Skip to content
BENIBIX Learn

Express.js

Development🌐 Web DevelopmentFrameworks

Also known as Express, ExpressJS

A small, plain web framework. It helps you build a server with Node.js.

Think of it like

Think of it like a plain, sturdy table. It does one job well, and you add the rest yourself.

Example

Lucy builds a tiny API for her shop with Express. Ten lines of code answer requests on port 3000.

Why it matters

Lots of coders start their server work with Express. It is small and easy to read.

Definition

Express is a small, simple web framework for Node.js. It lets you set up routes, read requests and send responses in a few lines. It does little on its own, so you add pieces called middleware for things like logins or reading forms. It was first released in 2010 and is one of the most used server tools in JavaScript. Many other Node.js frameworks are built on its ideas.

Example code

javascript
const express = require("express");
const app = express();
app.get("/", (req, res) => res.send("Hi Emma"));
app.listen(3000);
A whole web server that says Hi Emma at the home address.

Common mistake

Forgetting to catch errors in async routes. One unhandled error can crash the whole server.

Key takeaways

  1. 1
    Small. Routes, requests, responses.
  2. 2
    Add middleware. Plug in what you need.
  3. 3
    Runs on Node.js. JavaScript on the server.

Compare