Packages

react-router

8.5.1 · 27 Oct 2026MIT80.5M / weekRepositorynpmAtom feed

Your version

6.5.0

16 Dec 2022Where it was published

6.30.6 is the newest release of 6.x.

In short

1 new1 fixed9 changed1 internal

Security

3 advisories affect 6.5.0; 7.18.0 fixes them

Release note

The section about react-router of a note shared by several packages.

This release introduces support for Optional Route Segments. Now, adding a ? to the end of any path segment will make that entire segment optional. This works for both static segments and dynamic parameters.

Optional Params Examples

  • <Route path=":lang?/about> will match:

    • /:lang/about

    • /about

  • <Route path="/multistep/:widget1?/widget2?/widget3?"> will match:

    • /multistep

    • /multistep/:widget1

    • /multistep/:widget1/:widget2

    • /multistep/:widget1/:widget2/:widget3

Optional Static Segment Example

  • <Route path="/home?"> will match:

    • /

    • /home

  • <Route path="/fr?/about"> will match:

    • /about

    • /fr/about

Minor Changes

  • Allows optional routes and optional static segments

Patch Changes

  • Stop incorrectly matching on partial named parameters, i.e. <Route path="prefix-:param">, to align with how splat parameters work. If you were previously relying on this behavior then it's recommended to extract the static portion of the path at the useParams call site:

// Old behavior at URL /prefix-123
<Route path="prefix-:id" element={<Comp /> }>

function Comp() {
  let params = useParams(); // { id: '123' }
  let id = params.id; // "123"
  ...
}

// New behavior at URL /prefix-123
<Route path=":id" element={<Comp /> }>

function Comp() {
  let params = useParams(); // { id: 'prefix-123' }
  let id = params.id.replace(/^prefix-/, ''); // "123"
  ...
}

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.