req.app holds a reference to the Express application that is handling the request — the same object you create with express().
It shines when a middleware file only exports a handler and cannot close over the app variable. Inside that handler, call req.app.get('views') (or any setting) to reach the app. It is not a browser API; it exists on the server-side request object.
Syntax
Read req.app in your Express.js route handler. Start with this line.
Required. Created once; req.app points at it during the request
Middleware / route handler
Required. Where you read req.app
Settings via app.set
Optional. Config that handlers later read with req.app.get
Return Value
req.app is a property that refers to the Express application handling this request. Reading it returns that app instance — useful for settings and shared app state.
Express
const title = req.app.get('title');
const env = req.app.get('env');
Express.js Examples
Example 1 — Access the App from a Middleware Module
Export a handler that never imports app. It still reaches settings through req.app (the official docs pattern).
Create two apps.app is the parent; admin is a sub-app with its own settings.
Mount the sub-app.app.use('/admin', admin) attaches it under /admin.
req.app is the sub-app. Inside admin.get('/'), settings come from admin, not the parent.
Check mountpath.req.app.mountpath is /admin — see also app.mountpath.
Compatibility
Runtime Support
req.app is an Express.js request property. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers never see this object.
✓ Server · Express 4 & 5
req.app
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.
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
req.appExpress on Node.js
Bottom line: Study and run these examples with Node.js and the express package. Use req.app whenever a handler needs the application without a global import.
Frequently Asked Questions
It is a reference to the Express application instance that is currently handling the request — the same object you create with express().
Use it in middleware or route modules that do not close over the app variable, especially when a file only exports a handler and needs app settings.
Call req.app.get('settingName'), the same API as app.get for settings. Values come from app.set() or Express defaults like views.
Yes. res.app is identical to req.app — both point at the application using the middleware.
While a sub-app handles the request, req.app is that sub-app (not the parent). After the sub-app finishes, Express restores the parent prototypes.