Express.js req.res Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Request

Definition

In Express.js, req.res holds a reference to the response object for the same HTTP cycle. In any route or middleware handler, req.res === res is true — they are the same object, not a copy.

Express sets this link so internals (and your code) can reach the response from req alone. Day to day, prefer the res argument for clarity. See the full request and response objects for related APIs.

Syntax

Read req.res in your Express.js route handler. Start with this line.

Express
req.res              // → Response (same as res)
req.res === res      // → true
res.req              // → Request (reverse link)
CallWhat it does
req.res // → Response (same as res)Primary signature.
req.res === res // → trueRelated call form.
res.req // → Request (reverse link)Related call form.

Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.

Library declarations
Express
const express = require("express");
const app = express();

req.res              // → Response (same as res)
req.res === res      // → true
res.req              // → Request (reverse link)

Parameters

This Express.js property is read from the request or response — it has no call parameters.

Return Value

req.res is a property pointing at the same response object as res for this request-response cycle. Reading it returns that res reference.

Express
function helper(req) {
  req.res.set('X-Helper', '1');
}
// later in the route, res still sees that header

Express.js Examples

Example 1 — Confirm req.res Is the Same Object

Prove the official identity check from the Express docs.

Express
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  console.log(req.res === res); // true
  console.log(res.req === req); // true
  res.send('OK');
});

app.listen(3000);

How It Works

  1. Express links the pair. Before your handler runs, Express sets req.res = res and res.req = req.
  2. Strict equality. === compares object identity — both checks print true.
  3. One response. Calling res.send('OK') is the same as calling req.res.send('OK').
  4. Takeaway. req.res is a back-pointer, not a second response.

Example 2 — Prefer the res Argument

Normal route style — clearer than going through req.res.

Express
const express = require('express');
const app = express();

app.get('/status', (req, res) => {
  res.json({ ok: true, method: req.method });
});

app.listen(3000);

How It Works

  1. Handler signature. Express passes (req, res) into the callback.
  2. Use res directly. res.json(…) is the standard, readable path.
  3. Read from req. Request data like req.method stays on the request side.
  4. No need for req.res here. You already have res in scope.

Example 3 — Helper That Only Receives req

When a shared function takes only the request, req.res is a valid way to reply.

Express
const express = require('express');
const app = express();

function denyIfGuest(req) {
  if (req.get('x-user') !== 'admin') {
    req.res.status(403).json({ error: 'Forbidden' });
    return false;
  }
  return true;
}

app.get('/admin', (req, res) => {
  if (!denyIfGuest(req)) return;
  res.json({ area: 'admin' });
});

app.listen(3000);

How It Works

  1. Helper signature. denyIfGuest(req) only takes the request.
  2. Reach the response. req.res.status(403).json(…) uses the linked response.
  3. Stop the route. Returning false lets the caller return early and avoid a double send.
  4. Alternative. Passing (req, res) into the helper is often clearer and easier to test — use that when you can.

Runtime Support

req.res is an Express.js request property. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not have this API.

✓ Server · Express 4 & 5

req.res

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.

Server Node.js runtime API
Node.js 18+ for Express 5 · 14+ typical for Express 4
Supported
Bun Express-compatible server apps
Supported
Deno Via npm compatibility / adapters
Supported
req.res Express on Node.js

Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.

Frequently Asked Questions

It is a property on the request object that holds a reference to the response object for the same HTTP cycle. In a handler, req.res === res is true.
Prefer the res argument in routes and middleware — it is clearer. Use req.res when you only have the request object (for example inside a helper that receives req).
res.req points back to the request. Together they form a two-way link Express sets up for each request.
No. It is the same response instance as the res parameter — not a copy.
No. It is a server-side Express property. Browsers only send HTTP requests to your app.

Next: req.route

Inspect the route that matched the current request.

req.route tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful