Packages

react-router

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

Your version

7.2.0

18 Feb 2025Where it was published

7.18.6 is the newest release of 7.x.

In short

3 new7 fixed6 changed

Security

14 advisories affect 7.2.0; 7.18.0 fixes them

9 more

Release note

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

Minor Changes

  • New type-safe href utility that guarantees links point to actual paths in your app

    import { href } from "react-router";
    
    export default function Component() {
      const link = href("/blog/:slug", { slug: "my-first-post" });
      return (
        <main>
          <Link to={href("/products/:id", { id: "asdf" })} />
          <NavLink to={href("/:lang?/about", { lang: "en" })} />
        </main>
      );
    }

Patch Changes

  • Fix typegen for repeated params

    In React Router, path parameters are keyed by their name.
    So for a path pattern like /a/:id/b/:id?/c/:id, the last :id will set the value for id in useParams and the params prop.
    For example, /a/1/b/2/c/3 will result in the value { id: 3 } at runtime.

    Previously, generated types for params incorrectly modeled repeated params with an array.
    So /a/1/b/2/c/3 generated a type like { id: [1,2,3] }.

    To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters.
    So /a/1/b/2/c/3 now generates a type like { id: 3 }.

  • Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request

  • Properly handle revalidations to across a prerender/SPA boundary

    • In "hybrid" applications where some routes are pre-rendered and some are served from a SPA fallback, we need to avoid making .data requests if the path wasn't pre-rendered because the request will 404

    • We don't know all the pre-rendered paths client-side, however:

      • All loader data in ssr:false mode is static because it's generated at build time

      • A route must use a clientLoader to do anything dynamic

      • Therefore, if a route only has a loader and not a clientLoader, we disable revalidation by default because there is no new data to retrieve

      • We short circuit and skip single fetch .data request logic if there are no server loaders with shouldLoad=true in our single fetch dataStrategy

      • This ensures that the route doesn't cause a .data request that would 404 after a submission

  • Error at build time in ssr:false + prerender apps for the edge case scenario of:

    • A parent route has only a loader (does not have a clientLoader)

    • The parent route is pre-rendered

    • The parent route has children routes which are not prerendered

    • This means that when the child paths are loaded via the SPA fallback, the parent won't have any loaderData because there is no server on which to run the loader

    • This can be resolved by either adding a parent clientLoader or pre-rendering the child paths

    • If you add a clientLoader, calling the serverLoader() on non-prerendered paths will throw a 404

  • Add unstable support for splitting route modules in framework mode via future.unstable_splitRouteModules

  • Add unstable_SerializesTo brand type for library authors to register types serializable by React Router's streaming format (turbo-stream)

  • Align dev server behavior with static file server behavior when ssr:false is set

    • When no prerender config exists, only SSR down to the root HydrateFallback (SPA Mode)

    • When a prerender config exists but the current path is not prerendered, only SSR down to the root HydrateFallback (SPA Fallback)

    • Return a 404 on .data requests to non-pre-rendered paths

  • Improve prefetch performance of CSS side effects in framework mode

  • Disable Lazy Route Discovery for all ssr:false apps and not just "SPA Mode" because there is no runtime server to serve the search-param-configured __manifest requests

    • We previously only disabled this for "SPA Mode" which is ssr:false and no prerender config but we realized it should apply to all ssr:false apps, including those prerendering multiple pages

    • In those prerender scenarios we would prerender the /__manifest file assuming the static file server would serve it but that makes some unneccesary assumptions about the static file server behaviors

  • Properly handle interrupted manifest requests in lazy route discovery

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.