Express
Express.js is a minimal web framework for Node.js. It handles routing (mapping URLs to handler functions), middleware (functions that run on every request), and sending responses. It works with any frontend: React, Vue, or plain HTML.
Express is one of the most widely used Node.js frameworks. It does not impose a fixed project structure, so you can organise your code however makes sense for your project.
Express 5
Express 5 was released in 2024. All examples in this guide work on Express 5. The main change from Express 4 is that async route handlers now propagate thrown errors automatically, so you no longer need to wrap every async handler in a try/catch and call next(err) manually.
Install Express with:
npm install express
What to know first
Before starting with Express, you should be comfortable with:
- JavaScript fundamentals : variables, functions, objects, arrays
- Arrow functions
- Async/await and Promises
- HTTP basics: methods (GET, POST, PUT, DELETE), status codes, headers
- JSON: reading and writing JSON data
Pages in this section
- Installation : set up an Express project and configure nodemon
- Creating an Express App : the basic server structure and hello world
- Routing : GET, POST, PUT, DELETE, route parameters, and query strings
- Request Object : reading params, query strings, body, and headers
- Response Object : sending text, JSON, files, and redirects
- Middleware : custom middleware, built-in middleware, and third-party packages
- express.Router() : splitting routes into separate files
- Serve Static Files
: serving HTML, CSS, and images with
express.static - View Engines : rendering dynamic HTML with EJS
What to read next
- Installation : get your first Express app running