-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Improve clarity of next('route') usage in Route Handlers section #2034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Improve clarity of next('route') usage in Route Handlers section #2034
Conversation
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🚦 Lighthouse Results (Mobile & Desktop)
|
en/guide/routing.md
Outdated
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two sentences repeat content, whereas if the message can be improved and shown through the example, we shouldn’t repeat the content that was already mentioned earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out. I’ve removed the second sentence so the explanation is given only once, with the example showing the behavior directly. This should make the section more concise and avoid redundancy.
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.
Description:
This PR adds a concrete example demonstrating the use of next('route') in the “Route handlers” section of the Express routing documentation.
Currently, the docs mention next('route') but don’t show a simple, self-contained example, which could make it unclear for new users. This change:
Adds a GET /user/:id example that uses next('route') to skip to the next matching route.
Includes a short bullet-point explanation of the behavior for two different request paths (/user/5 and /user/0).
Before:
The section explains next('route') but doesn’t show a minimal code sample demonstrating it in action.
After:
The section now contains:
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
Why this change improves the docs:
Makes the next('route') behavior obvious without requiring guesswork.
Matches the style and tone of existing Express documentation.
Adds a practical example to complement the textual explanation.