Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Express.js · Interface

Express

The Express application object is created with express() and conventionally stored in app. It registers middleware and HTTP-method routes and can handle incoming requests.

How it works

Calling the top-level express() function creates an application object. The returned app can register middleware and HTTP-method routes, then listen for incoming connections; it is also available as req.app and res.app during request handling.

Syntax

const app = express();

Parameters

NameTypeDescription
No parameters are documented for the application interface itself; individual application methods define their own arguments.

Returns

The express() function returns an Express application instance.

Key points

  • The application instance is conventionally named app and represents the Express application.
  • Import Express and call express() to create the application instance.
  • Route handlers can access the current application through req.app or res.app.
  • Application routing methods are named after HTTP verbs, including get, post, and put.
  • The reference documents common routing methods explicitly, while Express supports additional HTTP-method route methods.

Common mistakes

  • Use app.all() only when middleware should run for every HTTP method at the selected path; it is not an ordinary HTTP-method route.
  • Use lowercase method names such as app.get() and app.post() when defining routes.

Example: Minimal Express application

import express from "express";

const app = express();
app.get("/", (_req, res) => {
  res.send("Hello World!");
});
app.listen(3000);

Creates an Express application, registers a GET route, and starts listening on port 3000.

When to use it

Define application routes

Build an HTTP server with route handlers.

Configure middleware

Apply shared processing such as authentication or parsing.

Start listening for requests

Expose the app to the Node.js HTTP server.

Inspect the current app

Access application configuration from handlers.

  • express()
  • app.all()
  • app.METHOD()
  • app.get()
  • app.post()
  • app.put()
  • app.delete()
  • app.use()

Source: Application Object · Express.js 4.x. Checked 2026-10-15.