Skip to content

docs(routing): clarify wildcard behavior and restructure route parameters - #2451

Merged
bjohansebas merged 18 commits into
expressjs:mainfrom
Akshay4754:docs/wildcard-route-parameters
Jul 28, 2026
Merged

docs(routing): clarify wildcard behavior and restructure route parameters#2451
bjohansebas merged 18 commits into
expressjs:mainfrom
Akshay4754:docs/wildcard-route-parameters

Conversation

@Akshay4754

Copy link
Copy Markdown
Contributor

Summary

This PR improves the discoverability of wildcard parameters in the Express 5 Route parameters documentation.

Instead of duplicating the existing wildcard documentation, it adds a short note that points readers to the existing Wildcards section.

Fixes #1891

@Akshay4754
Akshay4754 requested a review from a team as a code owner July 18, 2026 21:59
@netlify

netlify Bot commented Jul 18, 2026

Copy link
Copy Markdown

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 9718688
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/6a68ea2eed448b0008535c8c
😎 Deploy Preview https://deploy-preview-2451--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 96 (🔴 down 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

});
```

Wildcard parameters (`*`) are also supported in Express 5. Unlike named parameters (`:`), they capture one or more path segments and expose them as an array in `req.params`. See the [Wildcards](#wildcards) section above for details and examples.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Wildcard parameters (`*`) are also supported in Express 5. Unlike named parameters (`:`), they capture one or more path segments and expose them as an array in `req.params`. See the [Wildcards](#wildcards) section above for details and examples.
<Alert type="info">
Wildcard parameters (`*`) are only supports in Express 5. Unlike named parameters (`:`), they capture one or more path segments and expose them as an array in `req.params`. See the [Wildcards](#wildcards) section above or [migration guide](https://expressjs.com/en/guide/migrating-5/#path-route-matching-syntax) for details and examples.
<Alert>

Add abouve note on page: https://expressjs.com/en/5x/api/request/#reqparams

Some extra, but not necessary. Add alert not on 4x doc https://expressjs.com/en/4x/api/request/#reqparams

<Alert type="alert">
Wildcard parameters (`*`) are introduced in Express 5. Unlike named parameters (`:`), they capture one or more path segments and expose them as an array in `req.params`. See the [migration guide to 5x](https://expressjs.com/en/guide/migrating-5/#path-route-matching-syntax) for details.
<Alert>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

I've addressed the requested changes by:

  • Wrapping the wildcard parameter note in an Alert component.
  • Adding the wildcard parameter note to the Express 5 req.params documentation with a link to the migration guide.
  • Adding the suggested notice to the Express 4 req.params documentation.

Please let me know if there are any further changes or improvements you'd like me to make. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this wording is clear. In 4.x there are wildcard parameters, but with no explicit names. These can still be accessed from req.params (so I'd argue that they are parameters) under integer keys (in most cases there's just one unnamed parameter so - req.params[0]). In 4.x wildcards return strings instead of string[] like in 5.x.

Copy link
Copy Markdown
Contributor Author

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! That's a good clarification. I'll update the wording to distinguish the Express 4 behavior (req.params[0] returning a string) from the named wildcard parameters introduced in Express 5.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this is best fit.

<Alert type="info">
In Express 4, wildcards (`*`) are unnamed, whereas in Express 5, wildcards must be explicitly named (e.g., `/*splat`). Please check the [migration guide to 5.x](https://expressjs.com/en/guide/migrating-5/#path-route-matching-syntax) before upgrading your routes.
</Alert>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've updated the wording accordingly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly tell if anything else is required. Thanks

Comment thread src/content/api/4x/api/request/index.mdx Outdated

@krzysdz krzysdz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5.x docs (API and routing guide) still claim that only Express 5 supports wildcards.


<Alert type="info">

Wildcard parameters (`*`) are only supported in Express 5. Unlike named parameters (`:`), they capture one or more path segments and expose them as an array in `req.params`. See the [Wildcards](#wildcards) section above or the [migration guide](https://expressjs.com/en/guide/migrating-5/#path-route-matching-syntax) for details and examples.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to say "Express 5" anymore. The guides are versioned, so that redundancy isn't necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I've simplified the wording by removing the redundant "Express 5" reference from the versioned guides while keeping the migration guide reference.

@bjohansebas bjohansebas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I need to take a closer look at this. I feel like we're breaking the reading flow, so I'll briefly block it for now

@Akshay4754
Akshay4754 force-pushed the docs/wildcard-route-parameters branch from 37336e9 to fa31c8a Compare July 24, 2026 21:38
@Akshay4754

Akshay4754 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Hi @bjohansebas , @ShubhamOulkar ,I've addressed the requested feedback in the latest commits, including the reading-flow concerns and the Express 4 migration notes. Whenever you have time, I'd appreciate another look and suggest if any changes needed . Thanks!

@Akshay4754
Akshay4754 requested a review from ShubhamOulkar July 27, 2026 19:48
@krzysdz

krzysdz commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

I was wondering when did the "Wildcards" section referenced in <Alert> appear, because I'm pretty sure it wasn't there when #1891 was opened. Had it been there at that time, the issue most likely would not have been created. To be clear, this doesn't mean that I'm opposed to this PR.

Information about wildcards was introduced to the 5.x routing guide in #2263.

@bjohansebas bjohansebas changed the title docs: improve discoverability of wildcard parameters docs(routing): clarify wildcard behavior and restructure route parameters Jul 28, 2026
@bjohansebas

Copy link
Copy Markdown
Member

I think reorganizing it the way I did improves the readability of the docs, as well as the format for LLMs. The idea is to focus the guides only on the current versions; for everything else, we already have the migration guides if users run into incompatibilities.

Comment thread src/content/docs/en/5x/guide/routing.mdx Outdated
});
```

The examples above behave the same regardless of the [`strict routing` setting](/api/application/#application-settings). As with any other route, that setting only changes whether a trailing slash (such as `/order/`) is treated as a different path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really clear to me - is it about the trailing slash (such as /order/) in path or the requested URL1. It's confusing also because on one hand the examples show that with or without strict routing the trailing / (in path) makes a difference and on the other hand the second sentence of this paragraph says that it's what strict routing affects.

Footnotes

  1. I know how this works, but it's not explained well and confusing for anyone who does not already know it.

@bjohansebas
bjohansebas merged commit bb571d8 into expressjs:main Jul 28, 2026
13 of 14 checks passed
@bjohansebas

Copy link
Copy Markdown
Member

thanks @Akshay4754

@Akshay4754

Copy link
Copy Markdown
Contributor Author

Thanks! I appreciate the review and all the guidance.

@ShubhamOulkar

Copy link
Copy Markdown
Member

Great @Akshay4754 @bjohansebas @krzysdz 🫰

@Akshay4754
Akshay4754 deleted the docs/wildcard-route-parameters branch July 29, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing documentation for wildcard parameters

4 participants