From 6112bbd6a46931729911077984a1b2449e597652 Mon Sep 17 00:00:00 2001
From: yelishgiri <118233081+yelishgiri@users.noreply.github.com>
Date: Fri, 8 Aug 2025 01:44:37 -0500
Subject: [PATCH 1/2] docs(route-handlers): add example for next('route') usage
---
en/guide/routing.md | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/en/guide/routing.md b/en/guide/routing.md
index 8ff238884a..5281ecb531 100755
--- a/en/guide/routing.md
+++ b/en/guide/routing.md
@@ -245,6 +245,26 @@ In Express 4.x, the `
You can provide multiple callback functions that behave like [middleware](/{{ page.lang }}/guide/using-middleware.html) to handle a request. The only exception is that these callbacks might invoke `next('route')` to bypass the remaining route callbacks. You can use this mechanism to impose pre-conditions on a route, then pass control to subsequent routes if there's no reason to proceed with the current route.
+You can use `next('route')` to skip the rest of a route's callbacks and pass control to the next route. For example:
+
+```js
+app.get('/user/:id', (req, res, next) => {
+ if (req.params.id === '0') {
+ return next('route')
+ }
+ res.send(`User ${req.params.id}`)
+})
+
+app.get('/user/:id', (req, res) => {
+ res.send('Special handler for user ID 0')
+})
+```
+
+In this example:
+
+- `GET /user/5` → handled by first route → sends "User 5"
+- `GET /user/0` → first route calls `next('route')`, skipping to the next matching `/user/:id` route
+
Route handlers can be in the form of a function, an array of functions, or combinations of both, as shown in the following examples.
A single callback function can handle a route. For example:
From f16c42e553e5bcd5c13770fae26ca6be65b027e7 Mon Sep 17 00:00:00 2001
From: Yelish Giri <118233081+yelishgiri@users.noreply.github.com>
Date: Fri, 15 Aug 2025 17:50:25 -0500
Subject: [PATCH 2/2] docs(route-handlers): remove redundant sentence in
next('route') section
Removed a duplicate explanation of next('route') to avoid redundancy.
The section now introduces the concept once and flows directly into the example,
making the docs more concise and easier to read.
---
en/guide/routing.md | 2 --
1 file changed, 2 deletions(-)
diff --git a/en/guide/routing.md b/en/guide/routing.md
index 5281ecb531..9d16c5cc7b 100755
--- a/en/guide/routing.md
+++ b/en/guide/routing.md
@@ -245,8 +245,6 @@ In Express 4.x, the `
You can provide multiple callback functions that behave like [middleware](/{{ page.lang }}/guide/using-middleware.html) to handle a request. The only exception is that these callbacks might invoke `next('route')` to bypass the remaining route callbacks. You can use this mechanism to impose pre-conditions on a route, then pass control to subsequent routes if there's no reason to proceed with the current route.
-You can use `next('route')` to skip the rest of a route's callbacks and pass control to the next route. For example:
-
```js
app.get('/user/:id', (req, res, next) => {
if (req.params.id === '0') {