Interview Prep
Interview questions, roadmaps and practice sets
Tutorials
Free tutorials on 30+ topics
Blog
Career guides, skills and interview tips
Free PDFs
Notes, cheat sheets and question banks
Certificates
Free skill tests and course certificates
Tools & Whiteboard
Free tools you can use right in the browser
Practice Tests
Mock tests, MCQs and quick Q&A
Free LMS
Learn on the Uncodemy LMS
Choose the best training program according to your career.
Improve the performance of your business with our innovative Industrial Training Program.
Read More →
Our instructor-led training classes are designed to make you an expert.
Read More →
Real-life case studies are a great way to demonstrate your practical knowledge.
Read More →
Explore blogs, latest technologies and industry updates with practical examples.
Read More →Browse all available training programs and choose the right one for your career.
Read More →Know more about who we are and what we stand for.
Discover our mission to equip individuals with essential IT skills and industry expertise.
Read More →
Free tutorials, interview questions, tools and calculators to help you learn.
Explore →Learn, practice and plan your career — bilkul free.
Book a free video counselling session and pick the right course for you.
Read More →Vercel and Netlify both host the React front end of a MERN app very well. The Express API can also run there, but only as serverless functions, and the database stays outside on MongoDB Atlas. That works for typical CRUD apps. It does not suit WebSockets, long-running jobs or anything that needs a server that is always on. For those, deploy React on Vercel or Netlify and Express on a long-running host. This guide shows both set-ups, with the config files you need.

A suggested repository layout:
my-app/
client/ # React app (Vite)
server/
app.js # Express app, exported, no app.listen()
db.js # cached MongoDB connection
local.js # app.listen() for local development only
api/index.js # Vercel entry point
netlify/functions/api.js # Netlify entry point
Export the app instead of calling listen(), and reuse the database connection between invocations. Opening a new connection on every request quickly exhausts Atlas connection limits.
// server/db.js
const mongoose = require("mongoose");
const cached = global._mongoose || (global._mongoose = { conn: null, promise: null });
async function connectDB() {
if (cached.conn) return cached.conn;
if (!cached.promise) cached.promise = mongoose.connect(process.env.MONGODB_URI);
cached.conn = await cached.promise;
return cached.conn;
}
module.exports = connectDB;
// server/app.js
const express = require("express");
const connectDB = require("./db");
const Note = require("./models/Note"); // a normal Mongoose model
const app = express();
app.use(express.json());
const router = express.Router();
router.get("/health", (req, res) => res.json({ ok: true }));
router.get("/notes", async (req, res) => {
await connectDB();
res.json(await Note.find().sort({ createdAt: -1 }).limit(20));
});
// "/api" for Vercel and local dev; the second path covers Netlify's function URL
app.use(["/api", "/.netlify/functions/api"], router);
module.exports = app;
// server/local.js (run with: node server/local.js)
require("dotenv").config();
require("./app").listen(5000, () => console.log("API on http://localhost:5000"));
During development, point Vite's dev-server proxy at http://localhost:5000 so the React app can call /api/... without CORS problems.
Vercel turns files in the top-level api/ folder into serverless functions. An Express app is a request handler, so it can be exported directly:
// api/index.js
module.exports = require("../server/app");
Then route API paths to that function and everything else to the React app. The second rule makes client-side routes such as /notes/42 work on refresh:
// vercel.json
{
"rewrites": [
{ "source": "/api/(.*)", "destination": "/api" },
{ "source": "/(.*)", "destination": "/index.html" }
]
}
cd client && npm install && npm run build) and the output directory (client/dist) if Vercel does not detect them.MONGODB_URI, JWT_SECRET and any other secrets under Project Settings → Environment Variables.A longer walkthrough is in deploying full-stack projects with Vercel.
Netlify Functions use a handler export. The serverless-http package adapts an Express app to that format:
// netlify/functions/api.js (npm install serverless-http)
const serverless = require("serverless-http");
const app = require("../../server/app");
module.exports.handler = serverless(app);
# netlify.toml
[build]
command = "cd client && npm install && npm run build"
publish = "client/dist"
functions = "netlify/functions"
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/api/:splat"
status = 200
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
The first redirect sends API calls to the function. The second is the single-page-app fallback; a public/_redirects file with /* /index.html 200 does the same job. Add environment variables under Site configuration → Environment variables, then connect the GitHub repository to deploy.
mongodb+srv:// connection string into MONGODB_URI.0.0.0.0/0) in Atlas Network Access. If you do this, rely on strong credentials and least-privilege database users. Paid plans of both platforms and Atlas offer tighter options.For the database code itself, see CRUD operations with Node and MongoDB.
| Aspect | Vercel | Netlify |
|---|---|---|
| Front-end hosting | Git-based deploys, previews per pull request, global CDN | Git-based deploys, deploy previews, global CDN |
| Express API | Export the app from a file in api/ | Wrap with serverless-http in Netlify Functions |
| Routing config | vercel.json rewrites | netlify.toml or _redirects |
| Framework focus | Built by the creators of Next.js, with first-class Next.js support | Framework-agnostic, with built-in forms and identity add-ons |
| Limits to check | Function duration, memory and bundle size per plan | Function duration, memory and invocations per plan |
Both have free tiers with usage limits and paid plans, and the limits change, so read the current pricing pages. Pick the one whose workflow you prefer. For a standard MERN app, either works.
Run Express on a long-running service (Render, Railway, Fly.io, a cloud VM or a container on AWS) if your app needs:
Then set the React app's API base URL through an environment variable (for Vite, VITE_API_URL; anything prefixed VITE_ is public, so never put secrets there), and enable CORS in Express for your front-end domain only. Deploying container apps with Docker and AWS covers that route.
.gitignore for .env./dashboard/settings) loads the app, not a 404./api/health returns {"ok":true} on the live URL.Secure and the right SameSite setting if the API is on another domain (see JWT authentication for MERN).