Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 43 ยท Getting Started

What Is Express?

Learn what Express.js is, what it adds on top of Node's http module, how Express 5 differs from 4, and how this course runs a mini Express right in your browser.

Express is a small web framework for Node.js. It sits on top of Node's built-in http module and gives you three things: a way to say "when a request for this URL arrives, run this function" (routing), a way to run shared steps before your handlers (middleware), and a handful of helpers for reading requests and writing responses. It is probably the most widely used server library in the Node.js world, and many other tools copy its ideas.

Express deliberately stays small. It has no database layer, no template language of its own, no login system and no required folder layout. You add only the pieces you need from the npm ecosystem. That freedom is why it fits everything from a ten-line prototype to a large API, and also why you need to learn the common patterns, which this course covers.

If you have not met Node's own server yet, skim the HTTP server lesson first. Express makes the most sense once you have seen the plain version.

What Node already gives you

Node can serve HTTP without any framework. The http module hands you a request object and a response object, and everything else is up to you.

Node.js A plain Node server

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

This works, but look at what grows as the app grows: a long if chain, manual header setting, manual JSON conversion, manual 404s. Add query strings, URL parameters, JSON bodies, cookies and error handling, and you would be writing a framework. Express is that framework, written once and tested by millions of apps.

What Express adds

Express in three ideas

Routing Match a method and a path to a handler.
Middleware Small steps that run in order for each request.
Helpers res.json, req.query, redirects and more.

Everything else is an optional package.

1 / 2

Here is the same app as above written with real Express. This code is read-only on this site because npm packages cannot be installed in the browser:

JavaScript
import express from 'express';

const app = express();

app.get('/', (req, res) => {
  res.send('Home page');
});

app.get('/about', (req, res) => {
  res.json({ name: 'demo', version: 1 });
});

app.listen(3000, () => {
  console.log('Listening on http://localhost:3000');
});

There is no if chain, no manual headers and no manual 404: Express sends a standard "Cannot GET /missing" page when nothing matches. res.json stringifies the object and sets the content type for you.

Real code versus the stand-in

Be clear about what you are running in this course:

  • Real Express code appears in plain code blocks. You can copy it into a project on your computer and it will work with Express 5.
  • Stand-in code appears in runnable node examples. It is a small framework, about 60 lines long, that we write ourselves on top of node:http. It copies the Express API (app.get, app.use, req.params, res.json, next()) closely enough that the ideas carry over directly. It is not Express, and the lessons say so whenever the difference matters.

The next lessons show how the stand-in works (Inside Express), so there is no magic: you will see how routes are stored, matched and run.

The stand-in handles the common cases only. Real Express also does things like ETags, content negotiation, trust-proxy handling and a full path syntax. Where those matter, the lesson explains the real behavior in text.

Express 5 and Express 4

Express 5 became the default version on npm in 2025, after a very long wait. For most apps the change is small, and this course teaches Express 5. These differences matter most:

Topic Express 4 Express 5
Rejected promises in handlers You must catch and call next(err) Forwarded to the error handler automatically
Wildcard paths /files/* Named: /files/*path
Optional parameters /users/:id? Braces: /users{/:id}
req.body without a parser {} undefined
Default query parser qs (nested objects) Simple parser
Minimum Node.js Very old versions Node 18 or newer

Old helpers such as app.del() and res.json(status, body) were removed. We will meet each change in the lesson where it applies, and the deployment lesson ends with a migration checklist.

Where Express fits

Express is a good choice when you want a familiar, flexible tool with a huge ecosystem of middleware and examples. Newer frameworks such as Fastify, Koa and Hono make different trade-offs (speed, schemas, smaller cores). Compare them in Express and Minimal Frameworks. The core skills you learn here, routing, middleware and error handling, transfer to all of them.

A first look at the stand-in

Here is the same app on our stand-in. Notice how close it is to the real code above. The part between the marker comments is the stand-in; you will read it in two lessons.

Node.js The same app on the mini Express

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is Express built on?

    Express wraps Node's http request and response objects and adds routing, middleware and helpers.
  2. 2. Which of these does Express include by default?

    Express is minimal. Routing, middleware and response helpers are the core; databases, templates and authentication are optional add-ons.
  3. 3. What happens in Express 5 when an async handler throws or rejects?

    Express 5 forwards rejected promises to next(err), so you no longer need a try/catch in every async handler.
  4. 4. In this course, why are the runnable examples a stand-in?

    The runner has Node's standard library but no npm, so real Express code is read-only and a small hand-written framework shows how it works.

Summary

  • Express is a minimal web framework on top of Node's http module.
  • Its core is routing, middleware and request/response helpers.
  • Databases, templates and authentication are optional packages you choose.
  • Express 5 forwards rejected promises, uses named wildcards and changes a few defaults.
  • Real Express code is read-only here; runnable examples use a mini Express stand-in.

Next: Your First Express App.