How to deploy MERN Stack


I have a MERN app with MongoDB Atlas as my database. Both backend and the frontend is in a folder call MyApp. In my My App folder, I have a server.js with express and cors and API routes and other stuffs. Also in the MyApp folder, I have a folder called frontend which is a React App. I have test locally and works well. HTTP://localhost:5000 is my backend API and http://localhost:3000, is the frontend React App. I have already setup Nginx and PM2.

Next, how do I deploy this MERN stack to a droplets. Many thanks in advance.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi, Shourov here. You can deploy your mern stack as a simple nodejs application. What you need to do is, just make a build of reactjs project and include it inside your server dir, then use express static and locate your build reactjs project. use a production route (*) and this will be resolve by the building one. that’s it. your mern is up and running.

or 2nd way you can deploy your backend or server at digital ocean and then you can deploy your frontend at netlify or firebase hosting, but before deploy make sure to use a proxy to fool react app.