Express req.route Property

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

What you’ll learn

  • What route metadata req.route contains.
  • Where in the request lifecycle req.route is available.
  • How to inspect route path/method for diagnostics.
  • Why this property is mainly for debugging, not core logic.

Usage syntax

javascript
req.route
req.route.path
req.route.methods
1

Inspect matched route path in handler

javascript
app.get('/users/:id', function (req, res) {
  res.json({
    routePath: req.route.path,
    methods: req.route.methods
  });
});
2

Route-level debug logging

javascript
app.post('/orders', function (req, res) {
  console.log('Matched route:', req.route.path, 'Method:', req.method);
  res.send('Order created');
});

❓ FAQ

It is an object representing the route currently matched for the request.
Commonly route path and method map metadata, useful for diagnostics/logging.
It is typically available inside matched route handlers, not in unrelated middleware before route resolution.
Usually no. It is best for observability and debugging rather than core business logic.
req.path is request URL path, while req.route is matched route definition metadata.
Did you know?

req.route describes the currently matched route definition and is useful for debugging route behavior.

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