Loading lessons...
Introduction to Express.js
What is Express.js?
Express is a minimal, unopinionated, and flexible Node.js web application framework that provides a robust set of features for building web applications and HTTP APIs.
Why Use Express over Native Node HTTP?
| Task | Native Node (node:http) | Express.js Framework |
|---|---|---|
| Server Setup | Verbose switch statement on req.url | Declarative routing (app.get, app.post) |
| Parsing JSON | Manual stream chunk buffer accumulation | Built-in express.json() middleware |
| Sending JSON | res.setHeader() + JSON.stringify() | res.json({ success: true }) |
| Route Parameters | Regex matching on URL path | Named route parameters (req.params.id) |
# Installing Express
npm install express
TL;DR
- Express abstracts low-level Node.js HTTP boilerplate into clean routing and middleware APIs.
- Lightweight, fast, and the de-facto standard framework for Node.js backends.