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

Express.js · Pipe

res.app

res.app references the Express application instance handling the current response. It provides access to application configuration and is the same object exposed as req.app.

How it works

res.app exposes the Express application instance associated with the current response. Use it to access application-level configuration and methods from response middleware or route handlers; it refers to the same application available as req.app.

Syntax

res.app

Returns

Application instance

Key points

  • It gives handlers and middleware a reference to the application currently processing the response.
  • The response-side application reference is identical to the request-side req.app reference.
  • Application settings can be read through res.app, including the configured view engine.
  • Identity comparison can confirm that the response and request expose the same application instance.

Common mistakes

  • The value belongs to the application handling the current middleware execution, not an unrelated Express application.
  • Do not treat res.app and req.app as separate application objects; they reference the same instance.

Example: Read the Express application from a response

import express from 'express';

const app = express();

app.get('/settings', (req, res) => {
  const sameApp = res.app === req.app;
  res.json({
    viewEngine: res.app.get('view engine'),
    sameApp
  });
});

app.listen(3000);

This route reads application settings through the application instance referenced by the response.

When to use it

Access app settings

Read application configuration inside a response handler without importing the app instance.

Verify application identity

Check whether request and response objects point to the same Express application.

Reach application APIs

Use application methods from middleware that receives only the response object.

Interview questions

QWhat does res.app represent?

res.app is a response property containing the Express application instance that is handling the request. It lets response-side code access application configuration and methods, such as get().

Follow-up: How can you verify it matches the request-side application? Compare res.app === req.app; the documentation’s example shows this evaluates to true.

QWhat type is res.app, and how might it be used?

Its documented type is Application. In a handler, calling res.app.get('view engine') reads an application setting through the instance associated with the response.

Follow-up: Why might this be useful in middleware? Middleware can access application-level configuration without importing the app object directly.

QHow does res.app relate to req.app?

res.app and req.app refer to the same Express application instance for the current request. Therefore, either property can be used to reach that application from the corresponding object.

Follow-up: What should code avoid assuming? It should not assume the property identifies a new or separate app; it is the current request’s application reference.

  • req.app
  • Application
  • app.get

Source: Response. Checked 2026-10-15.