Skip to content

These are the docs of abedmurrar/express, an unofficial fork of Express. The official Express docs are at expressjs.com. What the fork changes is in the Fork section.

Differences from Express 5.3.0 ​

So far the fork changes how Express is tested and built, not how it behaves: an app gets the same responses as on Express 5.3.0, except where 5.3.0 crashes the process or has a bug the fork fixes (see below). Bug fixes, speed-ups and strict TypeScript come next, on the same drop-in line (see the roadmap).

The full list is the "Unreleased (fork)" section of History.md.

Runtime ​

  • Node.js 22, 24 and 26 only. engines is >= 22. Express 5.3.0 supports Node.js 18 and later. CI runs the three supported versions on Linux and Windows.
  • Our own copies of router, send, serve-static, qs and body-parser. router 2.2.0, send 1.2.1, serve-static 2.2.1, qs 6.17.1 and body-parser 2.4.0 are vendored into lib/router, lib/send, lib/serve-static, lib/qs and lib/body-parser, with their licences and test suites, so routing, file-sending, query-parsing and body-parsing bugs can be fixed in the fork. They're the same versions Express 5.3.0 installs, and express.static now uses the same send as res.sendFile and res.download. The extended query parser and express.urlencoded({ extended: true }) use our qs, which needs no dependencies (it uses WeakMap and Map in place of side-channel). See VENDORED.md.
  • A throwing headers listener no longer crashes the process. A bad value in the headers option of res.sendFile or res.download (a CR or LF, or an invalid header name), or an express.static setHeaders function that throws, used to throw inside a file-stat callback and end the process on Express 5.3.0. The error now goes to the callback, or to next(err) and the app's error handler.
  • app.listen() doesn't swallow later server errors. Its startup error listener is removed once the server is listening, so a later error reaches the app's listeners, or is thrown when there are none, as with http.createServer(). Express 5.3.0 silently dropped the first one.
  • Files that stat as 0 bytes but have content are sent. Linux /proc and /sys files go out whole through res.sendFile, res.download and express.static, with no Content-Length and no ranges. Express 5.3.0 sent them empty. Really empty files are sent as before.
  • No per-request prototype swap on app.listen() servers. The server makes req and res with the app's prototypes already set, so app.handle() has nothing to swap. Apps see the same objects as before. The only visible difference: code that runs before the app on that server, such as an upgrade, connect or checkContinue listener, now gets req and res that already have the app's prototypes.
  • res.send sends binary bodies byte for byte. An ArrayBuffer, SharedArrayBuffer, DataView or any typed array is sent as the bytes it covers. Express 5.3.0 sent an ArrayBuffer as {}, a DataView as nothing, and a Uint16Array or Float64Array one byte per element, or answered 500.
  • res.set keeps an unknown Content-Type as given. res.set('Content-Type', 'custom-type') sends custom-type, where Express 5.3.0 sent false. res.send, res.json and res.sendFile then keep it too, where 5.3.0 used their default type.
  • res.redirect sends no Content-Length with Transfer-Encoding, as res.send already did, so clients accept the response.
  • res.cookie honours expires: 0 with a maxAge: the cookie gets Max-Age and no Expires.
  • res.jsonp falls back to JSON when the callback name has no allowed characters, instead of sending JavaScript that doesn't parse.
  • res.sendFile and res.download honour a per-call etag option. The app's etag setting is only the default, and the options object you pass is no longer changed.
  • res.render after another response no longer crashes the process. Without a callback, the "headers already sent" error goes to the error handler. Express 5.3.0 threw it from a deferred callback and ended the process.
  • res.render leaves its options object alone. res.locals is merged into a copy, so a frozen options object works and a shared one isn't changed.
  • A view name ending in . gets the usual lookup error through the callback, where Express 5.3.0 threw a require('') error synchronously.
  • View extensions match engines whatever their case. An engine registered as HTML renders user.html; Express 5.3.0 missed it and tried require('html'). An engine registered in the same case still wins, app.engines keeps the keys as registered, and file names keep their case.
  • res.links with nothing to add leaves the Link header alone. res.links({}) sends no Link header, and a relation given an empty array adds no entry. Express 5.3.0 sent an empty Link header, or one ending in , .
  • res.append keeps an existing empty header value. After res.set('X-A', ''), res.append('X-A', 'b') sends both values, as two header lines. Express 5.3.0 replaced the empty value.
  • res.redirect names a status without a standard message by its number. res.redirect(399, '/next') says 399. Redirecting to /next, where Express 5.3.0 said undefined. Redirecting to /next.
  • A quoted ; in a type parameter stays in its value. normalizeType('text/plain; foo="a;b"') from express/lib/utils gives foo "a;b", where Express 5.3.0 gave "a. Responses don't change.
  • RegExp paths with g or y match on every request. In Express 5.3.0 such a RegExp kept its lastIndex between requests and matched only every other request, which let requests past a guard like app.use(/^\/admin/g, auth). The fork starts every match at index 0.
  • A mount path made only of slashes keeps its slashes. In Express 5.3.0, app.use('//', router) (or ///) matched every request, because the trailing slashes were trimmed to an empty path, so the router answered /secret before the app's own guards. In the fork a // mount answers only // and // followed by /..., and app.get('//', ...) no longer answers /.
  • Mounting a router on itself at / throws. router.use(router), or a cycle through other routers mounted at /, throws a TypeError at mount time. Express 5.3.0 accepts it, and any request the router doesn't answer then overflows the stack. Cycles through a mount at another path, which end, still work.
  • A # fragment in the request target is dropped before routing. Node passes it through in req.url, and Express 5.3.0 then parsed //user@host/admin#z as a URL with a host and routed /admin. The fork drops the fragment from req.url and req.originalUrl first, so a request is routed and read as if the fragment had not been sent.
  • A strict router's '' route answers its mount path. With app.use('/dir', express.Router({ strict: true })), the router's get('') answers GET /dir and not GET /dir/. In Express 5.3.0 the strict router saw / for both, so a '' route never matched. A route for / still answers both, as in 5.3.0.
  • router.use(subApp) gives the caller its prototypes back. When a sub-app mounted with router.use() (or called as middleware inside another app) passes the request on, req and res get the calling app's prototypes back, as app.use() already did, so the middleware after it sees the caller's req.app and settings (trust proxy, for example). In Express 5.3.0 they kept the sub-app's. A bare router outside any app keeps the sub-app's, as before.
  • Userinfo in the Host header is dropped. In Express 5.3.0, Host: admin.example:x@public.example gave req.hostname admin.example, which let a request past a host-based guard. The fork uses the host after the last @, for the Host header and a trusted X-Forwarded-Host, and a host whose port is not all digits gives req.host and req.hostname undefined.
  • A trusted X-Forwarded-Proto is lowercased. HTTPS gives req.protocol https and req.secure true. Express 5.3.0 kept the case, so req.secure was false.
  • An IPv6 host has no subdomains. Host: [::ffff:127.0.0.1] gives req.subdomains []. Express 5.3.0 split the address on its dots.
  • A trailing root dot is not a subdomain. Host: tobi.ferrets.example.com. gives req.subdomains ["ferrets", "tobi"], as without the dot. Express 5.3.0 counted the empty label after it and gave ["example", "ferrets", "tobi"].
  • Fewer dependencies. The merge-descriptors, once and wrappy packages are gone, replaced by short built-in equivalents with the same behaviour. With body-parser and qs vendored, qs and the 18 packages it brought (side-channel and its chain) are gone too: a production install has 38 packages instead of 58.
  • Project links in package.json point to the fork, and upstream's funding entry is removed.
  • Built-in TypeScript types. The package ships types ported from @types/express 5.0.6 and @types/express-serve-static-core 5.1.3, so @types/express is no longer needed and code written for it compiles unchanged. See Install the fork.
  • An ES module entry. import loads index.mjs, a thin wrapper over the CommonJS build with the same named exports Node gives Express 5.3.0, so import and require share one copy of Express. package.json now has an exports map; it keeps require('express'), require('express/lib/...') and require('express/package.json') working, and other paths inside the package can no longer be required.

Additions ​

Opt-in: an app that doesn't use them behaves as on Express 5.3.0.

  • The view engines setting. app.set('view engines', ['pug', 'html']) lets res.render('page') render page.pug or page.html, whichever exists first, after the view engine extension. A name with an extension that has no engine, such as user.profile, gets one added. When nothing is found, the error lists the extensions tried. See Several template engines.

Tests that guard the drop-in promise ​

  • Differential harness. Thousands of scenarios (143 written by hand and 3,306 generated from every res method and req property) run on Express 5.3.0 and on the fork, and must give byte-identical responses and error logs. The method comes from ultimate-express's test runner.
  • Ecosystem check. Ten popular middleware packages (body-parser, cors, helmet, morgan, cookie-parser, express-session, compression, multer, passport, express-rate-limit) run on both and must give byte-identical responses and log lines.
  • Middleware's own test suites. The test suites of cors, express-session, multer, express-rate-limit, http-proxy-middleware, express-openapi-validator, express-fileupload, express-basic-auth, hpp and express-mongo-sanitize (1,678 tests) run against Express 5.3.0 and against the fork. Every test that passes on 5.3.0 must pass on the fork, and today all of them do.
  • Security test suite. Checks that an auth guard always runs before the route it protects however the path is spelled, that CR and LF never inject a header, where redirects point, that no request pollutes Object.prototype, and that file serving never leaves its root.
  • 100% coverage. Statements, branches, functions and lines of lib/ are measured with c8 and must stay at 100%, or CI fails.
  • Regression tests for 29 confirmed bugs. Each one asserts the correct behaviour and stays skipped until its fix lands.
  • Upstream test PRs. Eight upstream test-coverage pull requests are ported, keeping their authors.

Tooling ​

  • Biome is the only linter and formatter (no ESLint, no Prettier).
  • A benchmark on every PR that changes code, against Express 5.3.0, Fastify, Koa, Hono, polka and plain node:http. See Benchmarks.
  • Fewer installed packages for development: c8 replaces nyc (137 packages), and Biome replaces ESLint (63 packages).

An unofficial fork of Express, not the official project. Code: MIT. Docs adapted from expressjs.com by the Express contributors, CC BY 4.0, with changes (details).