react-router 8.5.0 → 8.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -1
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +1 -1
- package/dist/development/index-react-server.d.ts +50 -396
- package/dist/development/index-react-server.js +43 -15
- package/dist/development/index.js +1 -1
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/await.js +58 -0
- package/dist/development/lib/components.d.ts +41 -5
- package/dist/development/lib/components.js +62 -4
- package/dist/development/lib/context.d.ts +2 -2
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.js +1 -1
- package/dist/development/lib/dom/server.js +1 -1
- package/dist/development/lib/dom/ssr/components.js +1 -1
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/development/lib/dom/ssr/fallback.js +1 -1
- package/dist/development/lib/dom/ssr/fog-of-war.js +12 -3
- package/dist/development/lib/dom/ssr/hydration.js +1 -1
- package/dist/development/lib/dom/ssr/invariant.js +1 -1
- package/dist/development/lib/dom/ssr/links.js +1 -1
- package/dist/development/lib/dom/ssr/markup.js +1 -1
- package/dist/development/lib/dom/ssr/route-discovery.d.ts +2 -2
- package/dist/development/lib/dom/ssr/route-discovery.js +3 -3
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/development/lib/dom/ssr/routes.js +1 -1
- package/dist/development/lib/dom/ssr/server.js +1 -1
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +1 -1
- package/dist/development/lib/dom/ssr/single-fetch.js +7 -7
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +2 -2
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.d.ts +0 -3
- package/dist/development/lib/hooks.js +5 -6
- package/dist/development/lib/href.js +1 -1
- package/dist/development/lib/router/history.js +1 -1
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/development/lib/router/matcher.js +6 -1
- package/dist/development/lib/router/navigation.js +1 -1
- package/dist/development/lib/router/router.d.ts +2 -0
- package/dist/development/lib/router/router.js +58 -28
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +7 -0
- package/dist/development/lib/router/utils.js +1 -1
- package/dist/development/lib/rsc/browser.js +3 -3
- package/dist/development/lib/rsc/errorBoundaries.js +1 -1
- package/dist/development/lib/rsc/html-stream/browser.js +1 -1
- package/dist/development/lib/rsc/html-stream/server.js +1 -1
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.ssr.js +1 -1
- package/dist/development/lib/server-runtime/cookies.js +1 -1
- package/dist/development/lib/server-runtime/crypto.js +1 -1
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +1 -1
- package/dist/development/lib/server-runtime/entry.js +1 -1
- package/dist/development/lib/server-runtime/errors.js +1 -1
- package/dist/development/lib/server-runtime/headers.js +1 -1
- package/dist/development/lib/server-runtime/invariant.js +1 -1
- package/dist/development/lib/server-runtime/mode.js +1 -1
- package/dist/development/lib/server-runtime/routeMatching.js +1 -1
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +13 -5
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.js +2 -2
- package/dist/development/lib/server-runtime/single-fetch.js +1 -1
- package/dist/development/lib/server-runtime/urls.js +1 -1
- package/dist/development/lib/server-runtime/warnings.js +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/route-pattern.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/index-react-server-client.js +1 -1
- package/dist/production/index-react-server.d.ts +50 -396
- package/dist/production/index-react-server.js +43 -15
- package/dist/production/index.js +1 -1
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/await.js +58 -0
- package/dist/production/lib/components.d.ts +41 -5
- package/dist/production/lib/components.js +62 -4
- package/dist/production/lib/context.d.ts +2 -2
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.js +1 -1
- package/dist/production/lib/dom/server.js +1 -1
- package/dist/production/lib/dom/ssr/components.js +1 -1
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/production/lib/dom/ssr/fallback.js +1 -1
- package/dist/production/lib/dom/ssr/fog-of-war.js +12 -3
- package/dist/production/lib/dom/ssr/hydration.js +1 -1
- package/dist/production/lib/dom/ssr/invariant.js +1 -1
- package/dist/production/lib/dom/ssr/links.js +1 -1
- package/dist/production/lib/dom/ssr/markup.js +1 -1
- package/dist/production/lib/dom/ssr/route-discovery.d.ts +2 -2
- package/dist/production/lib/dom/ssr/route-discovery.js +3 -3
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/production/lib/dom/ssr/routes.js +1 -1
- package/dist/production/lib/dom/ssr/server.js +1 -1
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +1 -1
- package/dist/production/lib/dom/ssr/single-fetch.js +7 -7
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +2 -2
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.d.ts +0 -3
- package/dist/production/lib/hooks.js +5 -6
- package/dist/production/lib/href.js +1 -1
- package/dist/production/lib/router/history.js +1 -1
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/production/lib/router/matcher.js +6 -1
- package/dist/production/lib/router/navigation.js +1 -1
- package/dist/production/lib/router/router.d.ts +2 -0
- package/dist/production/lib/router/router.js +58 -28
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +7 -0
- package/dist/production/lib/router/utils.js +1 -1
- package/dist/production/lib/rsc/browser.js +3 -3
- package/dist/production/lib/rsc/errorBoundaries.js +1 -1
- package/dist/production/lib/rsc/html-stream/browser.js +1 -1
- package/dist/production/lib/rsc/html-stream/server.js +1 -1
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.ssr.js +1 -1
- package/dist/production/lib/server-runtime/cookies.js +1 -1
- package/dist/production/lib/server-runtime/crypto.js +1 -1
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +1 -1
- package/dist/production/lib/server-runtime/entry.js +1 -1
- package/dist/production/lib/server-runtime/errors.js +1 -1
- package/dist/production/lib/server-runtime/headers.js +1 -1
- package/dist/production/lib/server-runtime/invariant.js +1 -1
- package/dist/production/lib/server-runtime/mode.js +1 -1
- package/dist/production/lib/server-runtime/routeMatching.js +1 -1
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +13 -5
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.js +2 -2
- package/dist/production/lib/server-runtime/single-fetch.js +1 -1
- package/dist/production/lib/server-runtime/urls.js +1 -1
- package/dist/production/lib/server-runtime/warnings.js +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/route-pattern.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/explanation/backend-for-frontend.md +0 -3
- package/docs/explanation/code-splitting.md +0 -3
- package/docs/explanation/concurrency.md +0 -3
- package/docs/explanation/hot-module-replacement.md +0 -3
- package/docs/explanation/lazy-route-discovery.md +0 -3
- package/docs/explanation/progressive-enhancement.md +0 -3
- package/docs/explanation/race-conditions.md +0 -3
- package/docs/explanation/react-transitions.md +0 -3
- package/docs/explanation/sessions-and-cookies.md +1 -1
- package/docs/explanation/state-management.md +0 -3
- package/docs/explanation/styling.md +0 -3
- package/docs/explanation/type-safety.md +0 -3
- package/docs/how-to/accessibility.md +0 -6
- package/docs/how-to/client-data.md +0 -3
- package/docs/how-to/data-strategy.md +0 -3
- package/docs/how-to/error-boundary.md +0 -3
- package/docs/how-to/error-reporting.md +0 -3
- package/docs/how-to/fetchers.md +0 -3
- package/docs/how-to/file-route-conventions.md +0 -3
- package/docs/how-to/file-uploads.md +0 -3
- package/docs/how-to/form-validation.md +0 -3
- package/docs/how-to/headers.md +0 -3
- package/docs/how-to/instrumentation.md +0 -3
- package/docs/how-to/middleware.md +6 -3
- package/docs/how-to/navigation-blocking.md +0 -3
- package/docs/how-to/optimize-revalidation.md +0 -3
- package/docs/how-to/pre-rendering.md +0 -3
- package/docs/how-to/presets.md +0 -3
- package/docs/how-to/react-server-components.md +0 -3
- package/docs/how-to/resource-routes.md +0 -3
- package/docs/how-to/route-discovery.md +4 -2
- package/docs/how-to/route-module-type-safety.md +0 -3
- package/docs/how-to/security.md +0 -3
- package/docs/how-to/server-bundles.md +0 -3
- package/docs/how-to/spa.md +0 -3
- package/docs/how-to/status.md +0 -3
- package/docs/how-to/suspense.md +22 -6
- package/docs/how-to/using-handle.md +0 -3
- package/docs/how-to/view-transitions.md +0 -3
- package/docs/start/framework/data-loading.md +9 -0
- package/docs/upgrading/future.md +0 -12
- package/docs/upgrading/v7.md +3 -33
- package/package.json +1 -1
- package/dist/development/lib/dom/global.d.ts +0 -35
- package/dist/production/lib/dom/global.d.ts +0 -35
package/docs/upgrading/v7.md
CHANGED
|
@@ -13,9 +13,6 @@ We highly recommend you make a commit after each step and ship it instead of doi
|
|
|
13
13
|
|
|
14
14
|
[MODES: framework, data, declarative]
|
|
15
15
|
|
|
16
|
-
<br/>
|
|
17
|
-
<br/>
|
|
18
|
-
|
|
19
16
|
React Router v8 requires the following minimum versions. Update them before updating React Router to v8:
|
|
20
17
|
|
|
21
18
|
- `node@22.22+`
|
|
@@ -42,9 +39,6 @@ npm install react-router@7 @react-router/{dev,node,etc.}@7
|
|
|
42
39
|
|
|
43
40
|
[MODES: framework, data]
|
|
44
41
|
|
|
45
|
-
<br/>
|
|
46
|
-
<br/>
|
|
47
|
-
|
|
48
42
|
**Background**
|
|
49
43
|
|
|
50
44
|
Middleware allows you to run code before and after the [`Response`][Response] generation for the matched path. This enables common patterns like authentication, logging, error handling, and data preprocessing in a reusable way. Please see the [docs](../how-to/middleware) for more information.
|
|
@@ -86,9 +80,6 @@ If you're using the `context` parameter in `loader` and `action` functions, you
|
|
|
86
80
|
|
|
87
81
|
[MODES: framework]
|
|
88
82
|
|
|
89
|
-
<br/>
|
|
90
|
-
<br/>
|
|
91
|
-
|
|
92
83
|
**Background**
|
|
93
84
|
|
|
94
85
|
This feature enables splitting client-side route exports (`clientLoader`, `clientAction`, `clientMiddleware`, `HydrateFallback`) into separate chunks that can be loaded independently from the route component. This allows these exports to be fetched and executed while the component code is still downloading, improving performance for client-side data loading.
|
|
@@ -115,9 +106,6 @@ No code changes are required. This is an optimization feature that works automat
|
|
|
115
106
|
|
|
116
107
|
[MODES: framework]
|
|
117
108
|
|
|
118
|
-
<br/>
|
|
119
|
-
<br/>
|
|
120
|
-
|
|
121
109
|
**Background**
|
|
122
110
|
|
|
123
111
|
This enables support for the experimental Vite Environment API, which provides a more flexible and powerful way to configure Vite environments. This is only available when using Vite 6+.
|
|
@@ -173,9 +161,6 @@ See the [`node-custom-server` template][node-custom-server-template] for a compl
|
|
|
173
161
|
|
|
174
162
|
[MODES: framework]
|
|
175
163
|
|
|
176
|
-
<br/>
|
|
177
|
-
<br/>
|
|
178
|
-
|
|
179
164
|
**Background**
|
|
180
165
|
|
|
181
166
|
By default, React Router normalizes the `request.url` passed to your `loader`, `action`, and `middleware` functions by removing React Router's internal implementation details. Specifically, it removes `.data` suffixes and internal search parameters like `?index` and `?_routes`.
|
|
@@ -185,7 +170,7 @@ This flag eliminates that normalization and passes the raw HTTP `request` instan
|
|
|
185
170
|
- Reduces server-side overhead by eliminating multiple `new Request()` calls on the critical path
|
|
186
171
|
- Allows you to distinguish document from data requests in your handlers based on the presence of a `.data` suffix (useful for [observability] purposes)
|
|
187
172
|
|
|
188
|
-
If you were previously relying on the normalization of `request.url`, you can switch to use the new sibling `url` parameter which contains a `URL` instance
|
|
173
|
+
If you were previously relying on the normalization of `request.url`, you can switch to use the new sibling `url` parameter which contains a `URL` instance with React Router's internal implementation details removed.
|
|
189
174
|
|
|
190
175
|
👉 **Enable the Flag**
|
|
191
176
|
|
|
@@ -215,8 +200,8 @@ export async function loader({
|
|
|
215
200
|
}
|
|
216
201
|
}
|
|
217
202
|
|
|
218
|
-
// ✅ After: use `url`
|
|
219
|
-
// for
|
|
203
|
+
// ✅ After: use `url` with React Router's internal details removed
|
|
204
|
+
// and `request.url` for the original request URL
|
|
220
205
|
export async function loader({
|
|
221
206
|
request,
|
|
222
207
|
url,
|
|
@@ -236,9 +221,6 @@ export async function loader({
|
|
|
236
221
|
|
|
237
222
|
[MODES: framework]
|
|
238
223
|
|
|
239
|
-
<br/>
|
|
240
|
-
<br/>
|
|
241
|
-
|
|
242
224
|
**Background**
|
|
243
225
|
|
|
244
226
|
React Router serves Framework mode data requests from `.data` URLs. Previously, data requests for routes with and without trailing slashes could map to the same `.data` URL because trailing slashes were not considered during URL generation. This flag preserves trailing slash semantics for data request URLs to avoid ambiguity when your app distinguishes between trailing-slash and non-trailing-slash URLs.
|
|
@@ -293,9 +275,6 @@ The changes in this section are not controlled by future flags, but you can upda
|
|
|
293
275
|
|
|
294
276
|
[MODES: framework]
|
|
295
277
|
|
|
296
|
-
<br/>
|
|
297
|
-
<br/>
|
|
298
|
-
|
|
299
278
|
**Background**
|
|
300
279
|
|
|
301
280
|
React Router v8 removed deprecated `data` fields in favor of `loaderData` in a few places:
|
|
@@ -352,9 +331,6 @@ export default function Component({ matches, loaderData }: ComponentProps) {
|
|
|
352
331
|
|
|
353
332
|
[MODES: framework, data, declarative]
|
|
354
333
|
|
|
355
|
-
<br/>
|
|
356
|
-
<br/>
|
|
357
|
-
|
|
358
334
|
**Background**
|
|
359
335
|
|
|
360
336
|
React Router v8 removes the `react-router-dom` re-export package. In v8, you should import DOM-specific APIs from `react-router/dom` and everything else from `react-router`.
|
|
@@ -385,9 +361,6 @@ For DOM-specific APIs, import from `react-router/dom`:
|
|
|
385
361
|
|
|
386
362
|
[MODES: framework]
|
|
387
363
|
|
|
388
|
-
<br/>
|
|
389
|
-
<br/>
|
|
390
|
-
|
|
391
364
|
**Background**
|
|
392
365
|
|
|
393
366
|
React Router v8 removes the React Router Cloudflare dev proxy. Cloudflare projects should use [`@cloudflare/vite-plugin`][cloudflare-vite-plugin] instead.
|
|
@@ -415,9 +388,6 @@ export default defineConfig({
|
|
|
415
388
|
|
|
416
389
|
[MODES: framework]
|
|
417
390
|
|
|
418
|
-
<br/>
|
|
419
|
-
<br/>
|
|
420
|
-
|
|
421
391
|
**Background**
|
|
422
392
|
|
|
423
393
|
In v7, the `@react-router/architect` adapter uses `X-Forwarded-Host` when creating the `request`, falling back to the `Host` header. In React Router v8, the adapter uses `event.requestContext.domainName` by default, falling back to the `Host` header.
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { HydrationState, Router } from "../router/router.js";
|
|
3
|
-
import { RouteModules } from "./ssr/routeModules.js";
|
|
4
|
-
import { ServerHandoff } from "../server-runtime/serverHandoff.js";
|
|
5
|
-
import { AssetsManifest } from "./ssr/entry.js";
|
|
6
|
-
|
|
7
|
-
//#region lib/dom/global.d.ts
|
|
8
|
-
type WindowReactRouterContext = ServerHandoff & {
|
|
9
|
-
state: HydrationState;
|
|
10
|
-
stream: ReadableStream<Uint8Array> | undefined;
|
|
11
|
-
streamController: ReadableStreamDefaultController<Uint8Array>;
|
|
12
|
-
};
|
|
13
|
-
interface ViewTransition {
|
|
14
|
-
finished: Promise<void>;
|
|
15
|
-
ready: Promise<void>;
|
|
16
|
-
updateCallbackDone: Promise<void>;
|
|
17
|
-
skipTransition(): void;
|
|
18
|
-
}
|
|
19
|
-
declare global {
|
|
20
|
-
var __staticRouterHydrationData: HydrationState | undefined;
|
|
21
|
-
var __reactRouterVersion: string;
|
|
22
|
-
interface Document {
|
|
23
|
-
startViewTransition(cb: () => Promise<void> | void): ViewTransition;
|
|
24
|
-
}
|
|
25
|
-
var __reactRouterContext: WindowReactRouterContext | undefined;
|
|
26
|
-
var __reactRouterManifest: AssetsManifest | undefined;
|
|
27
|
-
var __reactRouterRouteModules: RouteModules | undefined;
|
|
28
|
-
var __reactRouterDataRouter: Router | undefined;
|
|
29
|
-
var __reactRouterHdrActive: boolean;
|
|
30
|
-
var $RefreshRuntime$: {
|
|
31
|
-
performReactRefresh: () => void;
|
|
32
|
-
} | undefined;
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { WindowReactRouterContext };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { HydrationState, Router } from "../router/router.js";
|
|
3
|
-
import { RouteModules } from "./ssr/routeModules.js";
|
|
4
|
-
import { ServerHandoff } from "../server-runtime/serverHandoff.js";
|
|
5
|
-
import { AssetsManifest } from "./ssr/entry.js";
|
|
6
|
-
|
|
7
|
-
//#region lib/dom/global.d.ts
|
|
8
|
-
type WindowReactRouterContext = ServerHandoff & {
|
|
9
|
-
state: HydrationState;
|
|
10
|
-
stream: ReadableStream<Uint8Array> | undefined;
|
|
11
|
-
streamController: ReadableStreamDefaultController<Uint8Array>;
|
|
12
|
-
};
|
|
13
|
-
interface ViewTransition {
|
|
14
|
-
finished: Promise<void>;
|
|
15
|
-
ready: Promise<void>;
|
|
16
|
-
updateCallbackDone: Promise<void>;
|
|
17
|
-
skipTransition(): void;
|
|
18
|
-
}
|
|
19
|
-
declare global {
|
|
20
|
-
var __staticRouterHydrationData: HydrationState | undefined;
|
|
21
|
-
var __reactRouterVersion: string;
|
|
22
|
-
interface Document {
|
|
23
|
-
startViewTransition(cb: () => Promise<void> | void): ViewTransition;
|
|
24
|
-
}
|
|
25
|
-
var __reactRouterContext: WindowReactRouterContext | undefined;
|
|
26
|
-
var __reactRouterManifest: AssetsManifest | undefined;
|
|
27
|
-
var __reactRouterRouteModules: RouteModules | undefined;
|
|
28
|
-
var __reactRouterDataRouter: Router | undefined;
|
|
29
|
-
var __reactRouterHdrActive: boolean;
|
|
30
|
-
var $RefreshRuntime$: {
|
|
31
|
-
performReactRefresh: () => void;
|
|
32
|
-
} | undefined;
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { WindowReactRouterContext };
|