UNPKG

174 kBMarkdownView Raw
1# `react-router`
2
3## v8.5.3
4
5### Patch Changes
6
7- Forward all `NavigateOptions` from `<RouterProvider>`'s `navigator.push()` and `navigator.replace()` to `router.navigate()` ([#15781](https://github.com/remix-run/react-router/pull/15781))
8 - Options such as `mask`, `defaultShouldRevalidate`, `flushSync`, and `viewTransition` now reach the router from `<Link>`, `useNavigate()`, and `useSearchParams()` inside descendant `<Routes>` in Data and Framework modes
9- Prevent fetcher action revalidation from completing a navigation with stale route matches while lazy route discovery is pending ([#15731](https://github.com/remix-run/react-router/pull/15731))
10- Fix a circular type error when arrow function route components access `matches` from `Route.ComponentProps` ([#15163](https://github.com/remix-run/react-router/pull/15163))
11 - Use the current route's `loaderData` type directly so TypeScript can resolve `matches` without evaluating the component's own props again
12- Fix `useBlocker` blocking a second time when the destination route updates search params in a mount effect ([#15538](https://github.com/remix-run/react-router/pull/15538))
13- Read `encType` and `formEncType` case-insensitively in `<Form>` and `useSubmit` ([#15776](https://github.com/remix-run/react-router/pull/15776))
14 - Submit `Multipart/Form-Data` as `multipart/form-data`
15- Restore the router location of a masked hash history entry on back and forward navigation ([#15771](https://github.com/remix-run/react-router/pull/15771))
16- Prevent `<HydratedRouter>` from re-rendering the previous route during navigation ([#15823](https://github.com/remix-run/react-router/pull/15823))
17 - Avoid a loop with `<Navigate state={...} replace>` that could exceed Safari's limit on `history.replaceState()` calls
18- Keep the current route's `actionData` while a submission to another route is loading ([#15716](https://github.com/remix-run/react-router/pull/15716))
19- Reject excessively large optional route path combinations in `matchPath`. Each pattern may contain up to 12 optional (`?`) markers. ([#15827](https://github.com/remix-run/react-router/pull/15827))
20- Let the browser handle clicks on links with a `download` attribute ([#15815](https://github.com/remix-run/react-router/pull/15815))
21 - Apply this behavior to `<Link download>` and custom links built with `useLinkClickHandler`
22- Suppress nonce hydration warnings when using `<ServerRouter nonce>` ([#15721](https://github.com/remix-run/react-router/pull/15721))
23 - Cover critical CSS and HTML link descriptors rendered by `<Links>`
24 - Cover developer scripts rendered by the default root error boundary and hydrate fallback
25- Fix blocked back/forward navigations in a memory router landing on the wrong history entry when the requested delta goes past the first or last entry ([#15779](https://github.com/remix-run/react-router/pull/15779))
26- Preserve `caseSensitive` on client routes in Framework Mode and `createRoutesStub()` ([#15808](https://github.com/remix-run/react-router/pull/15808))
27 - Forward `route.caseSensitive` in `createClientRoutes()` so client hydration, client-side navigation, lazy route discovery, and HMR match `createServerRoutes()` and `createStaticHandlerDataRoutes()`
28 - Forward `route.caseSensitive` in `createRoutesStub()`
29- Preserve loader data for the current routes when a background fetcher finishes during a navigation ([#15806](https://github.com/remix-run/react-router/pull/15806))
30 - Keep layout content visible when the navigation reuses that data
31- Discard invalid persisted scroll positions so new positions can be saved when the page is hidden ([#15794](https://github.com/remix-run/react-router/pull/15794))
32- Fix `session.unset()` to remove both regular and flashed values for the given key ([#15811](https://github.com/remix-run/react-router/pull/15811))
33 - Accept flash-only keys in typed sessions
34- Keep `NavLink` inactive in the prerendered Framework SPA fallback and set its active state from the browser URL after hydration ([#15818](https://github.com/remix-run/react-router/pull/15818))
35- Handle leading double slashes in static router `encodeLocation()` ([#15805](https://github.com/remix-run/react-router/pull/15805))
36 - Prevent `TypeError: Invalid URL` during SSR in `<ServerRouter>`, `<StaticRouterProvider>`, and `<StaticRouter>`, including when rendering query-only or hash-only `<NavLink>` destinations on double-slash request URLs
37- Fix unhandled single-fetch stream completion rejections while preserving errors for callers awaiting completion or deferred values ([#15765](https://github.com/remix-run/react-router/pull/15765))
38- Treat session cookies with an invalid payload shape as empty sessions ([#15809](https://github.com/remix-run/react-router/pull/15809))
39 - Pass only nonempty string session IDs to storage adapters
40 - Accept only non-array objects as data for cookie-backed sessions
41
42### Unstable Changes
43
44⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
45
46- Report RSC loader, action, and middleware errors through `unstable_matchRSCServerRequest`'s `onError` handler ([#15598](https://github.com/remix-run/react-router/pull/15598))
47 - Log request errors with `console.error` by default unless the request was aborted
48 - Report middleware errors that occur after a form action consumes the request body
49 - Avoid duplicate logging when rendering the default error boundary during SSR in RSC Data and RSC Framework modes
50- Avoid false 404s in RSC Framework and RSC Data modes when navigating while eager route discovery is still streaming route definitions ([#15801](https://github.com/remix-run/react-router/pull/15801))
51- Improve handling of invalid requests in RSC Framework and RSC Data modes ([#15828](https://github.com/remix-run/react-router/pull/15828))
52
53## v8.5.2
54
55### Patch Changes
56
57- Keep navigation metadata consistent after a submission action throws an error ([#15621](https://github.com/remix-run/react-router/pull/15621))
58 - Use the committed history action for loader `dataStrategy` navigation types and loading navigation history actions
59- Cancel the discarded response body for `HEAD` requests, so a resource route streaming a file no longer leaks its file descriptor ([#15634](https://github.com/remix-run/react-router/pull/15634))
60 - Keep observing nested deferred promise rejections after cancelling a data response so they cannot crash the server
61- Preserve streamed `<Suspense>` boundaries during hydration in development ([#15382](https://github.com/remix-run/react-router/pull/15382))
62 - Wrap the critical CSS reset in `React.startTransition` to prevent React 19 from silently discarding the server HTML and rendering the boundary on the client
63- Fix submissions to root form actions containing search parameters or a hash when a `basename` is configured ([#15725](https://github.com/remix-run/react-router/pull/15725))
64- Fix `href()` to throw for `null` required parameters and omit `null` splat parameters without a trailing slash, matching the behavior for `undefined` and the defined types ([#15754](https://github.com/remix-run/react-router/pull/15754))
65- Fix generated `MetaArgs.matches` types to stop at the current route instead of appending an unknown, possibly undefined tail ([#15697](https://github.com/remix-run/react-router/pull/15697))
66- Improve path generation and URL validation across `href()`, `generatePath()`, links, forms, fetchers, and redirects ([#15785](https://github.com/remix-run/react-router/pull/15785))
67- Stop `redirect()`, `redirectDocument()` and `replace()` from setting `status: 302` on the `ResponseInit` passed to them ([#15753](https://github.com/remix-run/react-router/pull/15753))
68 - Later responses created from the same init object no longer get status 302, and a frozen init no longer throws
69- Clear an `<Await>` render error when it receives a new `resolve` value, so the error element no longer stays on screen after navigating to a route whose data renders fine ([#15695](https://github.com/remix-run/react-router/pull/15695))
70- Run `clientMiddleware` during RSC client navigations and preserve it when route components update via HMR ([#15763](https://github.com/remix-run/react-router/pull/15763))
71- Handle `HEAD` resource responses consistently in RSC Framework and RSC Data modes ([#15783](https://github.com/remix-run/react-router/pull/15783))
72- Fix initial rendering of RSC routes with a `clientLoader` and no `HydrateFallback` ([#15763](https://github.com/remix-run/react-router/pull/15763))
73- Fix `<ScrollRestoration>` throwing an uncaught error before hydration when `sessionStorage` is unavailable ([#15566](https://github.com/remix-run/react-router/pull/15566))
74 - The inline restore script already logged the storage error, but its cleanup call accessed `sessionStorage` again and threw (e.g. Chrome with "Block all cookies", sandboxed cross-origin iframes)
75 - The error is still logged with `console.error`; only the second, uncaught throw is removed
76- Fix `useBlocker` leaving behind a stale blocker that keeps blocking navigation after its component is hidden and shown again with `<Activity>`, or after the router is recreated ([#15710](https://github.com/remix-run/react-router/pull/15710))
77
78## v8.5.1
79
80### Patch Changes
81
82- Fix `URIError: URI malformed` when an `ssr: false` dev server receives a URL path with a malformed percent-encoding ([#15649](https://github.com/remix-run/react-router/pull/15649))
83- Bound server route manifest processing for paths with expensive route expansion ([#15703](https://github.com/remix-run/react-router/pull/15703))
84 - Fall back to initial route discovery during server rendering and RSC document/data requests
85 - Account for the number and depth of candidate branches when using regex matching
86- Encode commas within paths sent to the lazy route discovery manifest endpoint so routes with commas in their paths are discovered correctly ([#15640](https://github.com/remix-run/react-router/pull/15640))
87- Fix fetcher revalidation errors bubbling to the root error boundary instead of the nearest boundary above the route that owns the fetcher ([#15676](https://github.com/remix-run/react-router/pull/15676))
88- Avoid duplicate history entries when posting a `<Form>` to the current URL with an encoded `action` ([#15679](https://github.com/remix-run/react-router/pull/15679))
89 - Replace the current history entry when the `action` contains characters that get percent-encoded, such as spaces or non-ASCII characters
90- Fix an unhandled promise rejection when the browser skips a `viewTransition` navigation, for example in a hidden tab ([#15582](https://github.com/remix-run/react-router/pull/15582))
91- Bubble rejected `lazy.Component` imports on loader-less routes to the nearest error boundary ([#15658](https://github.com/remix-run/react-router/pull/15658))
92 - Render the error boundary instead of a blank page
93- Preserve pending fetcher mutation revalidation when an older navigation or background reload completes to prevent stale loader data ([#15686](https://github.com/remix-run/react-router/pull/15686))
94 - Keep newer fetcher loads cancellable and preserve them when earlier revalidations finish or abort, preventing older responses from overwriting fresh fetcher data
95- Retry rejected `lazy` route imports instead of caching failures permanently ([#15689](https://github.com/remix-run/react-router/pull/15689))
96- Revalidate loader data when a fetcher action redirect is not followed ([#15557](https://github.com/remix-run/react-router/pull/15557))
97 - Revalidate when an action redirect is ignored because a newer navigation started or the fetcher unmounted while the action was running
98 - Include shared parent loaders when another navigation completed while the action was running
99 - Continue to respect `shouldRevalidate`
100 - Return fetchers to `idle` when a revalidation completes a pending navigation started by another fetcher's redirect
101- Avoid adding an incompatible `document.startViewTransition()` overload to the global `Document` type ([#15680](https://github.com/remix-run/react-router/pull/15680))
102 - Allow transition results to be assigned to the DOM `ViewTransition` type
103- Skip `deleteData` in `destroySession` when the session has no ID ([#15639](https://github.com/remix-run/react-router/pull/15639))
104 - Avoid failures when destroying a session without a cookie on storage that rejects an empty key
105- Surface the host's 404 response when a SPA fallback route has no prerendered data ([#15646](https://github.com/remix-run/react-router/pull/15646))
106 - Request single-fetch `.data` files for hydrating routes with a server `loader` in an `ssr: false` app with a `prerender` config
107 - Avoid the internal "No result found for routeId" error for non-prerendered parameterized paths served via the SPA fallback
108- Improve turbo-stream decoding validation and object property handling ([18e1fbd](https://github.com/remix-run/react-router/commit/18e1fbd))
109
110### Unstable Changes
111
112⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
113
114- Add an opt-in `<Await unstable_promise={promise}>` implementation based on React's `use()` API ([#15678](https://github.com/remix-run/react-router/pull/15678))
115 - Use `React.use` instead of React Router's internal promise tracking
116 - Accept promise-like values and retain `errorElement`, `useAsyncValue`, and `useAsyncError` support
117 - Handle only promise rejections with `errorElement` when using `unstable_promise`, allowing child render errors to bubble to the nearest React error boundary
118 - Track streamed promises during decoding so settled server content stays visible during hydration updates with either Await API or direct `React.use()`
119- Fix `URIError: URI malformed` when an API-only (`ssr: "unstable_api-only"`) server receives a URL path with a malformed percent-encoding ([#15649](https://github.com/remix-run/react-router/pull/15649))
120- Fix duplicate headers when throwing a redirect from an RSC server function ([#15667](https://github.com/remix-run/react-router/pull/15667))
121
122## v8.5.0
123
124### Minor Changes
125
126- Deprecate React Router's view transition APIs in favor of React's `<ViewTransition>` component, available in React 19.3 and later ([#15493](https://github.com/remix-run/react-router/pull/15493))
127 - Deprecate the `viewTransition` props/options, `useViewTransitionState`, and `NavLink`'s `isTransitioning` render prop and `transitioning` class
128 - Preserve existing behavior, including support for older React versions
129 - See the [migration guide](https://reactrouter.com/how-to/view-transitions) for a navigation example and compatibility considerations
130
131### Patch Changes
132
133- Fix `<Await>` failing to server render promises decoded from an RSC payload, which caused the Suspense boundary to switch to client rendering ([#15597](https://github.com/remix-run/react-router/pull/15597))
134- Declare `@types/react` and `@types/react-dom` as optional peer dependencies so the shipped type definitions resolve React types under strict (non-hoisted) node_modules layouts ([#15528](https://github.com/remix-run/react-router/pull/15528))
135- Fix the `unstable_useRouterState` documentation example to call the imported alias ([#15535](https://github.com/remix-run/react-router/pull/15535))
136- Render the `HydrateFallback` of a route discovered through `patchRoutesOnNavigation` during initial hydration ([#15537](https://github.com/remix-run/react-router/pull/15537))
137 - Routes discovered during initial hydration are now exposed in `state.matches` while their loaders run, so `<RouterProvider>` renders down to the discovered route's `HydrateFallback` instead of rendering nothing
138- Fix router state recovery when updates occur before `RouterProvider` subscribes, including when other subscribers are already attached, and report current client errors once without replaying server errors during hydration ([#15637](https://github.com/remix-run/react-router/pull/15637))
139- Fix `matchPath` not treating a static segment as optional when it contains characters outside `[\w-]` ([#15425](https://github.com/remix-run/react-router/pull/15425))
140- Fix an RSC server crash when a client aborts a document request while the HTML stream waits for the RSC payload ([#15612](https://github.com/remix-run/react-router/pull/15612))
141- Stop revalidating a fetcher after `fetcher.reset()`, so its cleared data no longer comes back on the next revalidation ([#15633](https://github.com/remix-run/react-router/pull/15633))
142
143### Unstable Changes
144
145⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
146
147- Add an `unstable_fetch` prop to `<HydratedRouter>` to customize JavaScript-issued manifest and server data requests in conventional Framework Mode ([#15586](https://github.com/remix-run/react-router/pull/15586))
148 - The function receives the intended request as well as context identifying the type of request
149 - Data request context includes `navigationType` (`"PUSH"`, `"REPLACE"`, or `"POP"` for navigation-initiated requests, including reloaded fetchers; `null` otherwise)
150 - Data strategies receive equivalent metadata through `unstable_initiator` and `unstable_navigationType`
151 - The custom fetch context is a discriminated union, so narrowing `type` to `"navigation"` guarantees a non-null `navigationType`, while other data requests have a `null` `navigationType`
152 - Fetchers reloaded after an initialization redirect retain the `"initialization"` type and include their fetcher key
153 - Like other router initialization options, the implementation is captured when the singleton router is created and thus subsequent prop changes are ignored
154 - Browser-managed data prefetches from `<Link prefetch>` use native `<link rel="prefetch">` elements and do not call the custom implementation
155 - Use the callback for custom fetch options, custom headers, safe request retries, or response header inspection
156 - Return response bodies unchanged so React Router can decode its manifest and Turbo Stream data protocols
157- Support API-only Framework Mode with runtime server data loading, actions, revalidation, and lazy route discovery ([#15601](https://github.com/remix-run/react-router/pull/15601))
158 - Hydrate prerendered pages from build-time data and fetch server loader data when hydrating a SPA fallback
159 - Preserve normal loader revalidation and server-action support for eagerly loaded and lazily discovered routes, and honor loader opt-outs when making server data requests
160- Add `unstable_useRouteDiscovery` for application-controlled route discovery in conventional Framework Mode ([#15602](https://github.com/remix-run/react-router/pull/15602))
161 - Discover selected destinations or load the running client's full route manifest without loading route modules
162 - Compose manifest-mismatch handlers, with shared recovery and cancellation that preserves application state
163 - Keep full-manifest failures catchable without rendering error boundaries, whether mismatch handlers use the hook or event's `loadAllRoutes()`
164 - Cancel pending revalidation alongside a canceled navigation, retaining existing data and settling interrupted fetchers before restoring Back/Forward history
165 - Enable `future.unstable_customRouteDiscovery` to opt in
166 - Apps without the flag retain existing discovery behavior
167 - Call `event.defaultBehavior()` from a custom mismatch handler to explicitly run built-in recovery
168- Return middleware short-circuit responses as-is for document requests in RSC modes, including resource routes, instead of decoding non-RSC bodies as Flight ([#15628](https://github.com/remix-run/react-router/pull/15628))
169 - Include server middleware in both eager and lazy RSC route configuration types
170 - Preserve HTML rendering for cached Flight responses returned by middleware, and pass through raw responses that replace the result of `next()`
171
172## v8.4.0
173
174### Minor Changes
175
176- Deprecate the `createStaticRouter({ branches })` option ([#15297](https://github.com/remix-run/react-router/pull/15297))
177 - `createStaticRouter` now caches route branches internally, ignores `branches`, and logs a deprecation warning when the option is provided
178 - The deprecated `EntryContext.branches` property remains available for compatibility but is always an empty array
179
180### Patch Changes
181
182- Prevent stale route discovery during manifest version-mismatch recovery ([#15489](https://github.com/remix-run/react-router/pull/15489))
183 - Keep concurrent manifest responses pending while a document reload is in progress
184 - Report a discovery error when a previous reload failed to resolve a version mismatch instead of loading a stale route or reloading repeatedly
185 - Fail pending requests if a document reload does not complete within five seconds or the document is restored from the back-forward cache, allowing subsequent requests to recover
186- Preserve lazy route module import errors during SPA navigations instead of replacing them with a missing `dataStrategy` result error ([#15464](https://github.com/remix-run/react-router/pull/15464))
187- Switch to more granular internal router contexts to avoid unnecessary route component re-renders when unrelated data router state changes ([#15376](https://github.com/remix-run/react-router/pull/15376))
188 - ⚠️ This contains some breaking changes to exported `UNSAFE_` contexts, so please review carefully if you are using those unsafe exports
189- Correctly escape streamed RSC redirect locations in meta tag attributes ([#15491](https://github.com/remix-run/react-router/pull/15491))
190- Avoid unintended `document.startViewTransition` calls during initial hydration and `router.revalidate()` calls ([#15484](https://github.com/remix-run/react-router/pull/15484))
191- Fix `SingleFetchNoResultError` thrown when a fetcher revalidates against a splat route during lazy route discovery ([#15395](https://github.com/remix-run/react-router/pull/15395))
192 - Track discovery per fetcher load so revalidation waits for the current load's discovery, even when the fetcher key is reused, while still restarting interrupted loaders after discovery completes
193- Preserve the underlying decode failure as the `cause` of the `Unable to decode turbo-stream response` error ([#15450](https://github.com/remix-run/react-router/pull/15450))
194
195### Unstable Changes
196
197⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
198
199- Add a Data Mode `future.unstable_routePatternMatching` flag for more efficient route matching powered by `@remix-run/route-pattern` ([#15298](https://github.com/remix-run/react-router/pull/15298))
200 - Add an `unstable_validateParams` route field to reject invalid parameter values and continue matching
201- Document access control requirements for RSC Server Functions ([#15490](https://github.com/remix-run/react-router/pull/15490))
202 - Treat every Server Function as a public endpoint that must perform all of its own access control checks
203 - Recommend route actions when access control should be provided by route middleware
204
205## v8.3.1
206
207### Patch Changes
208
209- Fix `Expected fetcher: <key>` error thrown on navigation when a fetcher is aborted during its post-action revalidation ([#15365](https://github.com/remix-run/react-router/pull/15365))
210- Fix lazy route discovery caching a path as discovered when the triggering navigation was aborted after the manifest response settled but before the route tree was patched, which permanently (for the session) shadowed the real route behind a catch-all or produced 404s on every subsequent visit ([#15399](https://github.com/remix-run/react-router/pull/15399))
211- Improve route matching performance for long paths ([#15417](https://github.com/remix-run/react-router/pull/15417))
212- Improve validation of action request origins ([#15419](https://github.com/remix-run/react-router/pull/15419))
213- Fix `<ScrollRestoration>` leaving `history.scrollRestoration` set to `"auto"` after a bfcache restore, which let the browser restore scroll on subsequent history traversals before the destination route had rendered ([#15397](https://github.com/remix-run/react-router/pull/15397))
214- Properly respect the `relative` option in `useSubmit`/`fetcher.submit` when resolivng the `action` path ([#15400](https://github.com/remix-run/react-router/pull/15400))
215- Add additional URL validation on client side navigations/redirects ([#15445](https://github.com/remix-run/react-router/pull/15445))
216
217## v8.3.0
218
219### Patch Changes
220
221- Encode path params in `href`/`generatePath` per RFC 3986 path-segment rules instead of `encodeURIComponent` ([#15310](https://github.com/remix-run/react-router/pull/15310))
222 - Characters that are valid literally in a path segment (`$ & + , ; = : @` — RFC 3986 `pchar`) are no longer percent-encoded, so values like a semver build `1.0.0+1` interpolate unchanged instead of becoming `1.0.0%2B1`
223 - Structural/unsafe characters (`/ ? # %`, whitespace, non-ASCII) are still escaped exactly as before
224- Use `crypto.randomUUID()` for `createMemorySessionStorage` session ids ([#15302](https://github.com/remix-run/react-router/pull/15302))
225 - `createMemorySessionStorage` is only intended for local development and testing - sessions are lost when the server restarts
226- Fix `NavLink` not applying its `pending` state when `to` has a trailing slash ([#15300](https://github.com/remix-run/react-router/pull/15300))
227- Preserve RSC route component metadata so routes with a `clientLoader` can skip unnecessary server requests once their components have rendered while still fetching missing server-rendered elements ([#15323](https://github.com/remix-run/react-router/pull/15323))
228- Harden RSC CSRF code paths ([#15311](https://github.com/remix-run/react-router/pull/15311))
229- Fix server crash (`TypeError: Invalid state: Unable to enqueue`) when a request is aborted while the RSC HTML stream has a pending flush ([#15286](https://github.com/remix-run/react-router/pull/15286))
230 - Handle cancellation of the `injectRSCPayload` readable side, clear the pending flush, and cancel the underlying RSC payload stream
231
232### Unstable Changes
233
234⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
235
236- Detect stale RSC clients during lazy route discovery and reload the destination document ([#15318](https://github.com/remix-run/react-router/pull/15318))
237
238 #### Migration
239
240 Apps using the default RSC Framework entry do not need to make any changes. Apps with a custom `entry.rsc.tsx` should import the generated client version and pass it to `unstable_matchRSCServerRequest`:
241
242 ```tsx
243 import clientVersion from "virtual:react-router/unstable_rsc/client-version";
244
245 return unstable_matchRSCServerRequest({
246 // ...
247 clientVersion,
248 });
249 ```
250
251- Add CSP nonce support to RSC document rendering ([#15320](https://github.com/remix-run/react-router/pull/15320))
252 - Add `nonce` options to `unstable_routeRSCServerRequest` and `unstable_RSCStaticRouter`
253 - Forward the nonce to the HTML renderer and apply it to injected RSC payload scripts and nonce-aware framework components
254
255 To adopt nonce-based CSP, update your `entry.ssr.tsx` (run `react-router reveal entry.ssr` first in RSC Framework Mode) to generate a fresh nonce for each request. Pass it to `routeRSCServerRequest`, spread the `renderHTML` options into React's HTML renderer, pass `options.nonce` to `RSCStaticRouter`, and use the same nonce in the `Content-Security-Policy` response header:
256
257 ```tsx
258 const nonce = crypto.randomUUID();
259 const response = await routeRSCServerRequest({
260 request,
261 serverResponse,
262 createFromReadableStream,
263 nonce,
264 async renderHTML(getPayload, options) {
265 const payload = getPayload();
266 return renderHTMLToReadableStream(
267 <RSCStaticRouter getPayload={getPayload} nonce={options.nonce} />,
268 {
269 ...options,
270 bootstrapScriptContent,
271 formState: await payload.formState,
272 signal: request.signal,
273 },
274 );
275 },
276 });
277 response.headers.set(
278 "Content-Security-Policy",
279 `script-src 'self' 'nonce-${nonce}'`,
280 );
281 ```
282
283## v8.2.0
284
285### Patch Changes
286
287- Fix `href()` to properly stringify and URL-encode param values, matching `generatePath()` ([#15277](https://github.com/remix-run/react-router/pull/15277))
288 - splat params preserve path separators while encoding each segment individually
289- Fix dynamic param extraction for routes with optional static segments ([#15200](https://github.com/remix-run/react-router/pull/15200))
290 - When a route path contains optional static segments (e.g. `/school?/user/:id`), the internal regex's incorrectly shifted parameter indices resulting in incorrect parameter extraction
291 - Consecutive optional static segments (e.g. `/one?/two?`) were only partially handled
292- Preserve navigation blocker state through a revalidation ([#15246](https://github.com/remix-run/react-router/pull/15246))
293- Fix route ranking for dynamic parameters with static extension suffixes ([#15273](https://github.com/remix-run/react-router/pull/15273))
294 - These were not being detected as dynamic param segments and instead got incorrectly scored higher as a static segment
295 - This meant they could potentially tie truly static routes like `/sitemap.xml` and outrank them based on definition order
296 - These are now correctly identified as dynamic parameter segments and scored correctly
297- Use ReactFormState types instead of unknown ([#15263](https://github.com/remix-run/react-router/pull/15263))
298
299## v8.1.0
300
301### Minor Changes
302
303- Return route metadata from server request, client navigation, and client fetcher instrumentations ([#15235](https://github.com/remix-run/react-router/pull/15235))
304 - Adds result metadata after instrumented calls complete, including the URL, matched route pattern, and params
305 - Adds known HTTP status codes to server request handler instrumentation results
306
307## v8.0.1
308
309### Patch Changes
310
311- Remove the obsolete `AppLoadContext` type export accidentally left over from v7 now that middleware is always enabled and server request context is provided through `RouterContextProvider`. ([#15207](https://github.com/remix-run/react-router/pull/15207))
312
313## v8.0.0
314
315### Major Changes
316
317- Remove the `future.v8_trailingSlashAwareDataRequests` flag ([#15100](https://github.com/remix-run/react-router/pull/15100))
318 - Trailing slash-aware data request URLs are now the default behavior.
319- Update `tsconfig.json` `target`/`lib` from `ES2020 -> ES2022` ([591853e](https://github.com/remix-run/react-router/commit/591853e))
320- Switch the published packages in `packages/` to ESM-only. ([#14895](https://github.com/remix-run/react-router/pull/14895)) ([59ebcf1](https://github.com/remix-run/react-router/commit/59ebcf1))
321- Remove deprecated `data` parameter in favor of `loaderData` for `meta` APIs (to align with `Route.ComponentProps`) ([#14931](https://github.com/remix-run/react-router/pull/14931))
322 - `Route.MetaArgs`, `Route.MetaMatch`, `MetaArgs`, `MetaMatch`, `Route.ComponentProps.matches`, `UIMatch`
323- Remove `future.v8_passThroughRequests` flag - the raw incoming `request` is now always passed through to `loader`/`action`. Use `url` for the normalized URL without React Router-specific implementation details (`.data` suffixes, `index`/`_routes` search params). ([#15079](https://github.com/remix-run/react-router/pull/15079))
324- Remove internal `hasErrorBoundary` field added to `router.routes` when using a data router ([#15074](https://github.com/remix-run/react-router/pull/15074))
325 - This should not impact user-facing code since this was an internal prop and was computed based on the presence of `ErrorBoundary` or `errorElement` on your route
326 - `hasErrorBoundary` is no longer accepted on `RouteObject` (`IndexRouteObject`/`NonIndexRouteObject`), `DataRouteObject`, `<Route>` JSX props, or as a key in `lazy` route definitions.
327 - The `MapRoutePropertiesFunction` signature no longer requires returning `hasErrorBoundary`; the router infers it directly.
328- Remove `react-router-dom` package ([#15076](https://github.com/remix-run/react-router/pull/15076))
329 - In v7 everything DOM-specific was collapsed into `react-router/dom`
330 - `react-router-dom` was kept around as a convenience so existing v6 app imports would still work
331 - For v8, you will need to swap `react-router-dom` imports:
332 - `RouterProvider`/`HydratedRouter` should be imported from `react-router/dom`
333 - Everything else should be imported from `react-router`
334- Remove `future.v8_middleware` flag — middleware is always enabled in v8 ([#15078](https://github.com/remix-run/react-router/pull/15078))
335 - The `future.v8_middleware` flag has been removed; middleware is now always enabled
336 - The `context` parameter passed to `loader`, `action`, and `middleware` functions is always a `RouterContextProvider` instance
337 - `getLoadContext` functions in custom servers must return a `RouterContextProvider` — returning a plain object is no longer supported
338 - The `MiddlewareEnabled` type (previously exported as `UNSAFE_MiddlewareEnabled`) has been removed since the conditional it gated is now unconditional
339 - The `Future` module augmentation pattern (`interface Future { v8_middleware: true }`) is no longer needed to type `context` in Data Mode
340- Update minimum Node version to 22.22.0 ([#14928](https://github.com/remix-run/react-router/pull/14928))
341- Update minimum React version to 19.2.7 ([#15062](https://github.com/remix-run/react-router/pull/15062))
342
343### Minor Changes
344
345- Bump dependencies ([#15080](https://github.com/remix-run/react-router/pull/15080))
346 - Bumped `cookie` from `^1.0.1` to `^1.1.1`
347 - Bumped `set-cookie-parser` from `^2.6.0` to `^3.1.0`
348
349### Patch Changes
350
351- Ensure client middleware errors load lazy route error boundaries before bubbling ([#15086](https://github.com/remix-run/react-router/pull/15086))
352- Remove explicit `onSubmit` type override from `SharedFormProps` to fix deprecation warning with `@types/react@19.x` ([#14932](https://github.com/remix-run/react-router/pull/14932)) ([59ebcf1](https://github.com/remix-run/react-router/commit/59ebcf1))
353- Update package builds to preserve individual module files in published artifacts. Public APIs and documented import paths are unchanged. ([#15092](https://github.com/remix-run/react-router/pull/15092))
354 - Updated package TypeScript configs to support modern module syntax used by the build configuration.
355- Migrate package builds from `tsup` to `tsdown`. Published package entry points and public APIs are unchanged. ([#15092](https://github.com/remix-run/react-router/pull/15092))
356- Upgrade React Router's TypeScript tooling to TypeScript 6. Runtime behavior and public APIs are unchanged. ([#15092](https://github.com/remix-run/react-router/pull/15092))
357
358## v7.18.0
359
360### Patch Changes
361
362- Fix server handler prerender responses when using `ssr: false` and `future.v8_trailingSlashAwareDataRequests: true`. Avoids false positive "SPA Mode" detection when serving prerendered paths ([#15173](https://github.com/remix-run/react-router/pull/15173))
363- Use the `ServerRouter` nonce for nonce-aware SSR components when they don't provide their own value so strict CSP pages can load them. ([#15170](https://github.com/remix-run/react-router/pull/15170))
364- Use `turbo-stream` to serialize and deserialize Framework Mode hydration errors ([#15175](https://github.com/remix-run/react-router/pull/15175))
365- Precompute route branch matchers to avoid recompiling route path regexes during matching ([#15186](https://github.com/remix-run/react-router/pull/15186))
366- Use the constructed request URL host when validating action request origins. ([#15185](https://github.com/remix-run/react-router/pull/15185))
367- Remove the un-documented custom error serialization logic from Data Mode SSR built-in hydration flows ([#15175](https://github.com/remix-run/react-router/pull/15175))
368- Validate protocols in RSC render redirects ([#15177](https://github.com/remix-run/react-router/pull/15177))
369- Consolidate url normalization logic and better handle mixed slashes ([#15176](https://github.com/remix-run/react-router/pull/15176))
370
371## v7.17.0
372
373### Minor Changes
374
375- Ship a subset of the official documentation inside the `react-router` package ([#15121](https://github.com/remix-run/react-router/pull/15121))
376 - Markdown docs are now available in `node_modules/react-router/docs`, letting AI coding agents and the React Router agent skills read official docs locally
377 - Excludes auto-generated API docs (`api/`), `community/` content, and tutorials (`tutorials/`)
378
379## v7.16.0
380
381### Minor Changes
382
383- Stabilize `future.unstable_trailingSlashAwareDataRequests` as `future.v8_trailingSlashAwareDataRequests` ([#15098](https://github.com/remix-run/react-router/pull/15098))
384
385### Patch Changes
386
387- Disable manifest path when lazy route dicovery is disabled ([#15068](https://github.com/remix-run/react-router/pull/15068))
388
389- Fix browser URL creation to use the configured history window instead of the global window. ([#15066](https://github.com/remix-run/react-router/pull/15066))
390 - Pass the history/router window through to `createBrowserURLImpl` so custom window contexts keep the correct URL origin.
391
392- Fix `useNavigation()` return type to preserve discriminated union across navigation states ([#15095](https://github.com/remix-run/react-router/pull/15095))
393
394- Widen `MetaDescriptor` `script:ld+json` type from `LdJsonObject` to `LdJsonObject | LdJsonObject[]` to permit multiple JSON-LD schemas in a single `<script type="application/ld+json">` tag emitted by `<Meta />` ([#15082](https://github.com/remix-run/react-router/pull/15082))
395
396## v7.15.1
397
398### Patch Changes
399
400- Update router to operate on fetcher Maps in an immutable manner to avoid delayed React renders from potentially reading an updated but not yet committed Map. This could result in brief flickers in some fetcher-driven optimistic UI scenarios. ([#15028](https://github.com/remix-run/react-router/pull/15028))
401- Fix `serverLoader()` returning stale SSR data when a client navigation aborts pending hydration before the hydration `clientLoader` resolves ([#15022](https://github.com/remix-run/react-router/pull/15022))
402- Fix `RouterProvider` `onError` callback not being called for synchronous initial loader errors in SPA mode ([#15039](https://github.com/remix-run/react-router/pull/15039)) ([#14942](https://github.com/remix-run/react-router/pull/14942))
403- Memoize `useFetchers` to return a stable identity and only change if fetchers changed ([#15028](https://github.com/remix-run/react-router/pull/15028))
404- Internal refactor to consolidate mutation request detection through shared utility ([#15033](https://github.com/remix-run/react-router/pull/15033))
405
406### Unstable Changes
407
408⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
409
410- Add a new `unstable_useRouterState()` hook that consolidates access to active and pending router states (RFC: #12358) ([#15017](https://github.com/remix-run/react-router/pull/15017))
411 - Data/Framework/RSC only — throws when used without a data router
412 - This should allow you to consolidate usages of the following hooks which will likely be deprecated and removed in a future major version
413 - `useLocation`
414 - `useSearchParams`
415 - `useParams`
416 - `useMatches`
417 - `useNavigationType`
418 - `useNavigation`
419
420 ```ts
421 let { active, pending } = unstable_useRouterState();
422
423 // Active is always populated with the current location
424 active.location; // replaces `useLocation()`
425 active.searchParams; // replaces `useSearchParams()[0]`
426 active.params; // replaces `useParams()`
427 active.matches; // replaces `useMatches()`
428 active.type; // replaces `useNavigationType()`
429
430 // Pending is only populated during a navigation
431 pending.location; // replaces `useNavigation().location`
432 pending.searchParams; // equivalent to `new URLSearchParams(useNavigation().search)`
433 pending.params; // Not directly accessible today
434 pending.matches; // Not directly accessible today
435 pending.type; // Not directly accessible today
436 pending.state; // replaces `useNavigation().state`
437 pending.formMethod; // replaces useNavigation().formMethod
438 pending.formAction; // replaces useNavigation().formAction
439 pending.formEncType; // replaces useNavigation().formEncType
440 pending.formData; // replaces useNavigation().formData
441 pending.json; // replaces useNavigation().json
442 pending.text; // replaces useNavigation().text
443 ```
444
445## v7.15.0
446
447### Minor Changes
448
449- Stabilize `unstable_defaultShouldRevalidate` as `defaultShouldRevalidate` on `<Link>`, `<Form>`, `useLinkClickHandler`, `useSubmit`, `fetcher.submit`, and `setSearchParams` ([a993f09](https://github.com/remix-run/react-router/commit/a993f09))
450 - ⚠️ This is a breaking change if you have already opted into the unstable version - you will need to update your code accordingly
451
452- Stabilize the instrumentation APIs. `unstable_instrumentations` is now `instrumentations` and `unstable_pattern` is now `pattern` ([a993f09](https://github.com/remix-run/react-router/commit/a993f09))
453 - The `unstable_ServerInstrumentation`, `unstable_ClientInstrumentation`, `unstable_InstrumentRequestHandlerFunction`, `unstable_InstrumentRouterFunction`, `unstable_InstrumentRouteFunction`, and `unstable_InstrumentationHandlerResult` types have had their `unstable_` prefixes removed
454 - ⚠️ This is a breaking change if you have already opted into the unstable version - you will need to update your code accordingly
455
456- Stabilize `unstable_mask` as `mask` on `<Link>`, `useLinkClickHandler`, and `useNavigate`, and rename the corresponding `Location.unstable_mask` field to `Location.mask` ([a993f09](https://github.com/remix-run/react-router/commit/a993f09))
457 - ⚠️ This is a breaking change if you have already opted into the unstable version - you will need to update your code accordingly
458
459- Stabilize the `unstable_normalizePath` option on `staticHandler.query` and `staticHandler.queryRoute` as `normalizePath` ([a993f09](https://github.com/remix-run/react-router/commit/a993f09))
460 - ⚠️ This is a breaking change if you have already opted into the unstable version - you will need to update your code accordingly
461
462- Stabilize `future.unstable_passThroughRequests` as `future.v8_passThroughRequests` ([a993f09](https://github.com/remix-run/react-router/commit/a993f09))
463 - ⚠️ This is a breaking change if you have already opted into the unstable version - you will need to update your code accordingly
464
465- Remove `unstable_subResourceIntegrity` from the runtime `FutureConfig` type; the flag is now controlled by the top-level `subResourceIntegrity` option in `react-router.config.ts` ([a993f09](https://github.com/remix-run/react-router/commit/a993f09))
466 - ⚠️ This is a breaking change if you have already opted into the unstable version - you will need to update your code accordingly
467
468- Stabilize `unstable_url` as `url` on `loader`, `action`, and `middleware` function args ([a993f09](https://github.com/remix-run/react-router/commit/a993f09))
469 - ⚠️ This is a breaking change if you have already opted into the unstable version - you will need to update your code accordingly
470
471- Stabilize `unstable_useTransitions` as `useTransitions` on `<BrowserRouter>`, `<HashRouter>`, `<HistoryRouter>`, `<MemoryRouter>`, `<Router>`, `<RouterProvider>`, `<HydratedRouter>`, and `useLinkClickHandler` ([a993f09](https://github.com/remix-run/react-router/commit/a993f09))
472 - ⚠️ This is a breaking change if you have already opted into the unstable version - you will need to update your code accordingly
473
474### Patch Changes
475
476- Add `nonce` to `<Scripts>` `<link rel="modulepreload">` elements (if provided) ([af5d49b](https://github.com/remix-run/react-router/commit/af5d49b))
477
478- Fix a bug with `unstable_defaultShouldRevalidate={false}` where parent routes that did not export a `shouldRevalidate` function could be incorrectly included in the single fetch call for new child route data ([#15012](https://github.com/remix-run/react-router/pull/15012))
479
480- Improve server-side route matching performance by pre-computing flattened/cached route branches ([#14967](https://github.com/remix-run/react-router/pull/14967)) ([af5d49b](https://github.com/remix-run/react-router/commit/af5d49b))
481 - Performance benchmarks showed roughly a 10-15% improvement in server-side request handling performance
482
483- Mark `mask` as an optional field in `Location` for easier mocking in unit tests ([#14999](https://github.com/remix-run/react-router/pull/14999))
484
485- Cache flattened/ranked route branches to optimize server-side route matching ([#14967](https://github.com/remix-run/react-router/pull/14967))
486
487- Improve route matching performance in Framework/Data Mode ([#14971](https://github.com/remix-run/react-router/pull/14971)) ([af5d49b](https://github.com/remix-run/react-router/commit/af5d49b))
488 - Avoiding unnecessary calls to `matchRoutes` in data router scenarios
489 - This includes adding back the optimization that was removed in `7.6.0` ([#13562](https://github.com/remix-run/react-router/pull/13562))
490 - The issues that prompted the revert have been addressed by using the available router `matches` but always updating `match.route` to the latest route in the `manifest`
491 - Leverage pre-computed pre-computing flattened/cached route branches during client side route matching
492 - Performance benchmarks showed roughly a 15-30% improvement in server-side request handling performance
493
494## v7.14.2
495
496### Patch Changes
497
498- Remove the un-documented custom error serialization logic from the internal turbo-stream implementation. React Router only automatically handles serialization of `Error` and it's standard subtypes (`SyntaxError`, `TypeError`, etc.). ([[aabf4a1](https://github.com/remix-run/react-router/commit/aabf4a1))
499
500- Properly handle parent middleware redirects during `fetcher.load` ([[aabf4a1](https://github.com/remix-run/react-router/commit/aabf4a1))
501
502- Remove redundant `Omit<RouterProviderProps, "flushSync">` from `react-router/dom` `RouterProvider` ([[aabf4a1](https://github.com/remix-run/react-router/commit/aabf4a1))
503
504- Improved types for `generatePath`'s `param` arg ([[aabf4a1](https://github.com/remix-run/react-router/commit/aabf4a1))
505
506 Type errors when required params are omitted:
507
508 ```ts
509 // Before
510 // Passes type checks, but throws at runtime 💥
511 generatePath(":required", { required: null });
512
513 // After
514 generatePath(":required", { required: null });
515 // ^^^^^^^^ Type 'null' is not assignable to type 'string'.ts(2322)
516 ```
517
518 Allow omission of optional params:
519
520 ```ts
521 // Before
522 generatePath(":optional?", {});
523 // ^^ Property 'optional' is missing in type '{}' but required in type '{ optional: string | null | undefined; }'.ts(2741)
524
525 // After
526 generatePath(":optional?", {});
527 ```
528
529 Allows extra keys:
530
531 ```ts
532 // Before
533 generatePath(":a", { a: "1", b: "2" });
534 // ^ Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'.ts(2353)
535
536 // After
537 generatePath(":a", { a: "1", b: "2" });
538 ```
539
540## v7.14.1
541
542### Patch Changes
543
544- Fix a potential race condition that can occur when rendering a `HydrateFallback` and initial loaders land before the `router.subscribe` call happens in the `RouterProvider` layout effect
545- Normalize double-slashes in redirect paths
546
547## 7.14.0
548
549### Patch Changes
550
551- UNSTABLE RSC FRAMEWORK MODE BREAKING CHANGE - Existing route module exports remain unchanged from stable v7 non-RSC mode, but new exports are added for RSC mode. If you want to use RSC features, you will need to update your route modules to export the new annotations. ([#14901](https://github.com/remix-run/react-router/pull/14901))
552
553 If you are using RSC framework mode currently, you will need to update your route modules to the new conventions. The following route module components have their own mutually exclusive server component counterparts:
554
555 | Server Component Export | Client Component |
556 | ----------------------- | ----------------- |
557 | `ServerComponent` | `default` |
558 | `ServerErrorBoundary` | `ErrorBoundary` |
559 | `ServerLayout` | `Layout` |
560 | `ServerHydrateFallback` | `HydrateFallback` |
561
562 If you were previously exporting a `ServerComponent`, your `ErrorBoundary`, `Layout`, and `HydrateFallback` were also server components. If you want to keep those as server components, you can rename them and prefix them with `Server`. If you were previously importing the implementations of those components from a client module, you can simply inline them.
563
564 Example:
565
566 Before
567
568 ```tsx
569 import { ErrorBoundary as ClientErrorBoundary } from "./client";
570
571 export function ServerComponent() {
572 // ...
573 }
574
575 export function ErrorBoundary() {
576 return <ClientErrorBoundary />;
577 }
578
579 export function Layout() {
580 // ...
581 }
582
583 export function HydrateFallback() {
584 // ...
585 }
586 ```
587
588 After
589
590 ```tsx
591 export function ServerComponent() {
592 // ...
593 }
594
595 export function ErrorBoundary() {
596 // previous implementation of ClientErrorBoundary, this is now a client component
597 }
598
599 export function ServerLayout() {
600 // rename previous Layout export to ServerLayout to make it a server component
601 }
602
603 export function ServerHydrateFallback() {
604 // rename previous HydrateFallback export to ServerHydrateFallback to make it a server component
605 }
606 ```
607
608- rsc Link prefetch ([#14902](https://github.com/remix-run/react-router/pull/14902))
609
610- Remove recursion from turbo-stream v2 allowing for encoding / decoding of massive payloads. ([#14838](https://github.com/remix-run/react-router/pull/14838))
611
612- encodeViaTurboStream leaked memory via unremoved AbortSignal listener ([#14900](https://github.com/remix-run/react-router/pull/14900))
613
614## 7.13.2
615
616### Patch Changes
617
618- Fix clientLoader.hydrate when an ancestor route is also hydrating a clientLoader ([#14835](https://github.com/remix-run/react-router/pull/14835))
619
620- Fix type error when passing Framework Mode route components using `Route.ComponentProps` to `createRoutesStub` ([#14892](https://github.com/remix-run/react-router/pull/14892))
621
622- Fix percent encoding in relative path navigation ([#14786](https://github.com/remix-run/react-router/pull/14786))
623
624- Add `future.unstable_passThroughRequests` flag ([#14775](https://github.com/remix-run/react-router/pull/14775))
625
626 By default, React Router normalizes the `request.url` passed to your `loader`, `action`, and `middleware` functions by removing React Router's internal implementation details (`.data` suffixes, `index` + `_routes` query params).
627
628 Enabling this flag removes that normalization and passes the raw HTTP `request` instance to your handlers. This provides a few benefits:
629 - Reduces server-side overhead by eliminating multiple `new Request()` calls on the critical path
630 - Allows you to distinguish document from data requests in your handlers base don the presence of a `.data` suffix (useful for observability purposes)
631
632 If you were previously relying on the normalization of `request.url`, you can switch to use the new sibling `unstable_url` parameter which contains a `URL` instance representing the normalized location:
633
634 ```tsx
635 // ❌ Before: you could assume there was no `.data` suffix in `request.url`
636 export async function loader({ request }: Route.LoaderArgs) {
637 let url = new URL(request.url);
638 if (url.pathname === "/path") {
639 // This check will fail with the flag enabled because the `.data` suffix will
640 // exist on data requests
641 }
642 }
643
644 // ✅ After: use `unstable_url` for normalized routing logic and `request.url`
645 // for raw routing logic
646 export async function loader({ request, unstable_url }: Route.LoaderArgs) {
647 if (unstable_url.pathname === "/path") {
648 // This will always have the `.data` suffix stripped
649 }
650
651 // And now you can distinguish between document versus data requests
652 let isDataRequest = new URL(request.url).pathname.endsWith(".data");
653 }
654 ```
655
656- Internal refactor to consolidate framework-agnostic/React-specific route type layers - no public API changes ([#14765](https://github.com/remix-run/react-router/pull/14765))
657
658- Sync protocol validation to rsc flows ([#14882](https://github.com/remix-run/react-router/pull/14882))
659
660- Add a new `unstable_url: URL` parameter to route handler methods (`loader`, `action`, `middleware`, etc.) representing the normalized URL the application is navigating to or fetching, with React Router implementation details removed (`.data`suffix, `index`/`_routes` query params) ([#14775](https://github.com/remix-run/react-router/pull/14775))
661
662 This is being added alongside the new `future.unstable_passthroughRequests` future flag so that users still have a way to access the normalized URL when that flag is enabled and non-normalized `request`'s are being passed to your handlers. When adopting this flag, you will only need to start leveraging this new parameter if you are relying on the normalization of `request.url` in your application code.
663
664 If you don't have the flag enabled, then `unstable_url` will match `request.url`.
665
666## 7.13.1
667
668### Patch Changes
669
670- fix null reference exception in bad codepath leading to invalid route tree comparisons ([#14780](https://github.com/remix-run/react-router/pull/14780))
671
672- fix: clear timeout when turbo-stream encoding completes ([#14810](https://github.com/remix-run/react-router/pull/14810))
673
674- Improve error message when Origin header is invalid ([#14743](https://github.com/remix-run/react-router/pull/14743))
675
676- Fix matchPath optional params matching without a "/" separator. ([#14689](https://github.com/remix-run/react-router/pull/14689))
677 - matchPath("/users/:id?", "/usersblah") now returns null.
678 - matchPath("/test_route/:part?", "/test_route_more") now returns null.
679
680- add RSC unstable_getRequest ([#14758](https://github.com/remix-run/react-router/pull/14758))
681
682- Fix `HydrateFallback` rendering during initial lazy route discovery with matching splat route ([#14740](https://github.com/remix-run/react-router/pull/14740))
683
684- \[UNSTABLE] Add support for `<Link unstable_mask>` in Data Mode which allows users to navigate to a URL in the router but "mask" the URL displayed in the browser. This is useful for contextual routing usages such as displaying an image in a model on top of a gallery, but displaying a browser URL directly to the image that can be shared and loaded without the contextual gallery in the background. ([#14716](https://github.com/remix-run/react-router/pull/14716))
685
686 ```tsx
687 // routes/gallery.tsx
688 export function clientLoader({ request }: Route.LoaderArgs) {
689 let sp = new URL(request.url).searchParams;
690 return {
691 images: getImages(),
692 // When the router location has the image param, load the modal data
693 modalImage: sp.has("image") ? getImage(sp.get("image")!) : null,
694 };
695 }
696
697 export default function Gallery({ loaderData }: Route.ComponentProps) {
698 return (
699 <>
700 <GalleryGrid>
701 {loaderData.images.map((image) => (
702 <Link
703 key={image.id}
704 {/* Navigate the router to /galley?image=N */}}
705 to={`/gallery?image=${image.id}`}
706 {/* But display /images/N in the URL bar */}}
707 unstable_mask={`/images/${image.id}`}
708 >
709 <img src={image.url} alt={image.alt} />
710 </Link>
711 ))}
712 </GalleryGrid>
713
714 {/* When the modal data exists, display the modal */}
715 {data.modalImage ? (
716 <dialog open>
717 <img src={data.modalImage.url} alt={data.modalImage.alt} />
718 </dialog>
719 ) : null}
720 </>
721 );
722 }
723 ```
724
725 Notes:
726 - The masked location, if present, will be available on `useLocation().unstable_mask` so you can detect whether you are currently masked or not.
727 - Masked URLs only work for SPA use cases, and will be removed from `history.state` during SSR.
728 - This provides a first-class API to mask URLs in Data Mode to achieve the same behavior you could do in Declarative Mode via [manual `backgroundLocation` management](https://github.com/remix-run/react-router/tree/main/examples/modal).
729
730- RSC: Update failed origin checks to return a 400 status and appropriate UI instead of a generic 500 ([#14755](https://github.com/remix-run/react-router/pull/14755))
731
732- Preserve query parameters and hash on manifest version mismatch reload ([#14813](https://github.com/remix-run/react-router/pull/14813))
733
734## 7.13.0
735
736### Minor Changes
737
738- Add `crossOrigin` prop to `Links` component ([#14687](https://github.com/remix-run/react-router/pull/14687))
739
740### Patch Changes
741
742- Fix double slash normalization for useNavigate colon urls ([#14718](https://github.com/remix-run/react-router/pull/14718))
743- Update failed origin checks to return a 400 status instead of a 500 ([#14737](https://github.com/remix-run/react-router/pull/14737))
744- Bugfix #14666: Inline criticalCss is missing nonce ([#14691](https://github.com/remix-run/react-router/pull/14691))
745- Loosen `allowedActionOrigins` glob check so `**` matches all domains ([#14722](https://github.com/remix-run/react-router/pull/14722))
746
747## 7.12.0
748
749### Minor Changes
750
751- Add additional layer of CSRF protection by rejecting submissions to UI routes from external origins. If you need to permit access to specific external origins, you can specify them in the `react-router.config.ts` config `allowedActionOrigins` field. ([#14708](https://github.com/remix-run/react-router/pull/14708))
752
753### Patch Changes
754
755- Fix `generatePath` when used with suffixed params (i.e., "/books/:id.json") ([#14269](https://github.com/remix-run/react-router/pull/14269))
756
757- Export `UNSAFE_createMemoryHistory` and `UNSAFE_createHashHistory` alongside `UNSAFE_createBrowserHistory` for consistency. These are not intended to be used for new apps but intended to help apps usiong `unstable_HistoryRouter` migrate from v6->v7 so they can adopt the newer APIs. ([#14663](https://github.com/remix-run/react-router/pull/14663))
758
759- Escape HTML in scroll restoration keys ([#14705](https://github.com/remix-run/react-router/pull/14705))
760
761- Validate redirect locations ([#14706](https://github.com/remix-run/react-router/pull/14706))
762
763- \[UNSTABLE] Pass `<Scripts nonce>` value through to the underlying `importmap` `script` tag when using `future.unstable_subResourceIntegrity` ([#14675](https://github.com/remix-run/react-router/pull/14675))
764
765- \[UNSTABLE] Add a new `future.unstable_trailingSlashAwareDataRequests` flag to provide consistent behavior of `request.pathname` inside `middleware`, `loader`, and `action` functions on document and data requests when a trailing slash is present in the browser URL. ([#14644](https://github.com/remix-run/react-router/pull/14644))
766
767 Currently, your HTTP and `request` pathnames would be as follows for `/a/b/c` and `/a/b/c/`
768
769 | URL `/a/b/c` | **HTTP pathname** | **`request` pathname\`** |
770 | ------------ | ----------------- | ------------------------ |
771 | **Document** | `/a/b/c` | `/a/b/c` ✅ |
772 | **Data** | `/a/b/c.data` | `/a/b/c` ✅ |
773
774 | URL `/a/b/c/` | **HTTP pathname** | **`request` pathname\`** |
775 | ------------- | ----------------- | ------------------------ |
776 | **Document** | `/a/b/c/` | `/a/b/c/` ✅ |
777 | **Data** | `/a/b/c.data` | `/a/b/c` ⚠️ |
778
779 With this flag enabled, these pathnames will be made consistent though a new `_.data` format for client-side `.data` requests:
780
781 | URL `/a/b/c` | **HTTP pathname** | **`request` pathname\`** |
782 | ------------ | ----------------- | ------------------------ |
783 | **Document** | `/a/b/c` | `/a/b/c` ✅ |
784 | **Data** | `/a/b/c.data` | `/a/b/c` ✅ |
785
786 | URL `/a/b/c/` | **HTTP pathname** | **`request` pathname\`** |
787 | ------------- | ------------------ | ------------------------ |
788 | **Document** | `/a/b/c/` | `/a/b/c/` ✅ |
789 | **Data** | `/a/b/c/_.data` ⬅️ | `/a/b/c/` ✅ |
790
791 This a bug fix but we are putting it behind an opt-in flag because it has the potential to be a "breaking bug fix" if you are relying on the URL format for any other application or caching logic.
792
793 Enabling this flag also changes the format of client side `.data` requests from `/_root.data` to `/_.data` when navigating to `/` to align with the new format. This does not impact the `request` pathname which is still `/` in all cases.
794
795- Preserve `clientLoader.hydrate=true` when using `<HydratedRouter unstable_instrumentations>` ([#14674](https://github.com/remix-run/react-router/pull/14674))
796
797## 7.11.0
798
799### Minor Changes
800
801- Stabilize `<HydratedRouter onError>`/`<RouterProvider onError>` ([#14546](https://github.com/remix-run/react-router/pull/14546))
802
803### Patch Changes
804
805- add support for throwing redirect Response's at RSC render time ([#14596](https://github.com/remix-run/react-router/pull/14596))
806
807- Support for throwing `data()` and Response from server component render phase. Response body is not serialized as async work is not allowed as error encoding phase. If you wish to transmit data to the boundary, throw `data()` instead. ([#14632](https://github.com/remix-run/react-router/pull/14632))
808
809- Fix `unstable_useTransitions` prop on `<Router>` component to permit omission for backewards compatibility ([#14646](https://github.com/remix-run/react-router/pull/14646))
810
811- `routeRSCServerRequest` replace `fetchServer` with `serverResponse` ([#14597](https://github.com/remix-run/react-router/pull/14597))
812
813- \[UNSTABLE] Add a new `unstable_defaultShouldRevalidate` flag to various APIs to allow opt-ing out of standard revalidation behaviors. ([#14542](https://github.com/remix-run/react-router/pull/14542))
814
815 If active routes include a `shouldRevalidate` function, then your value will be passed as `defaultShouldRevalidate` in those function so that the route always has the final revalidation determination.
816 - `<Form method="post" unstable_defaultShouldRevalidate={false}>`
817 - `submit(data, { method: "post", unstable_defaultShouldRevalidate: false })`
818 - `<fetcher.Form method="post" unstable_defaultShouldRevalidate={false}>`
819 - `fetcher.submit(data, { method: "post", unstable_defaultShouldRevalidate: false })`
820
821 This is also available on non-submission APIs that may trigger revalidations due to changing search params:
822 - `<Link to="/" unstable_defaultShouldRevalidate={false}>`
823 - `navigate("/?foo=bar", { unstable_defaultShouldRevalidate: false })`
824 - `setSearchParams(params, { unstable_defaultShouldRevalidate: false })`
825
826- Allow redirects to be returned from client side middleware ([#14598](https://github.com/remix-run/react-router/pull/14598))
827
828- Handle `dataStrategy` implementations that return insufficient result sets by adding errors for routes without any available result ([#14627](https://github.com/remix-run/react-router/pull/14627))
829
830## 7.10.1
831
832### Patch Changes
833
834- Update the `useOptimistic` stub we provide for React 18 users to use a stable setter function to avoid potential `useEffect` loops - specifically when using `<Link viewTransition>` ([#14628](https://github.com/remix-run/react-router/pull/14628))
835
836## 7.10.0
837
838### Minor Changes
839
840- Stabilize `fetcher.reset()` ([#14545](https://github.com/remix-run/react-router/pull/14545))
841 - ⚠️ This is a breaking change if you have begun using `fetcher.unstable_reset()`
842
843- Stabilize the `dataStrategy` `match.shouldRevalidateArgs`/`match.shouldCallHandler()` APIs. ([#14592](https://github.com/remix-run/react-router/pull/14592))
844 - The `match.shouldLoad` API is now marked deprecated in favor of these more powerful alternatives
845
846 - If you're using this API in a custom `dataStrategy` today, you can swap to the new API at your convenience:
847
848 ```tsx
849 // Before
850 const matchesToLoad = matches.filter((m) => m.shouldLoad);
851
852 // After
853 const matchesToLoad = matches.filter((m) => m.shouldCallHandler());
854 ```
855
856 - `match.shouldRevalidateArgs` is the argument that will be passed to the route `shouldRevaliate` function
857
858 - Combined with the parameter accepted by `match.shouldCallHandler`, you can define a custom revalidation behavior for your `dataStrategy`:
859
860 ```tsx
861 const matchesToLoad = matches.filter((m) => {
862 const defaultShouldRevalidate = customRevalidationBehavior(
863 match.shouldRevalidateArgs,
864 );
865 return m.shouldCallHandler(defaultShouldRevalidate);
866 // The argument here will override the internal `defaultShouldRevalidate` value
867 });
868 ```
869
870### Patch Changes
871
872- Fix a Framework Mode bug where the `defaultShouldRevalidate` parameter to `shouldRevalidate` would not be correct after `action` returned a 4xx/5xx response (`true` when it should have been `false`) ([#14592](https://github.com/remix-run/react-router/pull/14592))
873 - If your `shouldRevalidate` function relied on that parameter, you may have seen unintended revalidations
874
875- Fix `fetcher.submit` failing with plain objects containing a `tagName` property ([#14534](https://github.com/remix-run/react-router/pull/14534))
876
877- \[UNSTABLE] Add `unstable_pattern` to the parameters for client side `unstable_onError`, refactor how it's called by `RouterProvider` to avoid potential strict mode issues ([#14573](https://github.com/remix-run/react-router/pull/14573))
878
879- Add new `unstable_useTransitions` flag to routers to give users control over the usage of [`React.startTransition`](https://react.dev/reference/react/startTransition) and [`React.useOptimistic`](https://react.dev/reference/react/useOptimistic). ([#14524](https://github.com/remix-run/react-router/pull/14524))
880 - Framework Mode + Data Mode:
881 - `<HydratedRouter unstable_transition>`/`<RouterProvider unstable_transition>`
882 - When left unset (current default behavior)
883 - Router state updates are wrapped in `React.startTransition`
884 - ⚠️ This can lead to buggy behaviors if you are wrapping your own navigations/fetchers in `React.startTransition`
885 - You should set the flag to `true` if you run into this scenario to get the enhanced `useOptimistic` behavior (requires React 19)
886 - When set to `true`
887 - Router state updates remain wrapped in `React.startTransition` (as they are without the flag)
888 - `Link`/`Form` navigations will be wrapped in `React.startTransition`
889 - A subset of router state info will be surfaced to the UI _during_ navigations via `React.useOptimistic` (i.e., `useNavigation()`, `useFetchers()`, etc.)
890 - ⚠️ This is a React 19 API so you must also be React 19 to opt into this flag for Framework/Data Mode
891 - When set to `false`
892 - The router will not leverage `React.startTransition` or `React.useOptimistic` on any navigations or state changes
893 - Declarative Mode
894 - `<BrowserRouter unstable_useTransitions>`
895 - When left unset
896 - Router state updates are wrapped in `React.startTransition`
897 - When set to `true`
898 - Router state updates remain wrapped in `React.startTransition` (as they are without the flag)
899 - `Link`/`Form` navigations will be wrapped in `React.startTransition`
900 - When set to `false`
901 - the router will not leverage `React.startTransition` on any navigations or state changes
902
903- Fix the promise returned from `useNavigate` in Framework/Data Mode so that it properly tracks the duration of `popstate` navigations (i.e., `navigate(-1)`) ([#14524](https://github.com/remix-run/react-router/pull/14524))
904
905- Fix internal type error in useRoute types that surfaces when skipLibCheck is disabled ([#14577](https://github.com/remix-run/react-router/pull/14577))
906
907- Preserve `statusText` on the `ErrorResponse` instance when throwing `data()` from a route handler ([#14555](https://github.com/remix-run/react-router/pull/14555))
908
909- Optimize href() to avoid backtracking regex on splat ([#14329](https://github.com/remix-run/react-router/pull/14329))
910
911## 7.9.6
912
913### Patch Changes
914
915- \[UNSTABLE] Add `location`/`params` as arguments to client-side `unstable_onError` to permit enhanced error reporting. ([#14509](https://github.com/remix-run/react-router/pull/14509))
916
917 ⚠️ This is a breaking change if you've already adopted `unstable_onError`. The second `errorInfo` parameter is now an object with `location` and `params`:
918
919 ```tsx
920 // Before
921 function errorHandler(error: unknown, errorInfo?: React.errorInfo) {
922 /*...*/
923 }
924
925 // After
926 function errorHandler(
927 error: unknown,
928 info: {
929 location: Location;
930 params: Params;
931 errorInfo?: React.ErrorInfo;
932 },
933 ) {
934 /*...*/
935 }
936 ```
937
938- Properly handle ancestor thrown middleware errors before `next()` on fetcher submissions ([#14517](https://github.com/remix-run/react-router/pull/14517))
939
940- Fix issue with splat routes interfering with multiple calls to patchRoutesOnNavigation ([#14487](https://github.com/remix-run/react-router/pull/14487))
941
942- Normalize double-slashes in `resolvePath` ([#14529](https://github.com/remix-run/react-router/pull/14529))
943
944## 7.9.5
945
946### Patch Changes
947
948- Move RSCHydratedRouter and utils to `/dom` export. ([#14457](https://github.com/remix-run/react-router/pull/14457))
949
950- useRoute: return type-safe `handle` ([#14462](https://github.com/remix-run/react-router/pull/14462))
951
952 For example:
953
954 ```ts
955 // app/routes/admin.tsx
956 const handle = { hello: "world" };
957 ```
958
959 ```ts
960 // app/routes/some-other-route.tsx
961 export default function Component() {
962 const admin = useRoute("routes/admin");
963 if (!admin) throw new Error("Not nested within 'routes/admin'");
964 console.log(admin.handle);
965 // ^? { hello: string }
966 }
967 ```
968
969- Ensure action handlers run for routes with middleware even if no loader is present ([#14443](https://github.com/remix-run/react-router/pull/14443))
970
971- Add `unstable_instrumentations` API to allow users to add observablity to their apps by instrumenting route loaders, actions, middlewares, lazy, as well as server-side request handlers and client side navigations/fetches ([#14412](https://github.com/remix-run/react-router/pull/14412))
972 - Framework Mode:
973 - `entry.server.tsx`: `export const unstable_instrumentations = [...]`
974 - `entry.client.tsx`: `<HydratedRouter unstable_instrumentations={[...]} />`
975 - Data Mode
976 - `createBrowserRouter(routes, { unstable_instrumentations: [...] })`
977
978 This also adds a new `unstable_pattern` parameter to loaders/actions/middleware which contains the un-interpolated route pattern (i.e., `/blog/:slug`) which is useful for aggregating performance metrics by route
979
980## 7.9.4
981
982### Patch Changes
983
984- handle external redirects in from server actions ([#14400](https://github.com/remix-run/react-router/pull/14400))
985- New (unstable) `useRoute` hook for accessing data from specific routes ([#14407](https://github.com/remix-run/react-router/pull/14407))
986
987 For example, let's say you have an `admin` route somewhere in your app and you want any child routes of `admin` to all have access to the `loaderData` and `actionData` from `admin.`
988
989 ```tsx
990 // app/routes/admin.tsx
991 import { Outlet } from "react-router";
992
993 export const loader = () => ({ message: "Hello, loader!" });
994
995 export const action = () => ({ count: 1 });
996
997 export default function Component() {
998 return (
999 <div>
1000 {/* ... */}
1001 <Outlet />
1002 {/* ... */}
1003 </div>
1004 );
1005 }
1006 ```
1007
1008 You might even want to create a reusable widget that all of the routes nested under `admin` could use:
1009
1010 ```tsx
1011 import { unstable_useRoute as useRoute } from "react-router";
1012
1013 export function AdminWidget() {
1014 // How to get `message` and `count` from `admin` route?
1015 }
1016 ```
1017
1018 In framework mode, `useRoute` knows all your app's routes and gives you TS errors when invalid route IDs are passed in:
1019
1020 ```tsx
1021 export function AdminWidget() {
1022 const admin = useRoute("routes/dmin");
1023 // ^^^^^^^^^^^
1024 }
1025 ```
1026
1027 `useRoute` returns `undefined` if the route is not part of the current page:
1028
1029 ```tsx
1030 export function AdminWidget() {
1031 const admin = useRoute("routes/admin");
1032 if (!admin) {
1033 throw new Error(`AdminWidget used outside of "routes/admin"`);
1034 }
1035 }
1036 ```
1037
1038 Note: the `root` route is the exception since it is guaranteed to be part of the current page.
1039 As a result, `useRoute` never returns `undefined` for `root`.
1040
1041 `loaderData` and `actionData` are marked as optional since they could be accessed before the `action` is triggered or after the `loader` threw an error:
1042
1043 ```tsx
1044 export function AdminWidget() {
1045 const admin = useRoute("routes/admin");
1046 if (!admin) {
1047 throw new Error(`AdminWidget used outside of "routes/admin"`);
1048 }
1049 const { loaderData, actionData } = admin;
1050 console.log(loaderData);
1051 // ^? { message: string } | undefined
1052 console.log(actionData);
1053 // ^? { count: number } | undefined
1054 }
1055 ```
1056
1057 If instead of a specific route, you wanted access to the _current_ route's `loaderData` and `actionData`, you can call `useRoute` without arguments:
1058
1059 ```tsx
1060 export function AdminWidget() {
1061 const currentRoute = useRoute();
1062 currentRoute.loaderData;
1063 currentRoute.actionData;
1064 }
1065 ```
1066
1067 This usage is equivalent to calling `useLoaderData` and `useActionData`, but consolidates all route data access into one hook: `useRoute`.
1068
1069 Note: when calling `useRoute()` (without a route ID), TS has no way to know which route is the current route.
1070 As a result, `loaderData` and `actionData` are typed as `unknown`.
1071 If you want more type-safety, you can either narrow the type yourself with something like `zod` or you can refactor your app to pass down typed props to your `AdminWidget`:
1072
1073 ```tsx
1074 export function AdminWidget({
1075 message,
1076 count,
1077 }: {
1078 message: string;
1079 count: number;
1080 }) {
1081 /* ... */
1082 }
1083 ```
1084
1085## 7.9.3
1086
1087### Patch Changes
1088
1089- Do not try to use `turbo-stream` to decode CDN errors that never reached the server ([#14385](https://github.com/remix-run/react-router/pull/14385))
1090 - We used to do this but lost this check with the adoption of single fetch
1091
1092- Fix Data Mode regression causing a 404 during initial load in when `middleware` exists without any `loader` functions ([#14393](https://github.com/remix-run/react-router/pull/14393))
1093
1094## 7.9.2
1095
1096### Patch Changes
1097
1098- - Update client-side router to run client `middleware` on initial load even if no loaders exist ([#14348](https://github.com/remix-run/react-router/pull/14348))
1099 - Update `createRoutesStub` to run route middleware
1100 - You will need to set the `<RoutesStub future={{ v8_middleware: true }} />` flag to enable the proper `context` type
1101
1102- Update Lazy Route Discovery manifest requests to use a singular comma-separated `paths` query param instead of repeated `p` query params ([#14321](https://github.com/remix-run/react-router/pull/14321))
1103 - This is because Cloudflare has a hard limit of 100 URL search param key/value pairs when used as a key for caching purposes
1104 - If more that 100 paths were included, the cache key would be incomplete and could produce false-positive cache hits
1105
1106- \[UNSTABLE] Add `fetcher.unstable_reset()` API ([#14206](https://github.com/remix-run/react-router/pull/14206))
1107
1108- Made useOutlet element reference have stable identity in-between route chages ([#13382](https://github.com/remix-run/react-router/pull/13382))
1109
1110- feat: enable full transition support for the rsc router ([#14362](https://github.com/remix-run/react-router/pull/14362))
1111
1112- In RSC Data Mode, handle SSR'd client errors and re-try in the browser ([#14342](https://github.com/remix-run/react-router/pull/14342))
1113
1114- Support `middleware` prop on `<Route>` for usage with a data router via `createRoutesFromElements` ([#14357](https://github.com/remix-run/react-router/pull/14357))
1115
1116- Handle encoded question mark and hash characters in ancestor splat routes ([#14249](https://github.com/remix-run/react-router/pull/14249))
1117
1118- Fail gracefully on manifest version mismatch logic if `sessionStorage` access is blocked ([#14335](https://github.com/remix-run/react-router/pull/14335))
1119
1120## 7.9.1
1121
1122### Patch Changes
1123
1124- Fix internal `Future` interface naming from `middleware` -> `v8_middleware` ([#14327](https://github.com/remix-run/react-router/pull/14327))
1125
1126## 7.9.0
1127
1128### Minor Changes
1129
1130- Stabilize middleware and context APIs. ([#14215](https://github.com/remix-run/react-router/pull/14215))
1131
1132 We have removed the `unstable_` prefix from the following APIs and they are now considered stable and ready for production use:
1133 - [`RouterContextProvider`](https://reactrouter.com/api/utils/RouterContextProvider)
1134 - [`createContext`](https://reactrouter.com/api/utils/createContext)
1135 - `createBrowserRouter` [`getContext`](https://reactrouter.com/api/data-routers/createBrowserRouter#optsgetcontext) option
1136 - `<HydratedRouter>` [`getContext`](https://reactrouter.com/api/framework-routers/HydratedRouter#getcontext) prop
1137
1138 Please see the [Middleware Docs](https://reactrouter.com/how-to/middleware), the [Middleware RFC](https://github.com/remix-run/remix/discussions/7642), and the [Client-side Context RFC](https://github.com/remix-run/react-router/discussions/9856) for more information.
1139
1140### Patch Changes
1141
1142- Escape HTML in `meta()` JSON-LD content ([#14316](https://github.com/remix-run/react-router/pull/14316))
1143- Add react-server Await component implementation ([#14261](https://github.com/remix-run/react-router/pull/14261))
1144- In RSC Data Mode when using a custom basename, fix hydration errors for routes that only have client loaders ([#14264](https://github.com/remix-run/react-router/pull/14264))
1145- Make `href` function available in a react-server context ([#14262](https://github.com/remix-run/react-router/pull/14262))
1146- decode each time `getPayload()` is called to allow for "in-context" decoding and hoisting of contextual assets ([#14248](https://github.com/remix-run/react-router/pull/14248))
1147- `href()` now correctly processes routes that have an extension after the parameter or are a single optional parameter. ([#13797](https://github.com/remix-run/react-router/pull/13797))
1148
1149## 7.8.2
1150
1151### Patch Changes
1152
1153- \[UNSTABLE] Remove Data Mode `future.unstable_middleware` flag from `createBrowserRouter` ([#14213](https://github.com/remix-run/react-router/pull/14213))
1154 - This is only needed as a Framework Mode flag because of the route modules and the `getLoadContext` type behavior change
1155 - In Data Mode, it's an opt-in feature because it's just a new property on a route object, so there's no behavior changes that necessitate a flag
1156
1157- \[UNSTABLE] Add `<RouterProvider unstable_onError>`/`<HydratedRouter unstable_onError>` prop for client side error reporting ([#14162](https://github.com/remix-run/react-router/pull/14162))
1158
1159- server action revalidation opt out via $SKIP_REVALIDATION field ([#14154](https://github.com/remix-run/react-router/pull/14154))
1160
1161- Properly escape interpolated param values in `generatePath()` ([#13530](https://github.com/remix-run/react-router/pull/13530))
1162
1163- Maintain `ReadonlyMap` and `ReadonlySet` types in server response data. ([#13092](https://github.com/remix-run/react-router/pull/13092))
1164
1165- \[UNSTABLE] Delay serialization of `.data` redirects to 202 responses until after middleware chain ([#14205](https://github.com/remix-run/react-router/pull/14205))
1166
1167- Fix `TypeError` if you throw from `patchRoutesOnNavigation` when no partial matches exist ([#14198](https://github.com/remix-run/react-router/pull/14198))
1168
1169- Fix `basename` usage without a leading slash in data routers ([#11671](https://github.com/remix-run/react-router/pull/11671))
1170
1171- \[UNSTABLE] Update client middleware so it returns the data strategy results allowing for more advanced post-processing middleware ([#14151](https://github.com/remix-run/react-router/pull/14151))
1172
1173## 7.8.1
1174
1175### Patch Changes
1176
1177- Fix usage of optional path segments in nested routes defined using absolute paths ([#14135](https://github.com/remix-run/react-router/pull/14135))
1178- Bubble client pre-next middleware error to the shallowest ancestor that needs to load, not strictly the shallowest ancestor with a loader ([#14150](https://github.com/remix-run/react-router/pull/14150))
1179- Fix optional static segment matching in `matchPath` ([#11813](https://github.com/remix-run/react-router/pull/11813))
1180- Fix prerendering when a `basename` is set with `ssr:false` ([#13791](https://github.com/remix-run/react-router/pull/13791))
1181- Provide `isRouteErrorResponse` utility in `react-server` environments ([#14166](https://github.com/remix-run/react-router/pull/14166))
1182- Propagate non-redirect Responses thrown from middleware to the error boundary on document/data requests ([#14182](https://github.com/remix-run/react-router/pull/14182))
1183- Handle `meta` and `links` Route Exports in RSC Data Mode ([#14136](https://github.com/remix-run/react-router/pull/14136))
1184- Properly convert returned/thrown `data()` values to `Response` instances via `Response.json()` in resource routes and middleware ([#14159](https://github.com/remix-run/react-router/pull/14159), [#14181](https://github.com/remix-run/react-router/pull/14181))
1185
1186## 7.8.0
1187
1188### Minor Changes
1189
1190- Add `nonce` prop to `Links` & `PrefetchPageLinks` ([#14048](https://github.com/remix-run/react-router/pull/14048))
1191- Add `loaderData` arguments/properties alongside existing `data` arguments/properties to provide consistency and clarity between `loaderData` and `actionData` across the board ([#14047](https://github.com/remix-run/react-router/pull/14047))
1192 - Updated types: `Route.MetaArgs`, `Route.MetaMatch`, `MetaArgs`, `MetaMatch`, `Route.ComponentProps.matches`, `UIMatch`
1193 - `@deprecated` warnings have been added to the existing `data` properties to point users to new `loaderData` properties, in preparation for removing the `data` properties in a future major release
1194
1195### Patch Changes
1196
1197- Prevent _"Did not find corresponding fetcher result"_ console error when navigating during a `fetcher.submit` revalidation ([#14114](https://github.com/remix-run/react-router/pull/14114))
1198
1199- Bubble client-side middleware errors prior to `next` to the appropriate ancestor error boundary ([#14138](https://github.com/remix-run/react-router/pull/14138))
1200
1201- Switch Lazy Route Discovery manifest URL generation to usea standalone `URLSearchParams` instance instead of `URL.searchParams` to avoid a major performance bottleneck in Chrome ([#14084](https://github.com/remix-run/react-router/pull/14084))
1202
1203- Adjust internal RSC usage of `React.use` to avoid Webpack compilation errors when using React 18 ([#14113](https://github.com/remix-run/react-router/pull/14113))
1204
1205- Remove dependency on `@types/node` in TypeScript declaration files ([#14059](https://github.com/remix-run/react-router/pull/14059))
1206
1207- Fix types for `UIMatch` to reflect that the `loaderData`/`data` properties may be `undefined` ([#12206](https://github.com/remix-run/react-router/pull/12206))
1208 - When an `ErrorBoundary` is being rendered, not all active matches will have loader data available, since it may have been their `loader` that threw to trigger the boundary
1209 - The `UIMatch.data` type was not correctly handing this and would always reflect the presence of data, leading to the unexpected runtime errors when an `ErrorBoundary` was rendered
1210 - ⚠️ This may cause some type errors to show up in your code for unguarded `match.data` accesses - you should properly guard for `undefined` values in those scenarios.
1211
1212 ```tsx
1213 // app/root.tsx
1214 export function loader() {
1215 someFunctionThatThrows(); // ❌ Throws an Error
1216 return { title: "My Title" };
1217 }
1218
1219 export function Layout({ children }: { children: React.ReactNode }) {
1220 let matches = useMatches();
1221 let rootMatch = matches[0] as UIMatch<Awaited<ReturnType<typeof loader>>>;
1222 // ^ rootMatch.data is incorrectly typed here, so TypeScript does not
1223 // complain if you do the following which throws an error at runtime:
1224 let { title } = rootMatch.data; // 💥
1225
1226 return <html>...</html>;
1227 }
1228 ```
1229
1230- \[UNSTABLE] Ensure resource route errors go through `handleError` w/middleware enabled ([#14078](https://github.com/remix-run/react-router/pull/14078))
1231
1232- \[UNSTABLE] Propagate returned Response from server middleware if next wasn't called ([#14093](https://github.com/remix-run/react-router/pull/14093))
1233
1234- \[UNSTABLE] Allow server middlewares to return `data()` values which will be converted into a `Response` ([#14093](https://github.com/remix-run/react-router/pull/14093))
1235
1236- \[UNSTABLE] Update middleware error handling so that the `next` function never throws and instead handles any middleware errors at the proper `ErrorBoundary` and returns the `Response` up through the ancestor `next` function ([#14118](https://github.com/remix-run/react-router/pull/14118))
1237
1238- \[UNSTABLE] When middleware is enabled, make the `context` parameter read-only (via `Readonly<unstable_RouterContextProvider>`) so that TypeScript will not allow you to write arbitrary fields to it in loaders, actions, or middleware. ([#14097](https://github.com/remix-run/react-router/pull/14097))
1239
1240- \[UNSTABLE] Rename and alter the signature/functionality of the `unstable_respond` API in `staticHandler.query`/`staticHandler.queryRoute` ([#14103](https://github.com/remix-run/react-router/pull/14103))
1241 - The API has been renamed to `unstable_generateMiddlewareResponse` for clarity
1242 - The main functional change is that instead of running the loaders/actions before calling `unstable_respond` and handing you the result, we now pass a `query`/`queryRoute` function as a parameter and you execute the loaders/actions inside your callback, giving you full access to pre-processing and error handling
1243 - The `query` version of the API now has a signature of `(query: (r: Request) => Promise<StaticHandlerContext | Response>) => Promise<Response>`
1244 - The `queryRoute` version of the API now has a signature of `(queryRoute: (r: Request) => Promise<Response>) => Promise<Response>`
1245 - This allows for more advanced usages such as running logic before/after calling `query` and direct error handling of errors thrown from query
1246 - ⚠️ This is a breaking change if you've adopted the `staticHandler` `unstable_respond` API
1247
1248 ```tsx
1249 let response = await staticHandler.query(request, {
1250 requestContext: new unstable_RouterContextProvider(),
1251 async unstable_generateMiddlewareResponse(query) {
1252 try {
1253 // At this point we've run middleware top-down so we need to call the
1254 // handlers and generate the Response to bubble back up the middleware
1255 let result = await query(request);
1256 if (isResponse(result)) {
1257 return result; // Redirects, etc.
1258 }
1259 return await generateHtmlResponse(result);
1260 } catch (error: unknown) {
1261 return generateErrorResponse(error);
1262 }
1263 },
1264 });
1265 ```
1266
1267- \[UNSTABLE] Convert internal middleware implementations to use the new `unstable_generateMiddlewareResponse` API ([#14103](https://github.com/remix-run/react-router/pull/14103))
1268
1269- \[UNSTABLE] Change `getLoadContext` signature (`type GetLoadContextFunction`) when `future.unstable_middleware` is enabled so that it returns an `unstable_RouterContextProvider` instance instead of a `Map` used to contruct the instance internally ([#14097](https://github.com/remix-run/react-router/pull/14097))
1270 - This also removes the `type unstable_InitialContext` export
1271 - ⚠️ This is a breaking change if you have adopted middleware and are using a custom server with a `getLoadContext` function
1272
1273- \[UNSTABLE] Run client middleware on client navigations even if no loaders exist ([#14106](https://github.com/remix-run/react-router/pull/14106))
1274
1275- \[UNSTABLE] Change the `unstable_getContext` signature on `RouterProvider`/`HydratedRouter`/`unstable_RSCHydratedRouter` so that it returns an `unstable_RouterContextProvider` instance instead of a `Map` used to contruct the instance internally ([#14097](https://github.com/remix-run/react-router/pull/14097))
1276 - ⚠️ This is a breaking change if you have adopted the `unstable_getContext` prop
1277
1278- \[UNSTABLE] proxy server action side-effect redirects from actions for document and callServer requests ([#14131](https://github.com/remix-run/react-router/pull/14131))
1279
1280- \[UNSTABLE] Fix RSC Data Mode issue where routes that return `false` from `shouldRevalidate` would be replaced by an `<Outlet />` ([#14071](https://github.com/remix-run/react-router/pull/14071))
1281
1282## 7.7.1
1283
1284### Patch Changes
1285
1286- In RSC Data Mode, fix bug where routes with errors weren't forced to revalidate when `shouldRevalidate` returned false ([#14026](https://github.com/remix-run/react-router/pull/14026))
1287- In RSC Data Mode, fix `Matched leaf route at location "/..." does not have an element or Component` warnings when error boundaries are rendered. ([#14021](https://github.com/remix-run/react-router/pull/14021))
1288
1289## 7.7.0
1290
1291### Minor Changes
1292
1293- Add unstable RSC support ([#13700](https://github.com/remix-run/react-router/pull/13700))
1294
1295 For more information, see the [RSC documentation](https://reactrouter.com/start/rsc/installation).
1296
1297### Patch Changes
1298
1299- Handle `InvalidCharacterError` when validating cookie signature ([#13847](https://github.com/remix-run/react-router/pull/13847))
1300
1301- Pass a copy of `searchParams` to the `setSearchParams` callback function to avoid muations of the internal `searchParams` instance. This was an issue when navigations were blocked because the internal instance be out of sync with `useLocation().search`. ([#12784](https://github.com/remix-run/react-router/pull/12784))
1302
1303- Support invalid `Date` in `turbo-stream` v2 fork ([#13684](https://github.com/remix-run/react-router/pull/13684))
1304
1305- In Framework Mode, clear critical CSS in development after initial render ([#13872](https://github.com/remix-run/react-router/pull/13872))
1306
1307- Strip search parameters from `patchRoutesOnNavigation` `path` param for fetcher calls ([#13911](https://github.com/remix-run/react-router/pull/13911))
1308
1309- Skip scroll restoration on useRevalidator() calls because they're not new locations ([#13671](https://github.com/remix-run/react-router/pull/13671))
1310
1311- Support unencoded UTF-8 routes in prerender config with `ssr` set to `false` ([#13699](https://github.com/remix-run/react-router/pull/13699))
1312
1313- Do not throw if the url hash is not a valid URI component ([#13247](https://github.com/remix-run/react-router/pull/13247))
1314
1315- Fix a regression in `createRoutesStub` introduced with the middleware feature. ([#13946](https://github.com/remix-run/react-router/pull/13946))
1316
1317 As part of that work we altered the signature to align with the new middleware APIs without making it backwards compatible with the prior `AppLoadContext` API. This permitted `createRoutesStub` to work if you were opting into middleware and the updated `context` typings, but broke `createRoutesStub` for users not yet opting into middleware.
1318
1319 We've reverted this change and re-implemented it in such a way that both sets of users can leverage it.
1320
1321 ```tsx
1322 // If you have not opted into middleware, the old API should work again
1323 let context: AppLoadContext = {
1324 /*...*/
1325 };
1326 let Stub = createRoutesStub(routes, context);
1327
1328 // If you have opted into middleware, you should now pass an instantiated `unstable_routerContextProvider` instead of a `getContext` factory function.
1329 let context = new unstable_RouterContextProvider();
1330 context.set(SomeContext, someValue);
1331 let Stub = createRoutesStub(routes, context);
1332 ```
1333
1334 ⚠️ This may be a breaking bug for if you have adopted the unstable Middleware feature and are using `createRoutesStub` with the updated API.
1335
1336- Remove `Content-Length` header from Single Fetch responses ([#13902](https://github.com/remix-run/react-router/pull/13902))
1337
1338## 7.6.3
1339
1340### Patch Changes
1341
1342- Do not serialize types for `useRouteLoaderData<typeof clientLoader>` ([#13752](https://github.com/remix-run/react-router/pull/13752))
1343
1344 For types to distinguish a `clientLoader` from a `serverLoader`, you MUST annotate `clientLoader` args:
1345
1346 ```ts
1347 // 👇 annotation required to skip serializing types
1348 export function clientLoader({}: Route.ClientLoaderArgs) {
1349 return { fn: () => "earth" };
1350 }
1351
1352 function SomeComponent() {
1353 const data = useRouteLoaderData<typeof clientLoader>("routes/this-route");
1354 const planet = data?.fn() ?? "world";
1355 return <h1>Hello, {planet}!</h1>;
1356 }
1357 ```
1358
1359## 7.6.2
1360
1361### Patch Changes
1362
1363- Avoid additional `with-props` chunk in Framework Mode by moving route module component prop logic from the Vite plugin to `react-router` ([#13650](https://github.com/remix-run/react-router/pull/13650))
1364- Slight refactor of internal `headers()` function processing for use with RSC ([#13639](https://github.com/remix-run/react-router/pull/13639))
1365
1366## 7.6.1
1367
1368### Patch Changes
1369
1370- Update `Route.MetaArgs` to reflect that `data` can be potentially `undefined` ([#13563](https://github.com/remix-run/react-router/pull/13563))
1371
1372 This is primarily for cases where a route `loader` threw an error to it's own `ErrorBoundary`. but it also arises in the case of a 404 which renders the root `ErrorBoundary`/`meta` but the root loader did not run because not routes matched.
1373
1374- Partially revert optimization added in `7.1.4` to reduce calls to `matchRoutes` because it surfaced other issues ([#13562](https://github.com/remix-run/react-router/pull/13562))
1375
1376- Fix typegen when same route is used at multiple paths ([#13574](https://github.com/remix-run/react-router/pull/13574))
1377
1378 For example, `routes/route.tsx` is used at 4 different paths here:
1379
1380 ```ts
1381 import { type RouteConfig, route } from "@react-router/dev/routes";
1382 export default [
1383 route("base/:base", "routes/base.tsx", [
1384 route("home/:home", "routes/route.tsx", { id: "home" }),
1385 route("changelog/:changelog", "routes/route.tsx", { id: "changelog" }),
1386 route("splat/*", "routes/route.tsx", { id: "splat" }),
1387 ]),
1388 route("other/:other", "routes/route.tsx", { id: "other" }),
1389 ] satisfies RouteConfig;
1390 ```
1391
1392 Previously, typegen would arbitrarily pick one of these paths to be the "winner" and generate types for the route module based on that path.
1393 Now, typegen creates unions as necessary for alternate paths for the same route file.
1394
1395- Better types for `params` ([#13543](https://github.com/remix-run/react-router/pull/13543))
1396
1397 For example:
1398
1399 ```ts
1400 // routes.ts
1401 import { type RouteConfig, route } from "@react-router/dev/routes";
1402
1403 export default [
1404 route("parent/:p", "routes/parent.tsx", [
1405 route("layout/:l", "routes/layout.tsx", [
1406 route("child1/:c1a/:c1b", "routes/child1.tsx"),
1407 route("child2/:c2a/:c2b", "routes/child2.tsx"),
1408 ]),
1409 ]),
1410 ] satisfies RouteConfig;
1411 ```
1412
1413 Previously, `params` for the `routes/layout.tsx` route were calculated as `{ p: string, l: string }`.
1414 This incorrectly ignores params that could come from child routes.
1415 If visiting `/parent/1/layout/2/child1/3/4`, the actual params passed to `routes/layout.tsx` will have a type of `{ p: string, l: string, c1a: string, c1b: string }`.
1416
1417 Now, `params` are aware of child routes and autocompletion will include child params as optionals:
1418
1419 ```ts
1420 params.|
1421 // ^ cursor is here and you ask for autocompletion
1422 // p: string
1423 // l: string
1424 // c1a?: string
1425 // c1b?: string
1426 // c2a?: string
1427 // c2b?: string
1428 ```
1429
1430 You can also narrow the types for `params` as it is implemented as a normalized union of params for each page that includes `routes/layout.tsx`:
1431
1432 ```ts
1433 if (typeof params.c1a === 'string') {
1434 params.|
1435 // ^ cursor is here and you ask for autocompletion
1436 // p: string
1437 // l: string
1438 // c1a: string
1439 // c1b: string
1440 }
1441 ```
1442
1443 ***
1444
1445 UNSTABLE: renamed internal `react-router/route-module` export to `react-router/internal`
1446 UNSTABLE: removed `Info` export from generated `+types/*` files
1447
1448- Avoid initial fetcher execution 404 error when Lazy Route Discovery is interrupted by a navigation ([#13564](https://github.com/remix-run/react-router/pull/13564))
1449
1450- href replaces splats `*` ([#13593](https://github.com/remix-run/react-router/pull/13593))
1451
1452 ```ts
1453 const a = href("/products/*", { "*": "/1/edit" });
1454 // -> /products/1/edit
1455 ```
1456
1457## 7.6.0
1458
1459### Minor Changes
1460
1461- Added a new `react-router.config.ts` `routeDiscovery` option to configure Lazy Route Discovery behavior. ([#13451](https://github.com/remix-run/react-router/pull/13451))
1462 - By default, Lazy Route Discovery is enabled and makes manifest requests to the `/__manifest` path:
1463 - `routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }`
1464 - You can modify the manifest path used:
1465 - `routeDiscovery: { mode: "lazy", manifestPath: "/custom-manifest" }`
1466 - Or you can disable this feature entirely and include all routes in the manifest on initial document load:
1467 - `routeDiscovery: { mode: "initial" }`
1468
1469- Add support for route component props in `createRoutesStub`. This allows you to unit test your route components using the props instead of the hooks: ([#13528](https://github.com/remix-run/react-router/pull/13528))
1470
1471 ```tsx
1472 let RoutesStub = createRoutesStub([
1473 {
1474 path: "/",
1475 Component({ loaderData }) {
1476 let data = loaderData as { message: string };
1477 return <pre data-testid="data">Message: {data.message}</pre>;
1478 },
1479 loader() {
1480 return { message: "hello" };
1481 },
1482 },
1483 ]);
1484
1485 render(<RoutesStub />);
1486
1487 await waitFor(() => screen.findByText("Message: hello"));
1488 ```
1489
1490### Patch Changes
1491
1492- Fix `react-router` module augmentation for `NodeNext` ([#13498](https://github.com/remix-run/react-router/pull/13498))
1493
1494- Don't bundle `react-router` in `react-router/dom` CJS export ([#13497](https://github.com/remix-run/react-router/pull/13497))
1495
1496- Fix bug where a submitting `fetcher` would get stuck in a `loading` state if a revalidating `loader` redirected ([#12873](https://github.com/remix-run/react-router/pull/12873))
1497
1498- Fix hydration error if a server `loader` returned `undefined` ([#13496](https://github.com/remix-run/react-router/pull/13496))
1499
1500- Fix initial load 404 scenarios in data mode ([#13500](https://github.com/remix-run/react-router/pull/13500))
1501
1502- Stabilize `useRevalidator`'s `revalidate` function ([#13542](https://github.com/remix-run/react-router/pull/13542))
1503
1504- Preserve status code if a `clientAction` throws a `data()` result in framework mode ([#13522](https://github.com/remix-run/react-router/pull/13522))
1505
1506- Be defensive against leading double slashes in paths to avoid `Invalid URL` errors from the URL constructor ([#13510](https://github.com/remix-run/react-router/pull/13510))
1507 - Note we do not sanitize/normalize these paths - we only detect them so we can avoid the error that would be thrown by `new URL("//", window.location.origin)`
1508
1509- Remove `Navigator` declaration for `navigator.connection.saveData` to avoid messing with any other types beyond `saveData` in userland ([#13512](https://github.com/remix-run/react-router/pull/13512))
1510
1511- Fix `handleError` `params` values on `.data` requests for routes with a dynamic param as the last URL segment ([#13481](https://github.com/remix-run/react-router/pull/13481))
1512
1513- Don't trigger an `ErrorBoundary` UI before the reload when we detect a manifest verison mismatch in Lazy Route Discovery ([#13480](https://github.com/remix-run/react-router/pull/13480))
1514
1515- Inline `turbo-stream@2.4.1` dependency and fix decoding ordering of Map/Set instances ([#13518](https://github.com/remix-run/react-router/pull/13518))
1516
1517- Only render dev warnings in DEV mode ([#13461](https://github.com/remix-run/react-router/pull/13461))
1518
1519- UNSTABLE: Fix a few bugs with error bubbling in middleware use-cases ([#13538](https://github.com/remix-run/react-router/pull/13538))
1520
1521- Short circuit post-processing on aborted `dataStrategy` requests ([#13521](https://github.com/remix-run/react-router/pull/13521))
1522 - This resolves non-user-facing console errors of the form `Cannot read properties of undefined (reading 'result')`
1523
1524## 7.5.3
1525
1526### Patch Changes
1527
1528- Fix bug where bubbled action errors would result in `loaderData` being cleared at the handling `ErrorBoundary` route ([#13476](https://github.com/remix-run/react-router/pull/13476))
1529- Handle redirects from `clientLoader.hydrate` initial load executions ([#13477](https://github.com/remix-run/react-router/pull/13477))
1530
1531## 7.5.2
1532
1533### Patch Changes
1534
1535- Update Single Fetch to also handle the 204 redirects used in `?_data` requests in Remix v2 ([#13364](https://github.com/remix-run/react-router/pull/13364))
1536 - This allows applications to return a redirect on `.data` requests from outside the scope of React Router (i.e., an `express`/`hono` middleware)
1537 - ⚠️ Please note that doing so relies on implementation details that are subject to change without a SemVer major release
1538 - This is primarily done to ease upgrading to Single Fetch for existing Remix v2 applications, but the recommended way to handle this is redirecting from a route middleware
1539
1540- Adjust approach for Prerendering/SPA Mode via headers ([#13453](https://github.com/remix-run/react-router/pull/13453))
1541
1542## 7.5.1
1543
1544### Patch Changes
1545
1546- Fix single fetch bug where no revalidation request would be made when navigating upwards to a reused parent route ([#13253](https://github.com/remix-run/react-router/pull/13253))
1547
1548- When using the object-based `route.lazy` API, the `HydrateFallback` and `hydrateFallbackElement` properties are now skipped when lazy loading routes after hydration. ([#13376](https://github.com/remix-run/react-router/pull/13376))
1549
1550 If you move the code for these properties into a separate file, you can use this optimization to avoid downloading unused hydration code. For example:
1551
1552 ```ts
1553 createBrowserRouter([
1554 {
1555 path: "/show/:showId",
1556 lazy: {
1557 loader: async () => (await import("./show.loader.js")).loader,
1558 Component: async () => (await import("./show.component.js")).Component,
1559 HydrateFallback: async () =>
1560 (await import("./show.hydrate-fallback.js")).HydrateFallback,
1561 },
1562 },
1563 ]);
1564 ```
1565
1566- Properly revalidate prerendered paths when param values change ([#13380](https://github.com/remix-run/react-router/pull/13380))
1567
1568- UNSTABLE: Add a new `unstable_runClientMiddleware` argument to `dataStrategy` to enable middleware execution in custom `dataStrategy` implementations ([#13395](https://github.com/remix-run/react-router/pull/13395))
1569
1570- UNSTABLE: Add better error messaging when `getLoadContext` is not updated to return a `Map`" ([#13242](https://github.com/remix-run/react-router/pull/13242))
1571
1572- Do not automatically add `null` to `staticHandler.query()` `context.loaderData` if routes do not have loaders ([#13223](https://github.com/remix-run/react-router/pull/13223))
1573 - This was a Remix v2 implementation detail inadvertently left in for React Router v7
1574 - Now that we allow returning `undefined` from loaders, our prior check of `loaderData[routeId] !== undefined` was no longer sufficient and was changed to a `routeId in loaderData` check - these `null` values can cause issues for this new check
1575 - ⚠️ This could be a "breaking bug fix" for you if you are doing manual SSR with `createStaticHandler()`/`<StaticRouterProvider>`, and using `context.loaderData` to control `<RouterProvider>` hydration behavior on the client
1576
1577- Fix prerendering when a loader returns a redirect ([#13365](https://github.com/remix-run/react-router/pull/13365))
1578
1579- UNSTABLE: Update context type for `LoaderFunctionArgs`/`ActionFunctionArgs` when middleware is enabled ([#13381](https://github.com/remix-run/react-router/pull/13381))
1580
1581- Add support for the new `unstable_shouldCallHandler`/`unstable_shouldRevalidateArgs` APIs in `dataStrategy` ([#13253](https://github.com/remix-run/react-router/pull/13253))
1582
1583## 7.5.0
1584
1585### Minor Changes
1586
1587- Add granular object-based API for `route.lazy` to support lazy loading of individual route properties, for example: ([#13294](https://github.com/remix-run/react-router/pull/13294))
1588
1589 ```ts
1590 createBrowserRouter([
1591 {
1592 path: "/show/:showId",
1593 lazy: {
1594 loader: async () => (await import("./show.loader.js")).loader,
1595 action: async () => (await import("./show.action.js")).action,
1596 Component: async () => (await import("./show.component.js")).Component,
1597 },
1598 },
1599 ]);
1600 ```
1601
1602 **Breaking change for `route.unstable_lazyMiddleware` consumers**
1603
1604 The `route.unstable_lazyMiddleware` property is no longer supported. If you want to lazily load middleware, you must use the new object-based `route.lazy` API with `route.lazy.unstable_middleware`, for example:
1605
1606 ```ts
1607 createBrowserRouter([
1608 {
1609 path: "/show/:showId",
1610 lazy: {
1611 unstable_middleware: async () =>
1612 (await import("./show.middleware.js")).middleware,
1613 // etc.
1614 },
1615 },
1616 ]);
1617 ```
1618
1619### Patch Changes
1620
1621- Introduce `unstable_subResourceIntegrity` future flag that enables generation of an importmap with integrity for the scripts that will be loaded by the browser. ([#13163](https://github.com/remix-run/react-router/pull/13163))
1622
1623## 7.4.1
1624
1625### Patch Changes
1626
1627- Fix types on `unstable_MiddlewareFunction` to avoid type errors when a middleware doesn't return a value ([#13311](https://github.com/remix-run/react-router/pull/13311))
1628- Dedupe calls to `route.lazy` functions ([#13260](https://github.com/remix-run/react-router/pull/13260))
1629- Add support for `route.unstable_lazyMiddleware` function to allow lazy loading of middleware logic. ([#13210](https://github.com/remix-run/react-router/pull/13210))
1630
1631 **Breaking change for `unstable_middleware` consumers**
1632
1633 The `route.unstable_middleware` property is no longer supported in the return value from `route.lazy`. If you want to lazily load middleware, you must use `route.unstable_lazyMiddleware`.
1634
1635## 7.4.0
1636
1637### Patch Changes
1638
1639- Fix root loader data on initial load redirects in SPA mode ([#13222](https://github.com/remix-run/react-router/pull/13222))
1640- Load ancestor pathless/index routes in lazy route discovery for upwards non-eager-discoery routing ([#13203](https://github.com/remix-run/react-router/pull/13203))
1641- Fix `shouldRevalidate` behavior for `clientLoader`-only routes in `ssr:true` apps ([#13221](https://github.com/remix-run/react-router/pull/13221))
1642- UNSTABLE: Fix `RequestHandler` `loadContext` parameter type when middleware is enabled ([#13204](https://github.com/remix-run/react-router/pull/13204))
1643- UNSTABLE: Update `Route.unstable_MiddlewareFunction` to have a return value of `Response | undefined` instead of `Response | void` becaue you should not return anything if you aren't returning the `Response` ([#13199](https://github.com/remix-run/react-router/pull/13199))
1644- UNSTABLE(BREAKING): If a middleware throws an error, ensure we only bubble the error itself via `next()` and are no longer leaking the `MiddlewareError` implementation detail ([#13180](https://github.com/remix-run/react-router/pull/13180))
1645
1646## 7.3.0
1647
1648### Minor Changes
1649
1650- Add `fetcherKey` as a parameter to `patchRoutesOnNavigation` ([#13061](https://github.com/remix-run/react-router/pull/13061))
1651 - In framework mode, Lazy Route Discovery will now detect manifest version mismatches after a new deploy
1652 - On navigations to undiscovered routes, this mismatch will trigger a document reload of the destination path
1653 - On `fetcher` calls to undiscovered routes, this mismatch will trigger a document reload of the current path
1654
1655### Patch Changes
1656
1657- Skip resource route flow in dev server in SPA mode ([#13113](https://github.com/remix-run/react-router/pull/13113))
1658
1659- Support middleware on routes (unstable) ([#12941](https://github.com/remix-run/react-router/pull/12941))
1660
1661 Middleware is implemented behind a `future.unstable_middleware` flag. To enable, you must enable the flag and the types in your `react-router-config.ts` file:
1662
1663 ```ts
1664 import type { Config } from "@react-router/dev/config";
1665 import type { Future } from "react-router";
1666
1667 declare module "react-router" {
1668 interface Future {
1669 unstable_middleware: true; // 👈 Enable middleware types
1670 }
1671 }
1672
1673 export default {
1674 future: {
1675 unstable_middleware: true, // 👈 Enable middleware
1676 },
1677 } satisfies Config;
1678 ```
1679
1680 ⚠️ Middleware is unstable and should not be adopted in production. There is at least one known de-optimization in route module loading for `clientMiddleware` that we will be addressing this before a stable release.
1681
1682 ⚠️ Enabling middleware contains a breaking change to the `context` parameter passed to your `loader`/`action` functions - see below for more information.
1683
1684 Once enabled, routes can define an array of middleware functions that will run sequentially before route handlers run. These functions accept the same parameters as `loader`/`action` plus an additional `next` parameter to run the remaining data pipeline. This allows middlewares to perform logic before and after handlers execute.
1685
1686 ```tsx
1687 // Framework mode
1688 export const unstable_middleware = [serverLogger, serverAuth]; // server
1689 export const unstable_clientMiddleware = [clientLogger]; // client
1690
1691 // Library mode
1692 const routes = [
1693 {
1694 path: "/",
1695 // Middlewares are client-side for library mode SPA's
1696 unstable_middleware: [clientLogger, clientAuth],
1697 loader: rootLoader,
1698 Component: Root,
1699 },
1700 ];
1701 ```
1702
1703 Here's a simple example of a client-side logging middleware that can be placed on the root route:
1704
1705 ```tsx
1706 const clientLogger: Route.unstable_ClientMiddlewareFunction = async (
1707 { request },
1708 next,
1709 ) => {
1710 let start = performance.now();
1711
1712 // Run the remaining middlewares and all route loaders
1713 await next();
1714
1715 let duration = performance.now() - start;
1716 console.log(`Navigated to ${request.url} (${duration}ms)`);
1717 };
1718 ```
1719
1720 Note that in the above example, the `next`/`middleware` functions don't return anything. This is by design as on the client there is no "response" to send over the network like there would be for middlewares running on the server. The data is all handled behind the scenes by the stateful `router`.
1721
1722 For a server-side middleware, the `next` function will return the HTTP `Response` that React Router will be sending across the wire, thus giving you a chance to make changes as needed. You may throw a new response to short circuit and respond immediately, or you may return a new or altered response to override the default returned by `next()`.
1723
1724 ```tsx
1725 const serverLogger: Route.unstable_MiddlewareFunction = async (
1726 { request, params, context },
1727 next,
1728 ) => {
1729 let start = performance.now();
1730
1731 // 👇 Grab the response here
1732 let res = await next();
1733
1734 let duration = performance.now() - start;
1735 console.log(`Navigated to ${request.url} (${duration}ms)`);
1736
1737 // 👇 And return it here (optional if you don't modify the response)
1738 return res;
1739 };
1740 ```
1741
1742 You can throw a `redirect` from a middleware to short circuit any remaining processing:
1743
1744 ```tsx
1745 import { sessionContext } from "../context";
1746 const serverAuth: Route.unstable_MiddlewareFunction = (
1747 { request, params, context },
1748 next,
1749 ) => {
1750 let session = context.get(sessionContext);
1751 let user = session.get("user");
1752 if (!user) {
1753 session.set("returnTo", request.url);
1754 throw redirect("/login", 302);
1755 }
1756 };
1757 ```
1758
1759 _Note that in cases like this where you don't need to do any post-processing you don't need to call the `next` function or return a `Response`._
1760
1761 Here's another example of using a server middleware to detect 404s and check the CMS for a redirect:
1762
1763 ```tsx
1764 const redirects: Route.unstable_MiddlewareFunction = async ({
1765 request,
1766 next,
1767 }) => {
1768 // attempt to handle the request
1769 let res = await next();
1770
1771 // if it's a 404, check the CMS for a redirect, do it last
1772 // because it's expensive
1773 if (res.status === 404) {
1774 let cmsRedirect = await checkCMSRedirects(request.url);
1775 if (cmsRedirect) {
1776 throw redirect(cmsRedirect, 302);
1777 }
1778 }
1779
1780 return res;
1781 };
1782 ```
1783
1784 **`context` parameter**
1785
1786 When middleware is enabled, your application will use a different type of `context` parameter in your loaders and actions to provide better type safety. Instead of `AppLoadContext`, `context` will now be an instance of `ContextProvider` that you can use with type-safe contexts (similar to `React.createContext`):
1787
1788 ```ts
1789 import { unstable_createContext } from "react-router";
1790 import { Route } from "./+types/root";
1791 import type { Session } from "./sessions.server";
1792 import { getSession } from "./sessions.server";
1793
1794 let sessionContext = unstable_createContext<Session>();
1795
1796 const sessionMiddleware: Route.unstable_MiddlewareFunction = ({
1797 context,
1798 request,
1799 }) => {
1800 let session = await getSession(request);
1801 context.set(sessionContext, session);
1802 // ^ must be of type Session
1803 };
1804
1805 // ... then in some downstream middleware
1806 const loggerMiddleware: Route.unstable_MiddlewareFunction = ({
1807 context,
1808 request,
1809 }) => {
1810 let session = context.get(sessionContext);
1811 // ^ typeof Session
1812 console.log(session.get("userId"), request.method, request.url);
1813 };
1814
1815 // ... or some downstream loader
1816 export function loader({ context }: Route.LoaderArgs) {
1817 let session = context.get(sessionContext);
1818 let profile = await getProfile(session.get("userId"));
1819 return { profile };
1820 }
1821 ```
1822
1823 If you are using a custom server with a `getLoadContext` function, the return value for initial context values passed from the server adapter layer is no longer an object and should now return an `unstable_InitialContext` (`Map<RouterContext, unknown>`):
1824
1825 ```ts
1826 let adapterContext = unstable_createContext<MyAdapterContext>();
1827
1828 function getLoadContext(req, res): unstable_InitialContext {
1829 let map = new Map();
1830 map.set(adapterContext, getAdapterContext(req));
1831 return map;
1832 }
1833 ```
1834
1835- Fix types for loaderData and actionData that contained `Record`s ([#13139](https://github.com/remix-run/react-router/pull/13139))
1836
1837 UNSTABLE(BREAKING):
1838
1839 `unstable_SerializesTo` added a way to register custom serialization types in Single Fetch for other library and framework authors like Apollo.
1840 It was implemented with branded type whose branded property that was made optional so that casting arbitrary values was easy:
1841
1842 ```ts
1843 // without the brand being marked as optional
1844 let x1 = 42 as unknown as unstable_SerializesTo<number>;
1845 // ^^^^^^^^^^
1846
1847 // with the brand being marked as optional
1848 let x2 = 42 as unstable_SerializesTo<number>;
1849 ```
1850
1851 However, this broke type inference in `loaderData` and `actionData` for any `Record` types as those would now (incorrectly) match `unstable_SerializesTo`.
1852 This affected all users, not just those that depended on `unstable_SerializesTo`.
1853 To fix this, the branded property of `unstable_SerializesTo` is marked as required instead of optional.
1854
1855 For library and framework authors using `unstable_SerializesTo`, you may need to add `as unknown` casts before casting to `unstable_SerializesTo`.
1856
1857- Fix single fetch `_root.data` requests when a `basename` is used ([#12898](https://github.com/remix-run/react-router/pull/12898))
1858
1859- Add `context` support to client side data routers (unstable) ([#12941](https://github.com/remix-run/react-router/pull/12941))
1860
1861 Your application `loader` and `action` functions on the client will now receive a `context` parameter. This is an instance of `unstable_RouterContextProvider` that you use with type-safe contexts (similar to `React.createContext`) and is most useful with the corresponding `middleware`/`clientMiddleware` API's:
1862
1863 ```ts
1864 import { unstable_createContext } from "react-router";
1865
1866 type User = {
1867 /*...*/
1868 };
1869
1870 let userContext = unstable_createContext<User>();
1871
1872 function sessionMiddleware({ context }) {
1873 let user = await getUser();
1874 context.set(userContext, user);
1875 }
1876
1877 // ... then in some downstream loader
1878 function loader({ context }) {
1879 let user = context.get(userContext);
1880 let profile = await getProfile(user.id);
1881 return { profile };
1882 }
1883 ```
1884
1885 Similar to server-side requests, a fresh `context` will be created per navigation (or `fetcher` call). If you have initial data you'd like to populate in the context for every request, you can provide an `unstable_getContext` function at the root of your app:
1886 - Library mode - `createBrowserRouter(routes, { unstable_getContext })`
1887 - Framework mode - `<HydratedRouter unstable_getContext>`
1888
1889 This function should return an value of type `unstable_InitialContext` which is a `Map<unstable_RouterContext, unknown>` of context's and initial values:
1890
1891 ```ts
1892 const loggerContext = unstable_createContext<(...args: unknown[]) => void>();
1893
1894 function logger(...args: unknown[]) {
1895 console.log(new Date.toISOString(), ...args);
1896 }
1897
1898 function unstable_getContext() {
1899 let map = new Map();
1900 map.set(loggerContext, logger);
1901 return map;
1902 }
1903 ```
1904
1905## 7.2.0
1906
1907### Minor Changes
1908
1909- New type-safe `href` utility that guarantees links point to actual paths in your app ([#13012](https://github.com/remix-run/react-router/pull/13012))
1910
1911 ```tsx
1912 import { href } from "react-router";
1913
1914 export default function Component() {
1915 const link = href("/blog/:slug", { slug: "my-first-post" });
1916 return (
1917 <main>
1918 <Link to={href("/products/:id", { id: "asdf" })} />
1919 <NavLink to={href("/:lang?/about", { lang: "en" })} />
1920 </main>
1921 );
1922 }
1923 ```
1924
1925### Patch Changes
1926
1927- Fix typegen for repeated params ([#13012](https://github.com/remix-run/react-router/pull/13012))
1928
1929 In React Router, path parameters are keyed by their name.
1930 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.
1931 For example, `/a/1/b/2/c/3` will result in the value `{ id: 3 }` at runtime.
1932
1933 Previously, generated types for params incorrectly modeled repeated params with an array.
1934 So `/a/1/b/2/c/3` generated a type like `{ id: [1,2,3] }`.
1935
1936 To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters.
1937 So `/a/1/b/2/c/3` now generates a type like `{ id: 3 }`.
1938
1939- Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request ([#12948](https://github.com/remix-run/react-router/pull/12948))
1940
1941- Properly handle revalidations to across a prerender/SPA boundary ([#13021](https://github.com/remix-run/react-router/pull/13021))
1942 - 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
1943 - We don't know all the pre-rendered paths client-side, however:
1944 - All `loader` data in `ssr:false` mode is static because it's generated at build time
1945 - A route must use a `clientLoader` to do anything dynamic
1946 - 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
1947 - We short circuit and skip single fetch `.data` request logic if there are no server loaders with `shouldLoad=true` in our single fetch `dataStrategy`
1948 - This ensures that the route doesn't cause a `.data` request that would 404 after a submission
1949
1950- Error at build time in `ssr:false` + `prerender` apps for the edge case scenario of: ([#13021](https://github.com/remix-run/react-router/pull/13021))
1951 - A parent route has only a `loader` (does not have a `clientLoader`)
1952 - The parent route is pre-rendered
1953 - The parent route has children routes which are not prerendered
1954 - 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`
1955 - This can be resolved by either adding a parent `clientLoader` or pre-rendering the child paths
1956 - If you add a `clientLoader`, calling the `serverLoader()` on non-prerendered paths will throw a 404
1957
1958- Add unstable support for splitting route modules in framework mode via `future.unstable_splitRouteModules` ([#11871](https://github.com/remix-run/react-router/pull/11871))
1959
1960- Add `unstable_SerializesTo` brand type for library authors to register types serializable by React Router's streaming format (`turbo-stream`) ([`ab5b05b02`](https://github.com/remix-run/react-router/commit/ab5b05b02f99f062edb3c536c392197c88eb6c77))
1961
1962- Align dev server behavior with static file server behavior when `ssr:false` is set ([#12948](https://github.com/remix-run/react-router/pull/12948))
1963 - When no `prerender` config exists, only SSR down to the root `HydrateFallback` (SPA Mode)
1964 - When a `prerender` config exists but the current path is not prerendered, only SSR down to the root `HydrateFallback` (SPA Fallback)
1965 - Return a 404 on `.data` requests to non-pre-rendered paths
1966
1967- Improve prefetch performance of CSS side effects in framework mode ([#12889](https://github.com/remix-run/react-router/pull/12889))
1968
1969- 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 ([#12894](https://github.com/remix-run/react-router/pull/12894))
1970 - 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
1971 - 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
1972
1973- Properly handle interrupted manifest requests in lazy route discovery ([#12915](https://github.com/remix-run/react-router/pull/12915))
1974
1975## 7.1.5
1976
1977### Patch Changes
1978
1979- Fix regression introduced in `7.1.4` via [#12800](https://github.com/remix-run/react-router/pull/12800) that caused issues navigating to hash routes inside splat routes for applications using Lazy Route Discovery (`patchRoutesOnNavigation`) ([#12927](https://github.com/remix-run/react-router/pull/12927))
1980
1981## 7.1.4
1982
1983### Patch Changes
1984
1985- Internal reorg to clean up some duplicated route module types ([#12799](https://github.com/remix-run/react-router/pull/12799))
1986- Properly handle status codes that cannot have a body in single fetch responses (204, etc.) ([#12760](https://github.com/remix-run/react-router/pull/12760))
1987- Stop erroring on resource routes that return raw strings/objects and instead serialize them as `text/plain` or `application/json` responses ([#12848](https://github.com/remix-run/react-router/pull/12848))
1988 - This only applies when accessed as a resource route without the `.data` extension
1989 - When accessed from a Single Fetch `.data` request, they will still be encoded via `turbo-stream`
1990- Optimize Lazy Route Discovery path discovery to favor a single `querySelectorAll` call at the `body` level instead of many calls at the sub-tree level ([#12731](https://github.com/remix-run/react-router/pull/12731))
1991- Properly bubble headers as `errorHeaders` when throwing a `data()` result ([#12846](https://github.com/remix-run/react-router/pull/12846))
1992 - Avoid duplication of `Set-Cookie` headers could be duplicated if also returned from `headers`
1993- Optimize route matching by skipping redundant `matchRoutes` calls when possible ([#12800](https://github.com/remix-run/react-router/pull/12800))
1994
1995## 7.1.3
1996
1997_No changes_
1998
1999## 7.1.2
2000
2001### Patch Changes
2002
2003- Fix issue with fetcher data cleanup in the data layer on fetcher unmount ([#12681](https://github.com/remix-run/react-router/pull/12681))
2004- Do not rely on `symbol` for filtering out `redirect` responses from loader data ([#12694](https://github.com/remix-run/react-router/pull/12694))
2005
2006 Previously, some projects were getting type checking errors like:
2007
2008 ```ts
2009 error TS4058: Return type of exported function has or is using name 'redirectSymbol' from external module "node_modules/..." but cannot be named.
2010 ```
2011
2012 Now that `symbol`s are not used for the `redirect` response type, these errors should no longer be present.
2013
2014## 7.1.1
2015
2016_No changes_
2017
2018## 7.1.0
2019
2020### Patch Changes
2021
2022- Throw unwrapped single fetch redirect to align with pre-single fetch behavior ([#12506](https://github.com/remix-run/react-router/pull/12506))
2023- Ignore redirects when inferring loader data types ([#12527](https://github.com/remix-run/react-router/pull/12527))
2024- Remove `<Link prefetch>` warning which suffers from false positives in a lazy route discovery world ([#12485](https://github.com/remix-run/react-router/pull/12485))
2025
2026## 7.0.2
2027
2028### Patch Changes
2029
2030- temporarily only use one build in export map so packages can have a peer dependency on react router ([#12437](https://github.com/remix-run/react-router/pull/12437))
2031- Generate wide `matches` and `params` types for current route and child routes ([#12397](https://github.com/remix-run/react-router/pull/12397))
2032
2033 At runtime, `matches` includes child route matches and `params` include child route path parameters.
2034 But previously, we only generated types for parent routes in `matches`; for `params`, we only considered the parent routes and the current route.
2035 To align our generated types more closely to the runtime behavior, we now generate more permissive, wider types when accessing child route information.
2036
2037## 7.0.1
2038
2039_No changes_
2040
2041## 7.0.0
2042
2043### Major Changes
2044
2045- Remove the original `defer` implementation in favor of using raw promises via single fetch and `turbo-stream`. This removes these exports from React Router: ([#11744](https://github.com/remix-run/react-router/pull/11744))
2046 - `defer`
2047 - `AbortedDeferredError`
2048 - `type TypedDeferredData`
2049 - `UNSAFE_DeferredData`
2050 - `UNSAFE_DEFERRED_SYMBOL`,
2051
2052- - Collapse `@remix-run/router` into `react-router` ([#11505](https://github.com/remix-run/react-router/pull/11505))
2053 - Collapse `react-router-dom` into `react-router`
2054 - Collapse `@remix-run/server-runtime` into `react-router`
2055 - Collapse `@remix-run/testing` into `react-router`
2056
2057- Remove single fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
2058
2059- Drop support for Node 16, React Router SSR now requires Node 18 or higher ([#11391](https://github.com/remix-run/react-router/pull/11391))
2060
2061- Remove `future.v7_startTransition` flag ([#11696](https://github.com/remix-run/react-router/pull/11696))
2062
2063- - Expose the underlying router promises from the following APIs for compsition in React 19 APIs: ([#11521](https://github.com/remix-run/react-router/pull/11521))
2064 - `useNavigate()`
2065 - `useSubmit`
2066 - `useFetcher().load`
2067 - `useFetcher().submit`
2068 - `useRevalidator.revalidate`
2069
2070- Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
2071
2072- For Remix consumers migrating to React Router, the `crypto` global from the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is now required when using cookie and session APIs. This means that the following APIs are provided from `react-router` rather than platform-specific packages: ([#11837](https://github.com/remix-run/react-router/pull/11837))
2073 - `createCookie`
2074 - `createCookieSessionStorage`
2075 - `createMemorySessionStorage`
2076 - `createSessionStorage`
2077
2078 For consumers running older versions of Node, the `installGlobals` function from `@remix-run/node` has been updated to define `globalThis.crypto`, using [Node's `require('node:crypto').webcrypto` implementation.](https://nodejs.org/api/webcrypto.html)
2079
2080 Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
2081 - `createCookieFactory`
2082 - `createSessionStorageFactory`
2083 - `createCookieSessionStorageFactory`
2084 - `createMemorySessionStorageFactory`
2085
2086- Imports/Exports cleanup ([#11840](https://github.com/remix-run/react-router/pull/11840))
2087 - Removed the following exports that were previously public API from `@remix-run/router`
2088 - types
2089 - `AgnosticDataIndexRouteObject`
2090 - `AgnosticDataNonIndexRouteObject`
2091 - `AgnosticDataRouteMatch`
2092 - `AgnosticDataRouteObject`
2093 - `AgnosticIndexRouteObject`
2094 - `AgnosticNonIndexRouteObject`
2095 - `AgnosticRouteMatch`
2096 - `AgnosticRouteObject`
2097 - `TrackedPromise`
2098 - `unstable_AgnosticPatchRoutesOnMissFunction`
2099 - `Action` -> exported as `NavigationType` via `react-router`
2100 - `Router` exported as `DataRouter` to differentiate from RR's `<Router>`
2101 - API
2102 - `getToPathname` (`@private`)
2103 - `joinPaths` (`@private`)
2104 - `normalizePathname` (`@private`)
2105 - `resolveTo` (`@private`)
2106 - `stripBasename` (`@private`)
2107 - `createBrowserHistory` -> in favor of `createBrowserRouter`
2108 - `createHashHistory` -> in favor of `createHashRouter`
2109 - `createMemoryHistory` -> in favor of `createMemoryRouter`
2110 - `createRouter`
2111 - `createStaticHandler` -> in favor of wrapper `createStaticHandler` in RR Dom
2112 - `getStaticContextFromError`
2113 - Removed the following exports that were previously public API from `react-router`
2114 - `Hash`
2115 - `Pathname`
2116 - `Search`
2117
2118- update minimum node version to 18 ([#11690](https://github.com/remix-run/react-router/pull/11690))
2119
2120- Remove `future.v7_prependBasename` from the ionternalized `@remix-run/router` package ([#11726](https://github.com/remix-run/react-router/pull/11726))
2121
2122- Migrate Remix type generics to React Router ([#12180](https://github.com/remix-run/react-router/pull/12180))
2123 - These generics are provided for Remix v2 migration purposes
2124 - These generics and the APIs they exist on should be considered informally deprecated in favor of the new `Route.*` types
2125 - Anyone migrating from React Router v6 should probably not leverage these new generics and should migrate straight to the `Route.*` types
2126 - For React Router v6 users, these generics are new and should not impact your app, with one exception
2127 - `useFetcher` previously had an optional generic (used primarily by Remix v2) that expected the data type
2128 - This has been updated in v7 to expect the type of the function that generates the data (i.e., `typeof loader`/`typeof action`)
2129 - Therefore, you should update your usages:
2130 - ❌ `useFetcher<LoaderData>()`
2131 - ✅ `useFetcher<typeof loader>()`
2132
2133- Remove `future.v7_throwAbortReason` from internalized `@remix-run/router` package ([#11728](https://github.com/remix-run/react-router/pull/11728))
2134
2135- Add `exports` field to all packages ([#11675](https://github.com/remix-run/react-router/pull/11675))
2136
2137- node package no longer re-exports from react-router ([#11702](https://github.com/remix-run/react-router/pull/11702))
2138
2139- renamed RemixContext to FrameworkContext ([#11705](https://github.com/remix-run/react-router/pull/11705))
2140
2141- updates the minimum React version to 18 ([#11689](https://github.com/remix-run/react-router/pull/11689))
2142
2143- PrefetchPageDescriptor replaced by PageLinkDescriptor ([#11960](https://github.com/remix-run/react-router/pull/11960))
2144
2145- - Consolidate types previously duplicated across `@remix-run/router`, `@remix-run/server-runtime`, and `@remix-run/react` now that they all live in `react-router` ([#12177](https://github.com/remix-run/react-router/pull/12177))
2146 - Examples: `LoaderFunction`, `LoaderFunctionArgs`, `ActionFunction`, `ActionFunctionArgs`, `DataFunctionArgs`, `RouteManifest`, `LinksFunction`, `Route`, `EntryRoute`
2147 - The `RouteManifest` type used by the "remix" code is now slightly stricter because it is using the former `@remix-run/router` `RouteManifest`
2148 - `Record<string, Route> -> Record<string, Route | undefined>`
2149 - Removed `AppData` type in favor of inlining `unknown` in the few locations it was used
2150 - Removed `ServerRuntimeMeta*` types in favor of the `Meta*` types they were duplicated from
2151
2152- - Remove the `future.v7_partialHydration` flag ([#11725](https://github.com/remix-run/react-router/pull/11725))
2153 - This also removes the `<RouterProvider fallbackElement>` prop
2154 - To migrate, move the `fallbackElement` to a `hydrateFallbackElement`/`HydrateFallback` on your root route
2155 - Also worth nothing there is a related breaking changer with this future flag:
2156 - Without `future.v7_partialHydration` (when using `fallbackElement`), `state.navigation` was populated during the initial load
2157 - With `future.v7_partialHydration`, `state.navigation` remains in an `"idle"` state during the initial load
2158
2159- Remove `v7_relativeSplatPath` future flag ([#11695](https://github.com/remix-run/react-router/pull/11695))
2160
2161- Drop support for Node 18, update minimum Node vestion to 20 ([#12171](https://github.com/remix-run/react-router/pull/12171))
2162 - Remove `installGlobals()` as this should no longer be necessary
2163
2164- Remove remaining future flags ([#11820](https://github.com/remix-run/react-router/pull/11820))
2165 - React Router `v7_skipActionErrorRevalidation`
2166 - Remix `v3_fetcherPersist`, `v3_relativeSplatPath`, `v3_throwAbortReason`
2167
2168- rename createRemixStub to createRoutesStub ([#11692](https://github.com/remix-run/react-router/pull/11692))
2169
2170- Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties` ([#11751](https://github.com/remix-run/react-router/pull/11751))
2171
2172- Add `react-router/dom` subpath export to properly enable `react-dom` as an optional `peerDependency` ([#11851](https://github.com/remix-run/react-router/pull/11851))
2173 - This ensures that we don't blindly `import ReactDOM from "react-dom"` in `<RouterProvider>` in order to access `ReactDOM.flushSync()`, since that would break `createMemoryRouter` use cases in non-DOM environments
2174 - DOM environments should import from `react-router/dom` to get the proper component that makes `ReactDOM.flushSync()` available:
2175 - If you are using the Vite plugin, use this in your `entry.client.tsx`:
2176 - `import { HydratedRouter } from 'react-router/dom'`
2177 - If you are not using the Vite plugin and are manually calling `createBrowserRouter`/`createHashRouter`:
2178 - `import { RouterProvider } from "react-router/dom"`
2179
2180- Remove `future.v7_fetcherPersist` flag ([#11731](https://github.com/remix-run/react-router/pull/11731))
2181
2182- Update `cookie` dependency to `^1.0.1` - please see the [release notes](https://github.com/jshttp/cookie/releases) for any breaking changes ([#12172](https://github.com/remix-run/react-router/pull/12172))
2183
2184### Minor Changes
2185
2186- - Add support for `prerender` config in the React Router vite plugin, to support existing SSG use-cases ([#11539](https://github.com/remix-run/react-router/pull/11539))
2187 - You can use the `prerender` config to pre-render your `.html` and `.data` files at build time and then serve them statically at runtime (either from a running server or a CDN)
2188 - `prerender` can either be an array of string paths, or a function (sync or async) that returns an array of strings so that you can dynamically generate the paths by talking to your CMS, etc.
2189
2190 ```ts
2191 // react-router.config.ts
2192 import type { Config } from "@react-router/dev/config";
2193
2194 export default {
2195 async prerender() {
2196 let slugs = await fakeGetSlugsFromCms();
2197 // Prerender these paths into `.html` files at build time, and `.data`
2198 // files if they have loaders
2199 return ["/", "/about", ...slugs.map((slug) => `/product/${slug}`)];
2200 },
2201 } satisfies Config;
2202
2203 async function fakeGetSlugsFromCms() {
2204 await new Promise((r) => setTimeout(r, 1000));
2205 return ["shirt", "hat"];
2206 }
2207 ```
2208
2209- Params, loader data, and action data as props for route component exports ([#11961](https://github.com/remix-run/react-router/pull/11961))
2210
2211 ```tsx
2212 export default function Component({ params, loaderData, actionData }) {}
2213
2214 export function HydrateFallback({ params }) {}
2215 export function ErrorBoundary({ params, loaderData, actionData }) {}
2216 ```
2217
2218- Remove duplicate `RouterProvider` impliementations ([#11679](https://github.com/remix-run/react-router/pull/11679))
2219
2220- ### Typesafety improvements ([#12019](https://github.com/remix-run/react-router/pull/12019))
2221
2222 React Router now generates types for each of your route modules.
2223 You can access those types by importing them from `./+types.<route filename without extension>`.
2224 For example:
2225
2226 ```ts
2227 // app/routes/product.tsx
2228 import type * as Route from "./+types.product";
2229
2230 export function loader({ params }: Route.LoaderArgs) {}
2231
2232 export default function Component({ loaderData }: Route.ComponentProps) {}
2233 ```
2234
2235 This initial implementation targets type inference for:
2236 - `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
2237 - `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
2238 - `ActionData` : Action data from `action` and/or `clientAction` within your route module
2239
2240 In the future, we plan to add types for the rest of the route module exports: `meta`, `links`, `headers`, `shouldRevalidate`, etc.
2241 We also plan to generate types for typesafe `Link`s:
2242
2243 ```tsx
2244 <Link to="/products/:id" params={{ id: 1 }} />
2245 // ^^^^^^^^^^^^^ ^^^^^^^^^
2246 // typesafe `to` and `params` based on the available routes in your app
2247 ```
2248
2249 Check out our docs for more:
2250 - [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
2251 - [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
2252
2253- Stabilize `unstable_dataStrategy` ([#11969](https://github.com/remix-run/react-router/pull/11969))
2254
2255- Stabilize `unstable_patchRoutesOnNavigation` ([#11970](https://github.com/remix-run/react-router/pull/11970))
2256
2257### Patch Changes
2258
2259- No changes ([`506329c4e`](https://github.com/remix-run/react-router/commit/506329c4e2e7aba9837cbfa44df6103b49423745))
2260
2261- chore: re-enable development warnings through a `development` exports condition. ([#12269](https://github.com/remix-run/react-router/pull/12269))
2262
2263- Remove unstable upload handler. ([#12015](https://github.com/remix-run/react-router/pull/12015))
2264
2265- Remove unneeded dependency on @web3-storage/multipart-parser ([#12274](https://github.com/remix-run/react-router/pull/12274))
2266
2267- Fix redirects returned from loaders/actions using `data()` ([#12021](https://github.com/remix-run/react-router/pull/12021))
2268
2269- fix(react-router): (v7) fix static prerender of non-ascii characters ([#12161](https://github.com/remix-run/react-router/pull/12161))
2270
2271- Replace `substr` with `substring` ([#12080](https://github.com/remix-run/react-router/pull/12080))
2272
2273- Remove the deprecated `json` utility ([#12146](https://github.com/remix-run/react-router/pull/12146))
2274 - You can use [`Response.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json_static) if you still need to construct JSON responses in your app
2275
2276- Remove unneeded dependency on source-map ([#12275](https://github.com/remix-run/react-router/pull/12275))
2277
2278## 6.28.0
2279
2280### Minor Changes
2281
2282- - Log deprecation warnings for v7 flags ([#11750](https://github.com/remix-run/react-router/pull/11750))
2283 - Add deprecation warnings to `json`/`defer` in favor of returning raw objects
2284 - These methods will be removed in React Router v7
2285
2286### Patch Changes
2287
2288- Update JSDoc URLs for new website structure (add /v6/ segment) ([#12141](https://github.com/remix-run/react-router/pull/12141))
2289- Updated dependencies:
2290 - `@remix-run/router@1.21.0`
2291
2292## 6.27.0
2293
2294### Minor Changes
2295
2296- Stabilize `unstable_patchRoutesOnNavigation` ([#11973](https://github.com/remix-run/react-router/pull/11973))
2297 - Add new `PatchRoutesOnNavigationFunctionArgs` type for convenience ([#11967](https://github.com/remix-run/react-router/pull/11967))
2298- Stabilize `unstable_dataStrategy` ([#11974](https://github.com/remix-run/react-router/pull/11974))
2299- Stabilize the `unstable_flushSync` option for navigations and fetchers ([#11989](https://github.com/remix-run/react-router/pull/11989))
2300- Stabilize the `unstable_viewTransition` option for navigations and the corresponding `unstable_useViewTransitionState` hook ([#11989](https://github.com/remix-run/react-router/pull/11989))
2301
2302### Patch Changes
2303
2304- Fix bug when submitting to the current contextual route (parent route with an index child) when an `?index` param already exists from a prior submission ([#12003](https://github.com/remix-run/react-router/pull/12003))
2305
2306- Fix `useFormAction` bug - when removing `?index` param it would not keep other non-Remix `index` params ([#12003](https://github.com/remix-run/react-router/pull/12003))
2307
2308- Fix types for `RouteObject` within `PatchRoutesOnNavigationFunction`'s `patch` method so it doesn't expect agnostic route objects passed to `patch` ([#11967](https://github.com/remix-run/react-router/pull/11967))
2309
2310- Updated dependencies:
2311 - `@remix-run/router@1.20.0`
2312
2313## 6.26.2
2314
2315### Patch Changes
2316
2317- Updated dependencies:
2318 - `@remix-run/router@1.19.2`
2319
2320## 6.26.1
2321
2322### Patch Changes
2323
2324- Rename `unstable_patchRoutesOnMiss` to `unstable_patchRoutesOnNavigation` to match new behavior ([#11888](https://github.com/remix-run/react-router/pull/11888))
2325- Updated dependencies:
2326 - `@remix-run/router@1.19.1`
2327
2328## 6.26.0
2329
2330### Minor Changes
2331
2332- Add a new `replace(url, init?)` alternative to `redirect(url, init?)` that performs a `history.replaceState` instead of a `history.pushState` on client-side navigation redirects ([#11811](https://github.com/remix-run/react-router/pull/11811))
2333
2334### Patch Changes
2335
2336- Fix initial hydration behavior when using `future.v7_partialHydration` along with `unstable_patchRoutesOnMiss` ([#11838](https://github.com/remix-run/react-router/pull/11838))
2337 - During initial hydration, `router.state.matches` will now include any partial matches so that we can render ancestor `HydrateFallback` components
2338- Updated dependencies:
2339 - `@remix-run/router@1.19.0`
2340
2341## 6.25.1
2342
2343No significant changes to this package were made in this release. [See the repo `CHANGELOG.md`](https://github.com/remix-run/react-router/blob/main/CHANGELOG.md) for an overview of all changes in v6.25.1.
2344
2345## 6.25.0
2346
2347### Minor Changes
2348
2349- Stabilize `future.unstable_skipActionErrorRevalidation` as `future.v7_skipActionErrorRevalidation` ([#11769](https://github.com/remix-run/react-router/pull/11769))
2350 - When this flag is enabled, actions will not automatically trigger a revalidation if they return/throw a `Response` with a `4xx`/`5xx` status code
2351 - You may still opt-into revalidation via `shouldRevalidate`
2352 - This also changes `shouldRevalidate`'s `unstable_actionStatus` parameter to `actionStatus`
2353
2354### Patch Changes
2355
2356- Fix regression and properly decode paths inside `useMatch` so matches/params reflect decoded params ([#11789](https://github.com/remix-run/react-router/pull/11789))
2357- Updated dependencies:
2358 - `@remix-run/router@1.18.0`
2359
2360## 6.24.1
2361
2362### Patch Changes
2363
2364- When using `future.v7_relativeSplatPath`, properly resolve relative paths in splat routes that are children of pathless routes ([#11633](https://github.com/remix-run/react-router/pull/11633))
2365- Updated dependencies:
2366 - `@remix-run/router@1.17.1`
2367
2368## 6.24.0
2369
2370### Minor Changes
2371
2372- Add support for Lazy Route Discovery (a.k.a. Fog of War) ([#11626](https://github.com/remix-run/react-router/pull/11626))
2373 - RFC: <https://github.com/remix-run/react-router/discussions/11113>
2374 - `unstable_patchRoutesOnMiss` docs: <https://reactrouter.com/v6/routers/create-browser-router>
2375
2376### Patch Changes
2377
2378- Updated dependencies:
2379 - `@remix-run/router@1.17.0`
2380
2381## 6.23.1
2382
2383### Patch Changes
2384
2385- allow undefined to be resolved with `<Await>` ([#11513](https://github.com/remix-run/react-router/pull/11513))
2386- Updated dependencies:
2387 - `@remix-run/router@1.16.1`
2388
2389## 6.23.0
2390
2391### Minor Changes
2392
2393- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098))
2394 - This option allows Data Router applications to take control over the approach for executing route loaders and actions
2395 - The default implementation is today's behavior, to fetch all loaders in parallel, but this option allows users to implement more advanced data flows including Remix single-fetch, middleware/context APIs, automatic loader caching, and more
2396
2397### Patch Changes
2398
2399- Updated dependencies:
2400 - `@remix-run/router@1.16.0`
2401
2402## 6.22.3
2403
2404### Patch Changes
2405
2406- Updated dependencies:
2407 - `@remix-run/router@1.15.3`
2408
2409## 6.22.2
2410
2411### Patch Changes
2412
2413- Updated dependencies:
2414 - `@remix-run/router@1.15.2`
2415
2416## 6.22.1
2417
2418### Patch Changes
2419
2420- Fix encoding/decoding issues with pre-encoded dynamic parameter values ([#11199](https://github.com/remix-run/react-router/pull/11199))
2421- Updated dependencies:
2422 - `@remix-run/router@1.15.1`
2423
2424## 6.22.0
2425
2426### Patch Changes
2427
2428- Updated dependencies:
2429 - `@remix-run/router@1.15.0`
2430
2431## 6.21.3
2432
2433### Patch Changes
2434
2435- Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
2436
2437## 6.21.2
2438
2439### Patch Changes
2440
2441- Updated dependencies:
2442 - `@remix-run/router@1.14.2`
2443
2444## 6.21.1
2445
2446### Patch Changes
2447
2448- Fix bug with `route.lazy` not working correctly on initial SPA load when `v7_partialHydration` is specified ([#11121](https://github.com/remix-run/react-router/pull/11121))
2449- Updated dependencies:
2450 - `@remix-run/router@1.14.1`
2451
2452## 6.21.0
2453
2454### Minor Changes
2455
2456- Add a new `future.v7_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. ([#11087](https://github.com/remix-run/react-router/pull/11087))
2457
2458 This fix was originally added in [#10983](https://github.com/remix-run/react-router/issues/10983) and was later reverted in [#11078](https://github.com/remix-run/react-router/pull/11078) because it was determined that a large number of existing applications were relying on the buggy behavior (see [#11052](https://github.com/remix-run/react-router/issues/11052))
2459
2460 **The Bug**
2461 The buggy behavior is that without this flag, the default behavior when resolving relative paths is to _ignore_ any splat (`*`) portion of the current route path.
2462
2463 **The Background**
2464 This decision was originally made thinking that it would make the concept of nested different sections of your apps in `<Routes>` easier if relative routing would _replace_ the current splat:
2465
2466 ```jsx
2467 <BrowserRouter>
2468 <Routes>
2469 <Route path="/" element={<Home />} />
2470 <Route path="dashboard/*" element={<Dashboard />} />
2471 </Routes>
2472 </BrowserRouter>
2473 ```
2474
2475 Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
2476
2477 ```jsx
2478 function Dashboard() {
2479 return (
2480 <div>
2481 <h2>Dashboard</h2>
2482 <nav>
2483 <Link to="/">Dashboard Home</Link>
2484 <Link to="team">Team</Link>
2485 <Link to="projects">Projects</Link>
2486 </nav>
2487
2488 <Routes>
2489 <Route path="/" element={<DashboardHome />} />
2490 <Route path="team" element={<DashboardTeam />} />
2491 <Route path="projects" element={<DashboardProjects />} />
2492 </Routes>
2493 </div>
2494 );
2495 }
2496 ```
2497
2498 Now, all links and route paths are relative to the router above them. This makes code splitting and compartmentalizing your app really easy. You could render the `Dashboard` as its own independent app, or embed it into your large app without making any changes to it.
2499
2500 **The Problem**
2501
2502 The problem is that this concept of ignoring part of a path breaks a lot of other assumptions in React Router - namely that `"."` always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using `"."`:
2503
2504 ```jsx
2505 // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
2506 function DashboardTeam() {
2507 // ❌ This is broken and results in <a href="/dashboard">
2508 return <Link to=".">A broken link to the Current URL</Link>;
2509
2510 // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
2511 return <Link to="./team">A broken link to the Current URL</Link>;
2512 }
2513 ```
2514
2515 We've also introduced an issue that we can no longer move our `DashboardTeam` component around our route hierarchy easily - since it behaves differently if we're underneath a non-splat route, such as `/dashboard/:widget`. Now, our `"."` links will, properly point to ourself _inclusive of the dynamic param value_ so behavior will break from it's corresponding usage in a `/dashboard/*` route.
2516
2517 Even worse, consider a nested splat route configuration:
2518
2519 ```jsx
2520 <BrowserRouter>
2521 <Routes>
2522 <Route path="dashboard">
2523 <Route path="*" element={<Dashboard />} />
2524 </Route>
2525 </Routes>
2526 </BrowserRouter>
2527 ```
2528
2529 Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
2530
2531 Another common issue arose in Data Routers (and Remix) where any `<Form>` should post to it's own route `action` if you the user doesn't specify a form action:
2532
2533 ```jsx
2534 let router = createBrowserRouter({
2535 path: "/dashboard",
2536 children: [
2537 {
2538 path: "*",
2539 action: dashboardAction,
2540 Component() {
2541 // ❌ This form is broken! It throws a 405 error when it submits because
2542 // it tries to submit to /dashboard (without the splat value) and the parent
2543 // `/dashboard` route doesn't have an action
2544 return <Form method="post">...</Form>;
2545 },
2546 },
2547 ],
2548 });
2549 ```
2550
2551 This is just a compounded issue from the above because the default location for a `Form` to submit to is itself (`"."`) - and if we ignore the splat portion, that now resolves to the parent route.
2552
2553 **The Solution**
2554 If you are leveraging this behavior, it's recommended to enable the future flag, move your splat to it's own route, and leverage `../` for any links to "sibling" pages:
2555
2556 ```jsx
2557 <BrowserRouter>
2558 <Routes>
2559 <Route path="dashboard">
2560 <Route index path="*" element={<Dashboard />} />
2561 </Route>
2562 </Routes>
2563 </BrowserRouter>
2564
2565 function Dashboard() {
2566 return (
2567 <div>
2568 <h2>Dashboard</h2>
2569 <nav>
2570 <Link to="..">Dashboard Home</Link>
2571 <Link to="../team">Team</Link>
2572 <Link to="../projects">Projects</Link>
2573 </nav>
2574
2575 <Routes>
2576 <Route path="/" element={<DashboardHome />} />
2577 <Route path="team" element={<DashboardTeam />} />
2578 <Route path="projects" element={<DashboardProjects />} />
2579 </Router>
2580 </div>
2581 );
2582 }
2583 ```
2584
2585 This way, `.` means "the full current pathname for my route" in all cases (including static, dynamic, and splat routes) and `..` always means "my parents pathname".
2586
2587### Patch Changes
2588
2589- Properly handle falsy error values in ErrorBoundary's ([#11071](https://github.com/remix-run/react-router/pull/11071))
2590- Updated dependencies:
2591 - `@remix-run/router@1.14.0`
2592
2593## 6.20.1
2594
2595### Patch Changes
2596
2597- Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see <https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329>). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
2598- Updated dependencies:
2599 - `@remix-run/router@1.13.1`
2600
2601## 6.20.0
2602
2603### Minor Changes
2604
2605- Export the `PathParam` type from the public API ([#10719](https://github.com/remix-run/react-router/pull/10719))
2606
2607### Patch Changes
2608
2609- Fix bug with `resolveTo` in splat routes ([#11045](https://github.com/remix-run/react-router/pull/11045))
2610 - This is a follow up to [#10983](https://github.com/remix-run/react-router/pull/10983) to handle the few other code paths using `getPathContributingMatches`
2611 - This removes the `UNSAFE_getPathContributingMatches` export from `@remix-run/router` since we no longer need this in the `react-router`/`react-router-dom` layers
2612- Updated dependencies:
2613 - `@remix-run/router@1.13.0`
2614
2615## 6.19.0
2616
2617### Minor Changes
2618
2619- Add `unstable_flushSync` option to `useNavigate`/`useSumbit`/`fetcher.load`/`fetcher.submit` to opt-out of `React.startTransition` and into `ReactDOM.flushSync` for state updates ([#11005](https://github.com/remix-run/react-router/pull/11005))
2620- Remove the `unstable_` prefix from the [`useBlocker`](https://reactrouter.com/v6/hooks/use-blocker) hook as it's been in use for enough time that we are confident in the API. We do not plan to remove the prefix from `unstable_usePrompt` due to differences in how browsers handle `window.confirm` that prevent React Router from guaranteeing consistent/correct behavior. ([#10991](https://github.com/remix-run/react-router/pull/10991))
2621
2622### Patch Changes
2623
2624- Fix `useActionData` so it returns proper contextual action data and not _any_ action data in the tree ([#11023](https://github.com/remix-run/react-router/pull/11023))
2625
2626- Fix bug in `useResolvedPath` that would cause `useResolvedPath(".")` in a splat route to lose the splat portion of the URL path. ([#10983](https://github.com/remix-run/react-router/pull/10983))
2627 - ⚠️ This fixes a quite long-standing bug specifically for `"."` paths inside a splat route which incorrectly dropped the splat portion of the URL. If you are relative routing via `"."` inside a splat route in your application you should double check that your logic is not relying on this buggy behavior and update accordingly.
2628
2629- Updated dependencies:
2630 - `@remix-run/router@1.12.0`
2631
2632## 6.18.0
2633
2634### Patch Changes
2635
2636- Fix the `future` prop on `BrowserRouter`, `HashRouter` and `MemoryRouter` so that it accepts a `Partial<FutureConfig>` instead of requiring all flags to be included. ([#10962](https://github.com/remix-run/react-router/pull/10962))
2637- Updated dependencies:
2638 - `@remix-run/router@1.11.0`
2639
2640## 6.17.0
2641
2642### Patch Changes
2643
2644- Fix `RouterProvider` `future` prop type to be a `Partial<FutureConfig>` so that not all flags must be specified ([#10900](https://github.com/remix-run/react-router/pull/10900))
2645- Updated dependencies:
2646 - `@remix-run/router@1.10.0`
2647
2648## 6.16.0
2649
2650### Minor Changes
2651
2652- In order to move towards stricter TypeScript support in the future, we're aiming to replace current usages of `any` with `unknown` on exposed typings for user-provided data. To do this in Remix v2 without introducing breaking changes in React Router v6, we have added generics to a number of shared types. These continue to default to `any` in React Router and are overridden with `unknown` in Remix. In React Router v7 we plan to move these to `unknown` as a breaking change. ([#10843](https://github.com/remix-run/react-router/pull/10843))
2653 - `Location` now accepts a generic for the `location.state` value
2654 - `ActionFunctionArgs`/`ActionFunction`/`LoaderFunctionArgs`/`LoaderFunction` now accept a generic for the `context` parameter (only used in SSR usages via `createStaticHandler`)
2655 - The return type of `useMatches` (now exported as `UIMatch`) accepts generics for `match.data` and `match.handle` - both of which were already set to `unknown`
2656- Move the `@private` class export `ErrorResponse` to an `UNSAFE_ErrorResponseImpl` export since it is an implementation detail and there should be no construction of `ErrorResponse` instances in userland. This frees us up to export a `type ErrorResponse` which correlates to an instance of the class via `InstanceType`. Userland code should only ever be using `ErrorResponse` as a type and should be type-narrowing via `isRouteErrorResponse`. ([#10811](https://github.com/remix-run/react-router/pull/10811))
2657- Export `ShouldRevalidateFunctionArgs` interface ([#10797](https://github.com/remix-run/react-router/pull/10797))
2658- Removed private/internal APIs only required for the Remix v1 backwards compatibility layer and no longer needed in Remix v2 (`_isFetchActionRedirect`, `_hasFetcherDoneAnything`) ([#10715](https://github.com/remix-run/react-router/pull/10715))
2659
2660### Patch Changes
2661
2662- Updated dependencies:
2663 - `@remix-run/router@1.9.0`
2664
2665## 6.15.0
2666
2667### Minor Changes
2668
2669- Add's a new `redirectDocument()` function which allows users to specify that a redirect from a `loader`/`action` should trigger a document reload (via `window.location`) instead of attempting to navigate to the redirected location via React Router ([#10705](https://github.com/remix-run/react-router/pull/10705))
2670
2671### Patch Changes
2672
2673- Ensure `useRevalidator` is referentially stable across re-renders if revalidations are not actively occurring ([#10707](https://github.com/remix-run/react-router/pull/10707))
2674- Updated dependencies:
2675 - `@remix-run/router@1.8.0`
2676
2677## 6.14.2
2678
2679### Patch Changes
2680
2681- Updated dependencies:
2682 - `@remix-run/router@1.7.2`
2683
2684## 6.14.1
2685
2686### Patch Changes
2687
2688- Fix loop in `unstable_useBlocker` when used with an unstable blocker function ([#10652](https://github.com/remix-run/react-router/pull/10652))
2689- Fix issues with reused blockers on subsequent navigations ([#10656](https://github.com/remix-run/react-router/pull/10656))
2690- Updated dependencies:
2691 - `@remix-run/router@1.7.1`
2692
2693## 6.14.0
2694
2695### Patch Changes
2696
2697- Strip `basename` from locations provided to `unstable_useBlocker` functions to match `useLocation` ([#10573](https://github.com/remix-run/react-router/pull/10573))
2698- Fix `generatePath` when passed a numeric `0` value parameter ([#10612](https://github.com/remix-run/react-router/pull/10612))
2699- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573))
2700- Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622))
2701- Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
2702- Updated dependencies:
2703 - `@remix-run/router@1.7.0`
2704
2705## 6.13.0
2706
2707### Minor Changes
2708
2709- Move [`React.startTransition`](https://react.dev/reference/react/startTransition) usage behind a [future flag](https://reactrouter.com/v6/guides/api-development-strategy) to avoid issues with existing incompatible `Suspense` usages. We recommend folks adopting this flag to be better compatible with React concurrent mode, but if you run into issues you can continue without the use of `startTransition` until v7. Issues usually boils down to creating net-new promises during the render cycle, so if you run into issues you should either lift your promise creation out of the render cycle or put it behind a `useMemo`. ([#10596](https://github.com/remix-run/react-router/pull/10596))
2710
2711 Existing behavior will no longer include `React.startTransition`:
2712
2713 ```jsx
2714 <BrowserRouter>
2715 <Routes>{/*...*/}</Routes>
2716 </BrowserRouter>
2717
2718 <RouterProvider router={router} />
2719 ```
2720
2721 If you wish to enable `React.startTransition`, pass the future flag to your component:
2722
2723 ```jsx
2724 <BrowserRouter future={{ v7_startTransition: true }}>
2725 <Routes>{/*...*/}</Routes>
2726 </BrowserRouter>
2727
2728 <RouterProvider router={router} future={{ v7_startTransition: true }}/>
2729 ```
2730
2731### Patch Changes
2732
2733- Work around webpack/terser `React.startTransition` minification bug in production mode ([#10588](https://github.com/remix-run/react-router/pull/10588))
2734
2735## 6.12.1
2736
2737> \[!WARNING]
2738> Please use version `6.13.0` or later instead of `6.12.1`. This version suffers from a `webpack`/`terser` minification issue resulting in invalid minified code in your resulting production bundles which can cause issues in your application. See [#10579](https://github.com/remix-run/react-router/issues/10579) for more details.
2739
2740### Patch Changes
2741
2742- Adjust feature detection of `React.startTransition` to fix webpack + react 17 compilation error ([#10569](https://github.com/remix-run/react-router/pull/10569))
2743
2744## 6.12.0
2745
2746### Minor Changes
2747
2748- Wrap internal router state updates with `React.startTransition` if it exists ([#10438](https://github.com/remix-run/react-router/pull/10438))
2749
2750### Patch Changes
2751
2752- Updated dependencies:
2753 - `@remix-run/router@1.6.3`
2754
2755## 6.11.2
2756
2757### Patch Changes
2758
2759- Fix `basename` duplication in descendant `<Routes>` inside a `<RouterProvider>` ([#10492](https://github.com/remix-run/react-router/pull/10492))
2760- Updated dependencies:
2761 - `@remix-run/router@1.6.2`
2762
2763## 6.11.1
2764
2765### Patch Changes
2766
2767- Fix usage of `Component` API within descendant `<Routes>` ([#10434](https://github.com/remix-run/react-router/pull/10434))
2768- Fix bug when calling `useNavigate` from `<Routes>` inside a `<RouterProvider>` ([#10432](https://github.com/remix-run/react-router/pull/10432))
2769- Fix usage of `<Navigate>` in strict mode when using a data router ([#10435](https://github.com/remix-run/react-router/pull/10435))
2770- Updated dependencies:
2771 - `@remix-run/router@1.6.1`
2772
2773## 6.11.0
2774
2775### Patch Changes
2776
2777- Log loader/action errors to the console in dev for easier stack trace evaluation ([#10286](https://github.com/remix-run/react-router/pull/10286))
2778- Fix bug preventing rendering of descendant `<Routes>` when `RouterProvider` errors existed ([#10374](https://github.com/remix-run/react-router/pull/10374))
2779- Fix inadvertent re-renders when using `Component` instead of `element` on a route definition ([#10287](https://github.com/remix-run/react-router/pull/10287))
2780- Fix detection of `useNavigate` in the render cycle by setting the `activeRef` in a layout effect, allowing the `navigate` function to be passed to child components and called in a `useEffect` there. ([#10394](https://github.com/remix-run/react-router/pull/10394))
2781- Switched from `useSyncExternalStore` to `useState` for internal `@remix-run/router` router state syncing in `<RouterProvider>`. We found some [subtle bugs](https://codesandbox.io/s/use-sync-external-store-loop-9g7b81) where router state updates got propagated _before_ other normal `useState` updates, which could lead to footguns in `useEffect` calls. ([#10377](https://github.com/remix-run/react-router/pull/10377), [#10409](https://github.com/remix-run/react-router/pull/10409))
2782- Allow `useRevalidator()` to resolve a loader-driven error boundary scenario ([#10369](https://github.com/remix-run/react-router/pull/10369))
2783- Avoid unnecessary unsubscribe/resubscribes on router state changes ([#10409](https://github.com/remix-run/react-router/pull/10409))
2784- When using a `RouterProvider`, `useNavigate`/`useSubmit`/`fetcher.submit` are now stable across location changes, since we can handle relative routing via the `@remix-run/router` instance and get rid of our dependence on `useLocation()`. When using `BrowserRouter`, these hooks remain unstable across location changes because they still rely on `useLocation()`. ([#10336](https://github.com/remix-run/react-router/pull/10336))
2785- Updated dependencies:
2786 - `@remix-run/router@1.6.0`
2787
2788## 6.10.0
2789
2790### Minor Changes
2791
2792- Added support for [**Future Flags**](https://reactrouter.com/v6/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
2793 - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
2794 - `useNavigation().formMethod` is lowercase
2795 - `useFetcher().formMethod` is lowercase
2796 - When `future.v7_normalizeFormMethod === true`:
2797 - `useNavigation().formMethod` is uppercase
2798 - `useFetcher().formMethod` is uppercase
2799
2800### Patch Changes
2801
2802- Fix route ID generation when using Fragments in `createRoutesFromElements` ([#10193](https://github.com/remix-run/react-router/pull/10193))
2803- Updated dependencies:
2804 - `@remix-run/router@1.5.0`
2805
2806## 6.9.0
2807
2808### Minor Changes
2809
2810- React Router now supports an alternative way to define your route `element` and `errorElement` fields as React Components instead of React Elements. You can instead pass a React Component to the new `Component` and `ErrorBoundary` fields if you choose. There is no functional difference between the two, so use whichever approach you prefer 😀. You shouldn't be defining both, but if you do `Component`/`ErrorBoundary` will "win". ([#10045](https://github.com/remix-run/react-router/pull/10045))
2811
2812 **Example JSON Syntax**
2813
2814 ```jsx
2815 // Both of these work the same:
2816 const elementRoutes = [{
2817 path: '/',
2818 element: <Home />,
2819 errorElement: <HomeError />,
2820 }]
2821
2822 const componentRoutes = [{
2823 path: '/',
2824 Component: Home,
2825 ErrorBoundary: HomeError,
2826 }]
2827
2828 function Home() { ... }
2829 function HomeError() { ... }
2830 ```
2831
2832 **Example JSX Syntax**
2833
2834 ```jsx
2835 // Both of these work the same:
2836 const elementRoutes = createRoutesFromElements(
2837 <Route path='/' element={<Home />} errorElement={<HomeError /> } />
2838 );
2839
2840 const componentRoutes = createRoutesFromElements(
2841 <Route path='/' Component={Home} ErrorBoundary={HomeError} />
2842 );
2843
2844 function Home() { ... }
2845 function HomeError() { ... }
2846 ```
2847
2848- **Introducing Lazy Route Modules!** ([#10045](https://github.com/remix-run/react-router/pull/10045))
2849
2850 In order to keep your application bundles small and support code-splitting of your routes, we've introduced a new `lazy()` route property. This is an async function that resolves the non-route-matching portions of your route definition (`loader`, `action`, `element`/`Component`, `errorElement`/`ErrorBoundary`, `shouldRevalidate`, `handle`).
2851
2852 Lazy routes are resolved on initial load and during the `loading` or `submitting` phase of a navigation or fetcher call. You cannot lazily define route-matching properties (`path`, `index`, `children`) since we only execute your lazy route functions after we've matched known routes.
2853
2854 Your `lazy` functions will typically return the result of a dynamic import.
2855
2856 ```jsx
2857 // In this example, we assume most folks land on the homepage so we include that
2858 // in our critical-path bundle, but then we lazily load modules for /a and /b so
2859 // they don't load until the user navigates to those routes
2860 let routes = createRoutesFromElements(
2861 <Route path="/" element={<Layout />}>
2862 <Route index element={<Home />} />
2863 <Route path="a" lazy={() => import("./a")} />
2864 <Route path="b" lazy={() => import("./b")} />
2865 </Route>,
2866 );
2867 ```
2868
2869 Then in your lazy route modules, export the properties you want defined for the route:
2870
2871 ```jsx
2872 export async function loader({ request }) {
2873 let data = await fetchData(request);
2874 return json(data);
2875 }
2876
2877 // Export a `Component` directly instead of needing to create a React Element from it
2878 export function Component() {
2879 let data = useLoaderData();
2880
2881 return (
2882 <>
2883 <h1>You made it!</h1>
2884 <p>{data}</p>
2885 </>
2886 );
2887 }
2888
2889 // Export an `ErrorBoundary` directly instead of needing to create a React Element from it
2890 export function ErrorBoundary() {
2891 let error = useRouteError();
2892 return isRouteErrorResponse(error) ? (
2893 <h1>
2894 {error.status} {error.statusText}
2895 </h1>
2896 ) : (
2897 <h1>{error.message || error}</h1>
2898 );
2899 }
2900 ```
2901
2902 An example of this in action can be found in the [`examples/lazy-loading-router-provider`](https://github.com/remix-run/react-router/tree/main/examples/lazy-loading-router-provider) directory of the repository.
2903
2904 🙌 Huge thanks to @rossipedia for the [Initial Proposal](https://github.com/remix-run/react-router/discussions/9826) and [POC Implementation](https://github.com/remix-run/react-router/pull/9830).
2905
2906- Updated dependencies:
2907 - `@remix-run/router@1.4.0`
2908
2909### Patch Changes
2910
2911- Fix `generatePath` incorrectly applying parameters in some cases ([#10078](https://github.com/remix-run/react-router/pull/10078))
2912- Improve memoization for context providers to avoid unnecessary re-renders ([#9983](https://github.com/remix-run/react-router/pull/9983))
2913
2914## 6.8.2
2915
2916### Patch Changes
2917
2918- Updated dependencies:
2919 - `@remix-run/router@1.3.3`
2920
2921## 6.8.1
2922
2923### Patch Changes
2924
2925- Remove inaccurate console warning for POP navigations and update active blocker logic ([#10030](https://github.com/remix-run/react-router/pull/10030))
2926- Updated dependencies:
2927 - `@remix-run/router@1.3.2`
2928
2929## 6.8.0
2930
2931### Patch Changes
2932
2933- Updated dependencies:
2934 - `@remix-run/router@1.3.1`
2935
2936## 6.7.0
2937
2938### Minor Changes
2939
2940- Add `unstable_useBlocker` hook for blocking navigations within the app's location origin ([#9709](https://github.com/remix-run/react-router/pull/9709))
2941
2942### Patch Changes
2943
2944- Fix `generatePath` when optional params are present ([#9764](https://github.com/remix-run/react-router/pull/9764))
2945- Update `<Await>` to accept `ReactNode` as children function return result ([#9896](https://github.com/remix-run/react-router/pull/9896))
2946- Updated dependencies:
2947 - `@remix-run/router@1.3.0`
2948
2949## 6.6.2
2950
2951### Patch Changes
2952
2953- Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
2954
2955## 6.6.1
2956
2957### Patch Changes
2958
2959- Updated dependencies:
2960 - `@remix-run/router@1.2.1`
2961
2962## 6.6.0
2963
2964### Patch Changes
2965
2966- Prevent `useLoaderData` usage in `errorElement` ([#9735](https://github.com/remix-run/react-router/pull/9735))
2967- Updated dependencies:
2968 - `@remix-run/router@1.2.0`
2969
2970## 6.5.0
2971
2972This release introduces support for [Optional Route Segments](https://github.com/remix-run/react-router/issues/9546). 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.
2973
2974**Optional Params Examples**
2975
2976- `<Route path=":lang?/about>` will match:
2977 - `/:lang/about`
2978 - `/about`
2979- `<Route path="/multistep/:widget1?/widget2?/widget3?">` will match:
2980 - `/multistep`
2981 - `/multistep/:widget1`
2982 - `/multistep/:widget1/:widget2`
2983 - `/multistep/:widget1/:widget2/:widget3`
2984
2985**Optional Static Segment Example**
2986
2987- `<Route path="/home?">` will match:
2988 - `/`
2989 - `/home`
2990- `<Route path="/fr?/about">` will match:
2991 - `/about`
2992 - `/fr/about`
2993
2994### Minor Changes
2995
2996- Allows optional routes and optional static segments ([#9650](https://github.com/remix-run/react-router/pull/9650))
2997
2998### Patch Changes
2999
3000- 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: ([#9506](https://github.com/remix-run/react-router/pull/9506))
3001
3002```jsx
3003// Old behavior at URL /prefix-123
3004<Route path="prefix-:id" element={<Comp /> }>
3005
3006function Comp() {
3007 let params = useParams(); // { id: '123' }
3008 let id = params.id; // "123"
3009 ...
3010}
3011
3012// New behavior at URL /prefix-123
3013<Route path=":id" element={<Comp /> }>
3014
3015function Comp() {
3016 let params = useParams(); // { id: 'prefix-123' }
3017 let id = params.id.replace(/^prefix-/, ''); // "123"
3018 ...
3019}
3020```
3021
3022- Updated dependencies:
3023 - `@remix-run/router@1.1.0`
3024
3025## 6.4.5
3026
3027### Patch Changes
3028
3029- Updated dependencies:
3030 - `@remix-run/router@1.0.5`
3031
3032## 6.4.4
3033
3034### Patch Changes
3035
3036- Updated dependencies:
3037 - `@remix-run/router@1.0.4`
3038
3039## 6.4.3
3040
3041### Patch Changes
3042
3043- `useRoutes` should be able to return `null` when passing `locationArg` ([#9485](https://github.com/remix-run/react-router/pull/9485))
3044- fix `initialEntries` type in `createMemoryRouter` ([#9498](https://github.com/remix-run/react-router/pull/9498))
3045- Updated dependencies:
3046 - `@remix-run/router@1.0.3`
3047
3048## 6.4.2
3049
3050### Patch Changes
3051
3052- Fix `IndexRouteObject` and `NonIndexRouteObject` types to make `hasErrorElement` optional ([#9394](https://github.com/remix-run/react-router/pull/9394))
3053- Enhance console error messages for invalid usage of data router hooks ([#9311](https://github.com/remix-run/react-router/pull/9311))
3054- If an index route has children, it will result in a runtime error. We have strengthened our `RouteObject`/`RouteProps` types to surface the error in TypeScript. ([#9366](https://github.com/remix-run/react-router/pull/9366))
3055- Updated dependencies:
3056 - `@remix-run/router@1.0.2`
3057
3058## 6.4.1
3059
3060### Patch Changes
3061
3062- Preserve state from `initialEntries` ([#9288](https://github.com/remix-run/react-router/pull/9288))
3063- Updated dependencies:
3064 - `@remix-run/router@1.0.1`
3065
3066## 6.4.0
3067
3068Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the [docs](https://reactrouter.com), especially the [feature overview](https://reactrouter.com/en/6.4.0/start/overview) and the [tutorial](https://reactrouter.com/en/6.4.0/start/tutorial).
3069
3070**New APIs**
3071
3072- Create your router with `createMemoryRouter`
3073- Render your router with `<RouterProvider>`
3074- Load data with a Route `loader` and mutate with a Route `action`
3075- Handle errors with Route `errorElement`
3076- Defer non-critical data with `defer` and `Await`
3077
3078**Bug Fixes**
3079
3080- Path resolution is now trailing slash agnostic (#8861)
3081- `useLocation` returns the scoped location inside a `<Routes location>` component (#9094)
3082
3083**Updated Dependencies**
3084
3085- `@remix-run/router@1.0.0`