What Express is
Express is a small web framework for Node.js. It receives HTTP requests and helps you answer them quickly: it connects addresses to functions, parses request data and sends the response in the right format. This course targets Express 5 and Node.js 22 or newer with ES modules (import and export).
A server without Express
Node.js has a built-in node:http module. You can write a server with it, but all the work is manual:
// server.js
import http from 'node:http';
const server = http.createServer((req, res) => {
if (req.method === 'GET' && req.url === '/posts') {
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
res.end('List of posts');
return;
}
res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
res.end('Not found');
});
server.listen(3000);Every address is one more if branch, headers are set by hand, and the body of a POST request has to be collected piece by piece from a stream.
The same server with Express
// server.js
import express from 'express';
const app = express();
app.get('/posts', (req, res) => {
res.send('List of posts');
});
app.listen(3000);The route takes one line, Express sets the headers itself and answers an unknown address with a 404 page.
What Express gives you
| Feature | What it means |
|---|---|
| Routes | An address and an HTTP method are connected to a function |
| Parameters | Parts of the address and the query string are already parsed |
| Middleware | Shared code for many requests: logging, login, body parsing |
| Responses | Ready methods for text, JSON, redirects, files |
| Templates | HTML pages are built from templates with data |
At the same time Express does not impose a database, a folder layout or a way to authenticate users — you choose those with separate packages.
What we will build
One example runs through the whole course — a blog with posts and comments. First it is an ordinary website with HTML pages and forms, then it gets a database, user login and a JSON API for other programs.
The course is for people who know JavaScript: functions, objects, promises, async/await and modules. If any of this is new, go back to the JavaScript tutorial.
Common mistake
Many articles on the internet are written for Express 4. Most of the code is the same, but there are differences: Express 5 changed the route path syntax (the * wildcard is now written as /*splat), and errors from async handlers are caught automatically. Check the version in package.json and, when in doubt, consult the Express 5 documentation.