Blog
2026-08-01
How to deploy a MERN project online
A MERN project is four moving parts, but only two need hosting: the Node.js server and the database. React is built and served by that same server. So a MERN deploy is really a Node.js deploy plus a MongoDB connection string.
The React build is served by the Express process, so the frontend and the API are one deploy rather than two, and there is no CORS to configure.
Step by step
- Change one line before you start: app.listen(process.env.PORT || 3000). A hard-coded port builds cleanly and then answers nothing.
- Make the root build script build React into the folder Express serves, so npm run build produces the whole application.
- Sign in to the dashboard with GitHub, press New app, and name it. The address under the field is the one you will share.
- Choose Nap, paste the repository URL and branch, and press Create and deploy. Press Connect GitHub first if the repository is private.
- Open Database, choose MongoDB, and press Add a database. It appears in the app as MONGODB_URI, so read that instead of a localhost string.
- Open Environment and add your JWT secret and any API keys. Saving restarts the app with them.
- Watch Live logs until the build finishes, then open the address. Turn on Deploy on push from the Deploy card, add the webhook it shows you on GitHub, and the next commit deploys itself.
Every step above is a control that exists in the dashboard today. The docs go further: custom domains, backups, rolling back a bad deploy, and what to read when a build fails.
Ready to try it? Sign in with GitHub and put 30 days of DormHost credit in your balance, no card required. Hosting is ₹99 a month on Nap afterwards.