Skip to content
Back to skills

React Router Knowledge Patch

ASecurity

React Router

  • 25 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added September 5, 2026
developmentjavascripttypescriptrustjavareactnodeexpressdebugginggitapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill react-router-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of React Router Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for React Router Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-react-router-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-react-router-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: react-router-knowledge-patch
description: React Router
version: "8.5.3"
license: MIT
metadata:
  author: Nevaberry
---


# React Router compatibility skill

Use this skill when migrating React Router apps, configuring Framework Mode,
or debugging routing, data loading, middleware, generated types, and RSC integrations.
Load the relevant reference for complete migration details and examples.
Version-specific instructions distinguish older flags from their stabilized or removed forms.

## Reference index

| Reference | Topics |
| --- | --- |
| [Migration, Packages, and Tooling](references/migration-and-tooling.md) | Runtime minimums, imports, adapters, scaffolding, CLI, Vite, server entries, deployment |
| [Framework Routing and Configuration](references/framework-routing-and-config.md) | Route config, matching, discovery, module splitting, build hooks, Vite environments, bundles |
| [Data Loading and Rendering](references/data-loading-and-rendering.md) | Hydration, SPA fallbacks, prerendering, revalidation, fetchers, requests, navigation, masking |
| [Middleware and Context](references/middleware-and-context.md) | Registration, context migration, execution, errors, route stubs, manual SSR, data strategies |
| [Type Safety and APIs](references/type-safety-and-apis.md) | Typegen, metadata, loader inference, typed paths, router state, form types |
| [React Server Components](references/rsc.md) | Experimental APIs, route exports, entries, server actions, request scope, CSP, integrity |
| [Security, Observability, and CSP](references/security-observability-and-csp.md) | Action origins, proxies, sessions, nonces, integrity, error reporting, instrumentation, fixes |

## Breaking changes and removals

### Runtime and imports

React Router 8.0 requires Node 22.22.0+, React 19.2.7+, and Vite 7+ for Framework Mode.
It supports all Active LTS Node versions and only the latest minor branch of each
Maintenance LTS version; minor releases can raise that Maintenance LTS minimum.
Published packages are ESM-only and use ES2022 for TypeScript `target` and `lib`.

In v8, remove `react-router-dom`. Import `RouterProvider` and `HydratedRouter`
from `react-router/dom`, and move its other imports to `react-router`.
Replace `@react-router/dev/vite/cloudflare` with `@cloudflare/vite-plugin`.
`@react-router/dev` drops Wrangler 3 peer support.
`@react-router/express` requires `express` in the range `^4.22.2 || ^5`.

### Framework configuration in v8

| Existing setting | Migration or resulting behavior |
| --- | --- |
| `future.v8_middleware` | Remove it; middleware is always enabled. |
| `future.v8_splitRouteModules` | Move to top-level `splitRouteModules`, default `true`; use `false` for a single chunk or `"enforce"` to require splittable routes. |
| `future.v8_viteEnvironmentApi` | Remove it; Framework Mode always uses the Vite Environment API. |
| `future.unstable_previewServerPrerendering` | Remove it; builds prerender through the Vite preview server. |
| `future.v8_passThroughRequests` | Remove it; loaders and actions receive raw `request` alongside normalized `url`. |
| `future.v8_trailingSlashAwareDataRequests` | Remove it; trailing-slash-aware data URLs are mandatory. |
| Architect `useRequestContextDomainName` | Remove it; the adapter uses API Gateway's `requestContext.domainName` by default. |

In v8, custom servers must return a `RouterContextProvider` instance from
`getLoadContext`. Remove the Data Mode `Future.v8_middleware` augmentation and
references to `UNSAFE_MiddlewareEnabled` (`MiddlewareEnabled`).
The obsolete `AppLoadContext` export is removed starting in 8.0.1.

### Removed fields and declarations

In v8, replace `data` with `loaderData` in `MetaArgs`, `MetaMatch`, generated
`Route.*` equivalents, `Route.ComponentProps.matches`, and `UIMatch` from `useMatches()`.
The fields were deprecated in 7.8.0; a match's `loaderData` can be `undefined`
when its loader throws to an error boundary.

Remove `hasErrorBoundary` from route objects, `<Route>` props, and lazy definitions
in v8. The router infers it from `ErrorBoundary` or `errorElement`;
`MapRoutePropertiesFunction` no longer requires that return field.

### Earlier migrations and deprecations

Move `<RouterProvider fallbackElement>` to the root `HydrateFallback` or
`hydrateFallbackElement`. Initial `state.navigation.state` stays `"idle"`.
Replace `<ServerRouter abortDelay>` with a `streamTimeout` export in milliseconds
from `app/entry.server.tsx` for Single Fetch pending promises.

In a custom `dataStrategy`, `match.shouldLoad` is deprecated. Use
`matches.filter((match) => match.shouldCallHandler())` to select handlers.
Include a route-ID-keyed result for each handler the strategy runs;
omitting a required route result produces an error for that route.

Starting in 7.14.2, automatic error serialization covers only `Error` and standard
subtypes. Pass custom error fields the client needs as explicit route data.
`react-router reveal --no-typescript` uses prebuilt JavaScript entry files from
8.3.1, no longer needs Prettier at runtime, and is deprecated for removal in v9.
In v8, scaffolding uses native `fetch` and loses the CLI's previous `HTTPS_PROXY` support.

## Stabilized API names

Use these migrations at the indicated API transition; full historical examples
and experimental behavior are in the topic references.

| Transition | Replacement |
| --- | --- |
| Middleware stabilization in 7.9.0 | `createContext`, `RouterContextProvider`, `getContext`, `middleware`, `clientMiddleware`; Framework opt-in is `future.v8_middleware`. |
| Module splitting and Vite Environment API in 7.10.0 | `future.v8_splitRouteModules`, `future.v8_viteEnvironmentApi` replace their `unstable_` forms. |
| Fetcher reset in 7.10.0 | `fetcher.reset()` replaces `fetcher.unstable_reset()`. |
| Data strategy matches in 7.10.0 | `match.shouldCallHandler()` and `match.shouldRevalidateArgs` replace their `unstable_` forms. |
| Client errors in 7.11.0 | `onError` replaces `unstable_onError` on `<RouterProvider>` and `<HydratedRouter>`. |
| Request handling in 7.15.0 | `future.v8_passThroughRequests`, `url`, and static-handler `normalizePath` replace unstable names. |
| Integrity and concurrency in 7.15.0 | Top-level `subResourceIntegrity` replaces `future.unstable_subResourceIntegrity`; `prerender.concurrency` replaces `prerender.unstable_concurrency`. |
| Instrumentation in 7.15.0 | `instrumentations` and `pattern` replace unstable names; the reference lists renamed types. |
| Navigation controls in 7.15.0 | `mask`, `Location.mask`, `useTransitions`, and `defaultShouldRevalidate` replace unstable names. |
| Data URLs in 7.16.0 | `future.v8_trailingSlashAwareDataRequests` replaces the unstable flag; the old key fails Framework config resolution. |

## Middleware and request context

Framework server middleware runs for document requests even without loaders.
After hydration, it runs only for `.data` requests; add a server loader to the
middleware route when a client navigation would otherwise call no server handler.
Calling `next()` twice in one middleware invocation throws.

A document POST shares server context between its action and following loaders.
A hydrated submission uses separate server contexts for the action POST and
revalidation GET; its client action and client loaders can share browser context.

Server middleware can short-circuit by returning a `Response` or `data()` before
`next()`. After a downstream middleware error reaches its `ErrorBoundary`, ancestor
server middleware receives the resulting `Response` from `await next()`.
Client middleware can redirect by returning `redirect("/login")`.

## Requests, hydration, and static rendering

### Raw and normalized URLs

With pass-through requests, `request` is the original HTTP request. The normalized
URL removes the `.data` suffix and internal `index` and `_routes` query parameters.
The stable argument name is `url`.
Trailing-slash-aware data paths are `/a/b/c/_.data` for `/a/b/c/`,
`/_.data` for `/`, and `/a/b/c.data` for `/a/b/c`.
Check cache rules and logic that matches data request paths when enabling this behavior.

### Hydration and SPA fallbacks

For SSR with `clientLoader.hydrate = true` and no `HydrateFallback`, the initial
client loader must return the same data as the server loader to avoid a mismatch.
To prime a cache, store `await serverLoader()` and return that same result.
A redirect from `serverLoader()` throws the redirect `Response`; let it propagate.

With `ssr: false`, serve prerendered files first. Rewrite other document requests
to `__spa-fallback.html` if `/` was prerendered, or use `index.html` otherwise.
Routes cannot export `action` or `headers`. The root can have a build-time `loader`;
with prerendering, another route can have one if a prerendered path matches it.
For a prerendered parent with SPA children, add a parent `clientLoader` or prerender
the children; `serverLoader()` throws 404 on SPA fallback paths.
Keep the root compatible with server rendering because it renders at build time.

### Prerendering and revalidation

The object form of `prerender` selects paths in `prerender.paths` and controls
concurrency with `prerender.concurrency`. A callback can use `getStaticPaths()`
to retain discovered static URLs while adding concrete parameterized URLs.
Resource routes, including binary responses, can be prerendered.
`prerender: true` skips action-only resource routes.

Framework SSR revalidates still-matched server loaders by default on navigations
and form submissions; `shouldRevalidate` can opt out. SPA Mode follows Data Mode defaults.
With `ssr: false`, a route with a `loader` and no `clientLoader` skips revalidation
by default. Use a `clientLoader` when build-time data needs to update.
From 7.10.0, Framework `defaultShouldRevalidate` is `false` after a 4xx or 5xx action response.
Per-call `defaultShouldRevalidate: false` supplies a default that route callbacks can override.

## Typed routing and navigation

Framework `href` checks route patterns and parameter names against route config.
From 7.6.2, choose concrete optional static segments and keep `?` on optional dynamic segments.
From 8.3.0, `href()` and `generatePath()` leave `$ & + , ; = : @` literal but
escape `/ ? # %`, whitespace, and non-ASCII characters in named parameters.
Splats preserve slash separators and encode each segment separately.
In 8.5.3, `matchPath()` rejects patterns with more than 12 optional (`?`) markers.

Use `useFetcher<typeof loader>()` or `typeof action` when migrating v6 data generics.
Check `navigation.state` to narrow `useNavigation()` fields; after handling `"idle"`,
`navigation.location` is defined. `unstable_useRouterState()` requires a data router
and exposes active and pending state in Data, Framework, and RSC modes.

The function returned by `useSubmit()`, fetcher `load()`/`submit()`, and
`useRevalidator().revalidate()` return promises you can await.
In Framework and Data Mode, `await navigate(-1)` tracks completion of the navigation.
`fetcher.reset()` restores the initial idle state.
`useFetchers()` retains its array identity until fetchers change.
`mask` changes the browser address while `to` selects a client navigation's route;
a direct visit to the displayed URL loads that route on its own.

## Security, errors, and instrumentation

Configure `allowedActionOrigins` for trusted cross-origin submissions to UI routes.
Failed origin checks return HTTP 400; `**` matches every domain.
Validation uses the request URL host built by the server adapter. If legitimate
mutations fail behind a reverse proxy, check that host and `allowedActionOrigins`.

Set `<ServerRouter nonce={nonce}>` to supply a default nonce to nonce-aware SSR
components; an explicit component nonce wins. Top-level `subResourceIntegrity`
enables integrity hashes, with separate custom RSC entry requirements in the reference.
Use `onError` for client errors and `instrumentations` for runtime instrumentation.
After awaiting request, navigation, or fetcher instrumentation, read
`result.meta?.url`, `result.meta?.pattern`, and `result.meta?.params`;
server requests also expose `result.statusCode` when known.

## Experimental React Server Components

RSC support is experimental. In RSC Framework Mode, choose one export per pair:
`default`/`ServerComponent`, `ErrorBoundary`/`ServerErrorBoundary`,
`Layout`/`ServerLayout`, and `HydrateFallback`/`ServerHydrateFallback`.
With `unstable_reactRouterRSC`, install `@vitejs/plugin-react` and add `react()` to Vite plugins.
Custom RSC entries have migrations for `serverResponse`, `clientVersion`, nonces,
and integrity hashes; load the RSC reference before changing those integrations.

Files in this skill

  • SKILL.md9.3 KB
  • coverage.json3.1 KB
  • references/data-loading-and-rendering.md8.7 KB
  • references/framework-routing-and-config.md8.7 KB
  • references/middleware-and-context.md8 KB
  • references/migration-and-tooling.md7.9 KB
  • references/rsc.md3.5 KB
  • references/security-observability-and-csp.md6.1 KB
  • references/type-safety-and-apis.md7.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.