Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of React Router Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-react-router-knowledge-patch)
---
name: react-router-knowledge-patch
description: React Router
version: "8.5.3"
license: MIT
metadata:
author: Nevaberry
---
# React Router Knowledge Patch
Load this skill when migrating React Router apps, configuring Framework Mode,
working with data requests or middleware, or integrating experimental React
Server Components. Use the topic references for complete guidance and examples.
## Reference index
| Reference | Topics |
| --- | --- |
| [Migration, packages, and tooling](references/migration-and-tooling.md) | Runtime requirements, imports, adapters, CLI, Vite, builds, streams |
| [Framework routing and configuration](references/framework-routing-and-config.md) | Route helpers, splitting, discovery, bundles, matching, navigation, masking, transitions |
| [Data loading and rendering](references/data-loading-and-rendering.md) | Hydration, SPA fallback, prerendering, revalidation, submissions, Single Fetch, errors |
| [Middleware and context](references/middleware-and-context.md) | Registration, context migration, execution, boundaries, lazy middleware, data strategies |
| [React Server Components](references/rsc.md) | Experimental APIs, route exports, custom entries, actions, builds, CSP, integrity |
| [Security, observability, and CSP](references/security-observability-and-csp.md) | Action origins, sessions, security updates, nonces, error reporting, instrumentation |
| [Type safety and APIs](references/type-safety-and-apis.md) | Generated types, route data, metadata, URL helpers, route stubs, router state |
## Breaking changes and deprecations
### Runtime and package migration
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 Node minimum. Published packages are ESM-only and use ES2022
for their TypeScript `target` and `lib`.
Remove `react-router-dom` in v8. Move its `RouterProvider` and `HydratedRouter`
imports to `react-router/dom`, and its other imports to `react-router`.
Replace `@react-router/dev/vite/cloudflare` with `@cloudflare/vite-plugin`.
`@react-router/dev` drops Wrangler 3 peer support, and `@react-router/express`
requires `express` in the range `^4.22.2 || ^5`.
### Framework configuration migration
Apply these changes when moving to v8:
| Previous setting | Required change or resulting behavior |
| --- | --- |
| `future.v8_middleware` | Remove it; middleware is always enabled |
| `future.v8_splitRouteModules` | Move to top-level `splitRouteModules`, default `true`; `false` keeps each route in one chunk and `"enforce"` requires 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 |
In v8, remove the Data Mode `Future.v8_middleware` augmentation and references
to `UNSAFE_MiddlewareEnabled` (`MiddlewareEnabled`). Loaders, actions, and
middleware always receive a `RouterContextProvider`; a custom server's
`getLoadContext` must return a provider instance. The obsolete `AppLoadContext`
export is removed in 8.0.1.
Remove `useRequestContextDomainName` from the Architect request-handler
options in v8: the adapter uses API Gateway's `requestContext.domainName`
by default.
### Route data and boundary declarations
Use `loaderData` instead of `data` in `MetaArgs`, `MetaMatch`, generated
`Route.*` equivalents, `Route.ComponentProps.matches`, and `UIMatch` values
from `useMatches()`. The old fields are deprecated in 7.8.0 and removed in v8.
A match's `loaderData` can be `undefined` when its loader throws to a boundary.
In v8, remove `hasErrorBoundary` from route objects, `<Route>` props, and lazy
definitions. React Router infers it from `ErrorBoundary` or `errorElement`;
`MapRoutePropertiesFunction` no longer requires that return field.
### Stable names and remaining deprecations
| Previous API | Replacement |
| --- | --- |
| `unstable_createContext`, `unstable_RouterContextProvider`, `unstable_getContext` | `createContext`, `RouterContextProvider`, `getContext` |
| `fetcher.unstable_reset()` | `fetcher.reset()` |
| `match.unstable_shouldCallHandler()`, `match.unstable_shouldRevalidateArgs` | `match.shouldCallHandler()`, `match.shouldRevalidateArgs` |
| `unstable_onError` | `onError` on `<RouterProvider>` and `<HydratedRouter>` |
| `unstable_instrumentations`, `unstable_pattern` in loader, action, middleware, and instrumentation arguments | `instrumentations`, `pattern` |
| `unstable_mask`, `Location.unstable_mask` | `mask`, `Location.mask` |
| `unstable_useTransitions` | `useTransitions` |
| `unstable_defaultShouldRevalidate` | `defaultShouldRevalidate` |
| `prerender.unstable_concurrency` | `prerender.concurrency` |
| `future.unstable_subResourceIntegrity` | Top-level `subResourceIntegrity` |
`match.shouldLoad` is deprecated; use
`matches.filter((match) => match.shouldCallHandler())` in a custom `dataStrategy`.
Include a result keyed by route ID for every handler the strategy runs;
omitting a required result produces a route error.
`react-router reveal --no-typescript` uses prebuilt JavaScript entries without
requiring Prettier at runtime; the flag is deprecated and slated for removal
in v9. The scaffolding CLI's move to native `fetch` removes its previous
`HTTPS_PROXY` support.
## Data requests, hydration, and revalidation
### Raw requests 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. Custom servers using `staticHandler.query()` or
`staticHandler.queryRoute()` should rename `unstable_normalizePath` to
`normalizePath` when adopting the stable API.
Trailing-slash-aware data requests use `/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 paths when enabling this behavior.
### Hydration and SPA fallback
Move `<RouterProvider fallbackElement>` to the root route's `HydrateFallback`
or `hydrateFallbackElement`. Initial `state.navigation.state` stays `"idle"`.
For SSR with `clientLoader.hydrate = true` and no `HydrateFallback`, return the
same data as the server loader to avoid a hydration mismatch. To prime a
client cache, store and return the result of `await serverLoader()`.
With `ssr: false`, serve prerendered files first. Rewrite other document
requests to `__spa-fallback.html` if `/` was prerendered; otherwise `index.html`
is the SPA fallback. Routes cannot export `action` or `headers`. A build-time
`loader` is allowed on the SPA root, or on a route matched by a prerendered path.
A prerendered parent with a `loader` and SPA-fallback children requires a
`clientLoader`, or prerendered child paths. Have that client loader supply data
directly: `serverLoader()` throws a 404 on SPA fallback paths. Keep the root
route compatible with server rendering because it renders at build time.
### Awaitable operations and revalidation defaults
The function from `useSubmit()`, fetcher `load()` and `submit()`, and
`useRevalidator().revalidate()` return promises. In Framework and Data Mode,
`await navigate(-1)` tracks completion of the resulting navigation.
Framework Mode with SSR revalidates still-matched server loaders on navigations
and form submissions by default; `shouldRevalidate` can opt out. SPA Mode uses
Data Mode defaults. In Framework Mode, `defaultShouldRevalidate` is `false`
after an action returns a 4xx or 5xx response.
Per-call `defaultShouldRevalidate: false` supplies an overridable default.
For a new child route's Single Fetch data request, this skips already matched
parent loaders on routes without a `shouldRevalidate` export. With `ssr: false`,
a route with a `loader` and no `clientLoader` skips revalidation by default;
use a `clientLoader` when its data needs to update after the build.
## Middleware, errors, and security
In Framework Mode, server middleware runs on document requests even without
loaders. After hydration it runs only for `.data` requests; add a server loader to the route
with the middleware if navigation would otherwise call no server handler.
A document POST shares context between its action and following loaders;
hydrated action POST and revalidation GET requests have separate server contexts.
Client actions and loaders can share the browser context for that submission.
Calling `next()` twice in one invocation throws. Server middleware can return
a `Response` or `data()` before `next()` to end the chain. After a downstream
middleware error is handled at an `ErrorBoundary`, ancestor server middleware
receives the resulting response from `await next()`.
Use `allowedActionOrigins` to permit UI-route submissions from trusted external
origins. Failed origin checks return HTTP 400. Validation uses the host in the
adapter-constructed request URL; check that host and the configured allowed
origins if legitimate mutations fail behind a reverse proxy.
Set `nonce` on `<ServerRouter>` to supply a default to nonce-aware SSR
components; an explicit component nonce takes precedence. Enable top-level
`subResourceIntegrity` to generate browser-script integrity entries.
## Routing, types, and observability
In Framework Mode, `href()` checks configured patterns and parameter names.
Choose concrete optional static segments and keep `?` on optional dynamic
segments. Splat values preserve slash separators and encode each segment.
`href()` and `generatePath()` leave `$ & + , ; = : @` literal but escape
`/ ? # %`, whitespace, and non-ASCII characters in named parameters.
In Framework and Data Mode, `mask` selects the address displayed for a client
navigation while `to` selects its route; a direct visit to the displayed URL
loads that route on its own.
`discover` and `prefetch` on `<Link>` and `<NavLink>` are Framework Mode only.
`matchPath()` rejects patterns with more than 12 optional (`?`) markers.
Await `flatRoutes()` before spreading it alongside explicit route entries.
Custom dev servers calling Vite's `createServer()` with the React Router plugin
keep route types current; use `react-router typegen --watch` for a standalone
watcher. Check `navigation.state` to narrow the fields from `useNavigation()`.
Use `onError` on `<RouterProvider>` or `<HydratedRouter>` for client errors.
After awaiting server request, client navigation, or client fetcher
instrumentation, read `result.meta?.url`, `result.meta?.pattern`, and
`result.meta?.params`; server request results also expose `result.statusCode`
when known.
## Experimental React Server Components
RSC support is experimental. In custom integrations, migrate
`unstable_routeRSCServerRequest` from `fetchServer` to `serverResponse`.
Pass the generated `clientVersion` to `unstable_matchRSCServerRequest` in a
custom `entry.rsc.tsx` so lazy discovery can detect older clients and reload.
Choose one export per client/server route pair: `default` or `ServerComponent`,
`ErrorBoundary` or `ServerErrorBoundary`, `Layout` or `ServerLayout`, and
`HydrateFallback` or `ServerHydrateFallback`. A Server Component can throw
`data()`, a `Response`, or `redirect()` while rendering; a thrown response's
body is omitted, so use `data()` when the boundary needs a payload.
For custom RSC document rendering, generate a fresh nonce per request, pass it
to `unstable_routeRSCServerRequest`, forward `renderHTML` options to the HTML
renderer, pass `options.nonce` to `unstable_RSCStaticRouter`, and use the same
nonce in the CSP header. See the RSC reference for complete entry examples.