Express req.res Property

Beginner
⏱️ 7 min read
📚 Updated: May 2026
🎯 3 Code Examples

What you’ll learn

  • What req.res points to in Express internals.
  • How it relates to the res argument in handlers.
  • When using req.res is acceptable vs avoidable.
  • How to keep middleware code readable and testable.

Usage syntax

javascript
req.res
res
1

Access response via req.res (equivalent behavior)

javascript
app.use(function (req, res, next) {
  req.res.set('X-Request-Mode', 'middleware');
  next();
});
2

Prefer direct res argument for clarity

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

❓ FAQ

It is a reference from the request object to the current response object.
Rarely. In most middleware/route handlers, use the res argument directly for readability.
They point to the same response object instance during the request lifecycle.
It can be, but passing explicit dependencies is often cleaner and easier to test.
No. It behaves like using res directly, since both refer to the same object.
Did you know?

req.res references the current response object, but using res directly in handlers is usually clearer.

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.

4 people found this page helpful