Skip to content
hostcomplex

What Is Express.js?

Maarten Soetens 2 min read

Express.js: A Minimal Framework for Node.js

Express.js is a web framework for Node.js that provides the basic tools for building web applications and APIs: routing, request handling and middleware. It is deliberately small, so it leaves decisions such as the database, the template engine and the folder structure to the developer.

A framework is a set of ready-made building blocks. Without one, a Node.js developer would have to parse every incoming request, work out which code should handle each address and write the response details by hand. Express handles those parts, so the application code can focus on the features a site actually needs.

How Routing and Middleware Work in Express

Routing matches an HTTP method and a URL path to a function. For example, a GET request to a product list might run one function, while a POST request to the same address might save a new item. This makes it straightforward to organize an API or a site into clear endpoints.

Middleware is a chain of functions that each request passes through before reaching its final handler. Typical middleware checks whether a user is logged in, reads JSON data sent in the request body, writes access logs or sets security headers. Each function either passes control to the next one or ends the request early, for example by returning an error.

Express Compared With Full-Stack Frameworks

Express is often described as unopinionated, which means it does not impose a structure. Full-stack frameworks such as Laravel for PHP or Django for Python include a database layer, authentication, an admin area and migration tools as standard. With Express, you choose these pieces yourself, usually from the npm registry, and connect them.

That flexibility suits small APIs and custom services well. For a content-heavy site that needs many standard features from the start, a full framework can reduce the number of decisions. Neither approach is better in general. The right fit depends on the project's size and the team's experience. For background on the category, see what a web framework is.

Frequently asked questions

Is Express.js the same as Node.js?

No. Node.js is the runtime that executes JavaScript on a server. Express.js is a library that runs on top of Node.js to help build web applications. Express cannot run without Node.js, but Node.js can run many kinds of programs that have nothing to do with the web.

What does Express need from a web host?

A host must be able to run a Node.js process that stays running, start it with a command and forward web traffic to the port it listens on, usually through a reverse proxy. Shared plans that only support PHP cannot run Express applications. Check for Node.js support before you choose hosting.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.