MERN Stack with Next

I am building an app with the MERN stack, but have still not decided on the frontend. I was thinking of Next. How would I implement it? I want to use SSR and I want to make API calls from the Next app to my express app.


You can host API inside your Next.js app, it’s possible:

If you already have Express server, then you will have to enable CORS and fetch data from the client (or from Next server using getStaticProps)

Is there any way to do it like the normal MERN way we do with create-react-app?

Also, considering getStaticProps will never run on the client, you can simply get data from mLab or Mongo Atlas directly from your next app, which sounds crazy but totally secure and valid way for smaller projects.

Yes, sure. This would be “normal” way :point_down:

You will have 2 processes running - one express API and other one Next app. Next app will fetch data from Express API, giving latter will enable CORS.