An Express application is essentially a series of middleware function calls executed during the request-response cycle. Middleware functions have access to the request object (req), the response object (res), and the next middleware function, commonly named next. Middleware can execute any code, modify the request and response objects, end the request-response cycle, or pass control onward; if it does not end the cycle, it must call next(), otherwise the request will be left hanging. The types are application-level (bound with app.use() and app.METHOD()), router-level (bound to an express.Router() instance with router.use() and router.METHOD()), error-handling, built-in, and third-party. Middleware loads with an optional mount path, and multiple functions loaded together form a sub-stack at that mount point. next('route') skips the remaining middleware in a router stack and works only in functions loaded via app.METHOD() or router.METHOD(); next('router') exits the router instance entirely. Built-in middleware: express.static serves static assets, express.json parses JSON payloads, express.raw parses Buffer payloads, express.text parses text payloads, and express.urlencoded parses URL-encoded payloads. Scope: Express. Reviewed October 4, 2026.
Middleware and the request-response cycle
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- expressjs.com
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.