app.param(name, callback) adds a trigger for a named route parameter such as :id or :user. When a matching route runs, Express calls your callback before the route handlers — ideal for validation and loading data into req.
The callback signature is (req, res, next, value, name). Pair it with paths from app.get() and values in req.params.
Syntax
Call app.param in your Express.js app. Start with this line.
Required. Parameter name without the colon — 'id' for :id. An array registers the callback for each name.
callback
Required. (req, res, next, value, name). Call next() to continue, next(err) on failure, or next('route') to skip this route.
Return Value
app.param() returns the same application object (app), which is usually ignored. When you pass an array of names, the same callback is registered for each name in order.
GET /profile/ada
→ { "name": "Ada", "role": "admin" }
GET /profile/nobody
→ 404 User not found
How It Works
Named param user. Matches routes with :user.
Lookup. Find the record (here a plain object; in apps often a DB call).
Attach. Set req.user so the route stays thin.
404 early. Missing users never reach the JSON handler.
Compatibility
Runtime Support
app.param() is an Express.js application method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers only send the URL that contains the parameter.
✓ Server · Express 4 & 5
app.param()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
app.param()Express on Node.js
Bottom line: Run examples with Node.js and the express package, then request paths like /users/42.
Frequently Asked Questions
It registers a callback that runs when a named route parameter (like :id) appears in a matching route, before the route handlers.
callback(req, res, next, value, name) — the parameter value and its name come after next.
No. Even if several routes match the same param name, the param callback runs only once per request-response cycle.
No. They are local to the app or router where you define them. Mounted apps/routers need their own app.param / router.param.
No. It is server-side Express middleware wired to route parameters on Node.js.