In short
Node's built-in http module can run a server, but you end up parsing URLs and bodies by hand. Express gives you a clean way to say: for this request, send that response.
Express is a minimal web framework for Node.js. A few lines create an app, register routes and start listening on a port, which is the starting point of every MERN backend.

Think of it like this
The dhaba counter
At a highway dhaba, you say 'two parathas' at the counter and a plate comes back. The cook doesn't care who you are, only what you ordered. An Express app is that counter: a request comes in, your handler cooks, a response goes out.
Watch it happen
One request, one response
GET /health
1/5A browser or Postman sends a GET request to your server on port 3000.
The big ideas
What you need to know
app is your server
const app = express() creates it. app.listen(3000) starts accepting requests on that port.
Method + path = route
app.get("/health", handler) runs only for GET requests to /health. POST to the same path won't match.
JSON in, JSON out
app.use(express.json()) parses JSON bodies into req.body. res.json() sends objects back as JSON.
Always respond once
Every request must end with exactly one res.send or res.json. Forget it and the client hangs.
See it in code
Walk through the code
1import express from "express";2 3const app = express();4app.use(express.json());5 6app.get("/health", (req, res) => {7 res.json({ ok: true, time: new Date().toISOString() });8});9 10app.post("/echo", (req, res) => {11 res.status(201).json({ youSent: req.body });12});13 14const PORT = process.env.PORT ?? 3000;15app.listen(PORT, () => console.log(`API on http://localhost:${PORT}`));1/4Create the app and turn on JSON body parsing for every request.
Install with npm i express, add "type": "module" to package.json, and run node index.js. Try both routes with curl or Postman.
Save yourself the pain
Common mistakes
Oops
Forgetting app.use(express.json()) and getting req.body as undefined.
Do this instead
Add the JSON parser before your routes. Without it, Express doesn't read the request body at all.
Oops
Hard-coding port 3000, then the deploy platform can't reach your app.
Do this instead
Use process.env.PORT with a fallback. Hosting platforms tell your app which port to use.
Your mission
Your first Express API
Quick check
You send a POST with a JSON body, but req.body is undefined. What's the most likely cause?
Go deeper
- 1Install express, create app.js, add a GET / route and start it on port 5000.
- 2Keep the app setup and the app.listen call in separate files so tests can import the app.
- 3Read the port from process.env.PORT with a sensible default.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.