Express Basics
Part of the Web Development Roadmap
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 small, popular Node.js framework that makes it easy to start a server, define routes and send responses.

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
- 1Create an Express server that returns JSON from a /health route.
- 2Use nodemon or node --watch so the server restarts when you save.
- 3Test your route in the browser and with a tool like Postman.
Also part of these roadmaps
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.