react-router 7.17.0 → 7.18.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 +19 -1
- package/dist/development/{browser-D3uq9sI1.d.ts → browser-B2PdsXXH.d.ts} +2 -2
- package/dist/development/{browser-CGcs-0pD.d.mts → browser-DBmQ1yAR.d.mts} +2 -2
- package/dist/development/{chunk-PBLBZ3QU.js → chunk-EVX4J2F5.js} +7 -7
- package/dist/development/{chunk-PULC7NLK.js → chunk-G5KIBF6U.js} +111 -108
- package/dist/{production/chunk-5TQZEVD5.mjs → development/chunk-IJF3QNGC.mjs} +45 -113
- package/dist/development/{chunk-6CSD65Y2.mjs → chunk-KS7C4IRE.mjs} +115 -38
- package/dist/development/{chunk-KFNXW4AL.js → chunk-SA4DP3SF.js} +113 -35
- package/dist/{production/context-CmHpk1Ws.d.mts → development/context-CeD5LmaF.d.mts} +12 -4
- package/dist/{production/data-D4xhSy90.d.ts → development/data-CjO11-hU.d.ts} +9 -1
- package/dist/development/{data-U8FS-wNn.d.mts → data-DEjBmEfD.d.mts} +9 -1
- package/dist/development/dom-export.d.mts +3 -3
- package/dist/development/dom-export.d.ts +3 -3
- package/dist/development/dom-export.js +46 -44
- package/dist/development/dom-export.mjs +23 -21
- package/dist/development/{index-react-server-client-CwU9bE5R.d.ts → index-react-server-client-3ykjivgQ.d.ts} +29 -7
- package/dist/development/{index-react-server-client-DPrDrCew.d.mts → index-react-server-client-CACgcj2J.d.mts} +19 -5
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +3 -3
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +9 -1
- package/dist/development/index-react-server.d.ts +9 -1
- package/dist/development/index-react-server.js +144 -121
- package/dist/development/index-react-server.mjs +143 -120
- package/dist/development/index.d.mts +15 -14
- package/dist/development/index.d.ts +15 -14
- package/dist/development/index.js +137 -205
- package/dist/development/index.mjs +3 -5
- package/dist/{production/instrumentation-1q4YhLGP.d.ts → development/instrumentation-Dkmpzd13.d.ts} +2 -2
- package/dist/development/lib/types/internal.d.mts +2 -2
- package/dist/development/lib/types/internal.d.ts +2 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-CqK96Zfk.d.mts → register-CmkRspdl.d.mts} +1 -1
- package/dist/development/{register-CNAx3TXj.d.ts → register-roq_0qYo.d.ts} +1 -1
- package/dist/production/{browser-D3uq9sI1.d.ts → browser-B2PdsXXH.d.ts} +2 -2
- package/dist/production/{browser-CGcs-0pD.d.mts → browser-DBmQ1yAR.d.mts} +2 -2
- package/dist/{development/chunk-ASILSGTR.mjs → production/chunk-3MA7PLKB.mjs} +45 -113
- package/dist/production/{chunk-OSYEOCBT.mjs → chunk-3WDNQUW5.mjs} +115 -38
- package/dist/production/{chunk-CTIXC7EV.js → chunk-GOIER6ML.js} +7 -7
- package/dist/production/{chunk-RTRY3JFT.js → chunk-IEF7VMTA.js} +113 -35
- package/dist/production/{chunk-EN242BO4.js → chunk-WICLSFKL.js} +111 -108
- package/dist/{development/context-CmHpk1Ws.d.mts → production/context-CeD5LmaF.d.mts} +12 -4
- package/dist/{development/data-D4xhSy90.d.ts → production/data-CjO11-hU.d.ts} +9 -1
- package/dist/production/{data-U8FS-wNn.d.mts → data-DEjBmEfD.d.mts} +9 -1
- package/dist/production/dom-export.d.mts +3 -3
- package/dist/production/dom-export.d.ts +3 -3
- package/dist/production/dom-export.js +46 -44
- package/dist/production/dom-export.mjs +23 -21
- package/dist/production/{index-react-server-client-CwU9bE5R.d.ts → index-react-server-client-3ykjivgQ.d.ts} +29 -7
- package/dist/production/{index-react-server-client-DPrDrCew.d.mts → index-react-server-client-CACgcj2J.d.mts} +19 -5
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +3 -3
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +9 -1
- package/dist/production/index-react-server.d.ts +9 -1
- package/dist/production/index-react-server.js +144 -121
- package/dist/production/index-react-server.mjs +143 -120
- package/dist/production/index.d.mts +15 -14
- package/dist/production/index.d.ts +15 -14
- package/dist/production/index.js +137 -205
- package/dist/production/index.mjs +3 -5
- package/dist/{development/instrumentation-1q4YhLGP.d.ts → production/instrumentation-Dkmpzd13.d.ts} +2 -2
- package/dist/production/lib/types/internal.d.mts +2 -2
- package/dist/production/lib/types/internal.d.ts +2 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{register-CqK96Zfk.d.mts → register-CmkRspdl.d.mts} +1 -1
- package/dist/production/{register-CNAx3TXj.d.ts → register-roq_0qYo.d.ts} +1 -1
- package/docs/explanation/type-safety.md +1 -1
- package/docs/how-to/headers.md +2 -1
- package/docs/how-to/security.md +8 -6
- package/docs/how-to/status.md +1 -1
- package/docs/start/data/installation.md +4 -0
- package/docs/start/framework/deploying.md +4 -0
- package/docs/upgrading/future.md +222 -12
- package/docs/upgrading/remix.md +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.18.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -21,14 +21,13 @@ import {
|
|
|
21
21
|
createRoutesStub,
|
|
22
22
|
createSession,
|
|
23
23
|
createSessionStorage,
|
|
24
|
-
deserializeErrors,
|
|
25
24
|
getHydrationData,
|
|
26
25
|
href,
|
|
27
26
|
isCookie,
|
|
28
27
|
isSession,
|
|
29
28
|
routeRSCServerRequest,
|
|
30
29
|
setDevServerHooks
|
|
31
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-3MA7PLKB.mjs";
|
|
32
31
|
import {
|
|
33
32
|
Action,
|
|
34
33
|
Await,
|
|
@@ -142,7 +141,7 @@ import {
|
|
|
142
141
|
withComponentProps,
|
|
143
142
|
withErrorBoundaryProps,
|
|
144
143
|
withHydrateFallbackProps
|
|
145
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-3WDNQUW5.mjs";
|
|
146
145
|
export {
|
|
147
146
|
Await,
|
|
148
147
|
BrowserRouter,
|
|
@@ -194,7 +193,6 @@ export {
|
|
|
194
193
|
createMemoryHistory as UNSAFE_createMemoryHistory,
|
|
195
194
|
createRouter as UNSAFE_createRouter,
|
|
196
195
|
decodeViaTurboStream as UNSAFE_decodeViaTurboStream,
|
|
197
|
-
deserializeErrors as UNSAFE_deserializeErrors,
|
|
198
196
|
getHydrationData as UNSAFE_getHydrationData,
|
|
199
197
|
getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction,
|
|
200
198
|
getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy,
|
package/dist/{development/instrumentation-1q4YhLGP.d.ts → production/instrumentation-Dkmpzd13.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as RouteObject, f as History, g as MaybePromise, c as RouterContextProvider, h as MapRoutePropertiesFunction, i as Action, L as Location, D as DataRouteMatch, j as Submission, k as RouteData, l as DataStrategyFunction, m as PatchRoutesOnNavigationFunction, n as DataRouteObject, o as RouteBranch, p as RouteManifest, U as UIMatch, T as To, q as HTMLFormMethod, F as FormEncType, r as Path, s as LoaderFunctionArgs, t as MiddlewareEnabled, u as AppLoadContext } from './data-
|
|
1
|
+
import { e as RouteObject, f as History, g as MaybePromise, c as RouterContextProvider, h as MapRoutePropertiesFunction, i as Action, L as Location, D as DataRouteMatch, j as Submission, k as RouteData, l as DataStrategyFunction, m as PatchRoutesOnNavigationFunction, n as DataRouteObject, o as RouteBranch, p as RouteManifest, U as UIMatch, T as To, q as HTMLFormMethod, F as FormEncType, r as Path, s as LoaderFunctionArgs, t as MiddlewareEnabled, u as AppLoadContext } from './data-CjO11-hU.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A Router instance manages all navigation and data loading/mutations
|
|
@@ -712,4 +712,4 @@ type RequestHandlerInstrumentationInfo = Readonly<{
|
|
|
712
712
|
context: ReadonlyContext | undefined;
|
|
713
713
|
}>;
|
|
714
714
|
|
|
715
|
-
export { type BlockerFunction as B, type ClientInstrumentation as C, type Fetcher as F, type GetScrollPositionFunction as G, type HydrationState as H, type InstrumentRequestHandlerFunction as I, type NavigationStates as N, type RouterInit as R, type StaticHandler as S, type Router as a, type Blocker as b, type RelativeRoutingType as c, type
|
|
715
|
+
export { type BlockerFunction as B, type ClientInstrumentation as C, type Fetcher as F, type GetScrollPositionFunction as G, type HydrationState as H, type InstrumentRequestHandlerFunction as I, type NavigationStates as N, type RouterInit as R, type StaticHandler as S, type Router as a, type Blocker as b, type RelativeRoutingType as c, type GetScrollRestorationKeyFunction as d, type StaticHandlerContext as e, type Navigation as f, type RouterState as g, type RouterSubscriber as h, type RouterNavigateOptions as i, type RouterFetchOptions as j, type RevalidationState as k, type ServerInstrumentation as l, type InstrumentRouterFunction as m, type InstrumentRouteFunction as n, type InstrumentationHandlerResult as o, IDLE_NAVIGATION as p, IDLE_FETCHER as q, IDLE_BLOCKER as r, createRouter as s, type FutureConfig as t, type CreateStaticHandlerOptions as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteModule, e as LinkDescriptor, L as Location, F as Func, f as Pretty, g as MetaDescriptor, G as GetLoaderData, h as ServerDataFunctionArgs, i as MiddlewareNextFunction, j as ClientDataFunctionArgs, D as DataStrategyResult, k as ServerDataFrom, N as Normalize, l as GetActionData } from '../../data-
|
|
2
|
-
import { R as RouteFiles, P as Pages } from '../../register-
|
|
1
|
+
import { R as RouteModule, e as LinkDescriptor, L as Location, F as Func, f as Pretty, g as MetaDescriptor, G as GetLoaderData, h as ServerDataFunctionArgs, i as MiddlewareNextFunction, j as ClientDataFunctionArgs, D as DataStrategyResult, k as ServerDataFrom, N as Normalize, l as GetActionData } from '../../data-DEjBmEfD.mjs';
|
|
2
|
+
import { R as RouteFiles, P as Pages } from '../../register-CmkRspdl.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteModule, v as LinkDescriptor, L as Location, w as Func, x as Pretty, y as MetaDescriptor, G as GetLoaderData, z as ServerDataFunctionArgs, B as MiddlewareNextFunction, E as ClientDataFunctionArgs, I as DataStrategyResult, J as ServerDataFrom, N as Normalize, K as GetActionData } from '../../data-
|
|
2
|
-
import { R as RouteFiles, P as Pages } from '../../register-
|
|
1
|
+
import { R as RouteModule, v as LinkDescriptor, L as Location, w as Func, x as Pretty, y as MetaDescriptor, G as GetLoaderData, z as ServerDataFunctionArgs, B as MiddlewareNextFunction, E as ClientDataFunctionArgs, I as DataStrategyResult, J as ServerDataFrom, N as Normalize, K as GetActionData } from '../../data-CjO11-hU.js';
|
|
2
|
+
import { R as RouteFiles, P as Pages } from '../../register-roq_0qYo.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -50,7 +50,7 @@ React Router's type generation executes your route config (`app/routes.ts` by de
|
|
|
50
50
|
It then generates a `+types/<route file>.d.ts` for each route within a special `.react-router/types/` directory.
|
|
51
51
|
With [`rootDirs` configured][route-module-type-safety], TypeScript can import these generated files as if they were right next to their corresponding route modules.
|
|
52
52
|
|
|
53
|
-
For a deeper dive into some of the design decisions, check out our [type inference decision doc](https://github.com/remix-run/react-router/blob/
|
|
53
|
+
For a deeper dive into some of the design decisions, check out our [type inference decision doc](https://github.com/remix-run/react-router/blob/main/decisions/0012-type-inference.md).
|
|
54
54
|
|
|
55
55
|
[route-module-type-safety]: ../how-to/route-module-type-safety
|
|
56
56
|
|
package/docs/how-to/headers.md
CHANGED
|
@@ -110,7 +110,8 @@ The easiest way is to simply append to the parent headers. This avoids overwriti
|
|
|
110
110
|
```tsx
|
|
111
111
|
export function headers({ parentHeaders }: HeadersArgs) {
|
|
112
112
|
parentHeaders.append(
|
|
113
|
-
"Permissions-Policy
|
|
113
|
+
"Permissions-Policy",
|
|
114
|
+
"geolocation=()",
|
|
114
115
|
);
|
|
115
116
|
return parentHeaders;
|
|
116
117
|
}
|
package/docs/how-to/security.md
CHANGED
|
@@ -13,15 +13,17 @@ This is by no means a comprehensive guide, but React Router provides features to
|
|
|
13
13
|
|
|
14
14
|
## `Content-Security-Policy`
|
|
15
15
|
|
|
16
|
-
If you are implementing a [Content-Security-Policy (CSP)][csp] in your application, specifically one using the `unsafe-inline` directive, you will need to specify a [`nonce`][nonce] attribute on the inline `<script>` elements rendered in your HTML.
|
|
16
|
+
If you are implementing a [Content-Security-Policy (CSP)][csp] in your application, specifically one using the `unsafe-inline` directive, you will need to specify a [`nonce`][nonce] attribute on the inline `<script>` elements rendered in your HTML.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- [`<ServerRouter nonce>`][serverrouter]
|
|
21
|
-
-
|
|
22
|
-
-
|
|
18
|
+
Add a nonce to these two spots in [`entry.server.tsx`][entryserver]:
|
|
19
|
+
|
|
20
|
+
- The [`<ServerRouter nonce>`][serverrouter] prop
|
|
21
|
+
- This will be proxied along through React Context and used for other Framework Mode components that output `nonce`-aware elements, including [`<Scripts>`][scripts], [`<ScrollRestoration>`][scrollrestoration]
|
|
22
|
+
- If those components specify their own `nonce` prop, it will override the `ServerRouter` value
|
|
23
|
+
- The `nonce` options of [`renderToPipeableStream`][renderToPipeableStream]/[`renderToReadableStream`][renderToReadableStream]
|
|
23
24
|
|
|
24
25
|
[csp]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP
|
|
26
|
+
[entryserver]: ../api/framework-conventions/entry.server.tsx
|
|
25
27
|
[nonce]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
|
|
26
28
|
[renderToPipeableStream]: https://react.dev/reference/react-dom/server/renderToPipeableStream
|
|
27
29
|
[renderToReadableStream]: https://react.dev/reference/react-dom/server/renderToReadableStream
|
package/docs/how-to/status.md
CHANGED
|
@@ -54,7 +54,7 @@ export async function loader({ params }: Route.ActionArgs) {
|
|
|
54
54
|
let project = await fakeDb.getProject(params.id);
|
|
55
55
|
if (!project) {
|
|
56
56
|
// throw to ErrorBoundary
|
|
57
|
-
throw data(
|
|
57
|
+
throw data("Not Found", { status: 404 });
|
|
58
58
|
}
|
|
59
59
|
return project;
|
|
60
60
|
}
|
|
@@ -47,6 +47,10 @@ ReactDOM.createRoot(root).render(
|
|
|
47
47
|
);
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
<docs-info>Data Routers should not be held in React state. You should create your router
|
|
51
|
+
once outside of the React tree and pass it to `<RouterProvider>`. You can use
|
|
52
|
+
`patchRoutesOnNavigation` to add additional routes programmatically.</docs-info>
|
|
53
|
+
|
|
50
54
|
---
|
|
51
55
|
|
|
52
56
|
Next: [Routing](./routing)
|
|
@@ -94,3 +94,7 @@ Netlify maintains their own template for React Router. Checkout the [Netlify Gui
|
|
|
94
94
|
### EdgeOne Pages
|
|
95
95
|
|
|
96
96
|
EdgeOne Pages maintains their own template for React Router. Checkout the [EdgeOne Pages Guide](https://pages.edgeone.ai/document/framework-react-router) for more information.
|
|
97
|
+
|
|
98
|
+
### DeployHQ
|
|
99
|
+
|
|
100
|
+
DeployHQ maintains their own guide for deploying React Router v7 to your own server. Checkout the [DeployHQ Guide](https://www.deployhq.com/guides/deploy-react-router-from-github) for more information.
|
package/docs/upgrading/future.md
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: Future
|
|
2
|
+
title: Future Changes
|
|
3
3
|
order: 1
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Future
|
|
6
|
+
# Future Changes
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
We try our best to keep major version upgrades simple and boring through the use of opt-in APIs and [Future Flags][api-development-strategy]. Future flags are used to gate breaking changes that don't otherwise have a good call-site opt-in strategy. By adopting all opt-in APIs and future flags, you should be able to upgrade to the next major version of React Router with minimal changes.
|
|
9
9
|
|
|
10
10
|
We highly recommend you make a commit after each step and ship it instead of doing everything all at once. Most flags can be adopted in any order, with exceptions noted below.
|
|
11
11
|
|
|
12
|
+
## Minimum Versions
|
|
13
|
+
|
|
14
|
+
[MODES: framework, data, declarative]
|
|
15
|
+
|
|
16
|
+
<br/>
|
|
17
|
+
<br/>
|
|
18
|
+
|
|
19
|
+
React Router v8 will require the following minimum versions. You can prepare for the upgrade by updating them while still on v7:
|
|
20
|
+
|
|
21
|
+
- `node@22.22+`
|
|
22
|
+
- `react@19.2.7+`/`react-dom@19.2.7+`
|
|
23
|
+
|
|
24
|
+
Framework mode will also require:
|
|
25
|
+
|
|
26
|
+
- `vite@7+` (requires `future.v8_viteEnvironmentApi`)
|
|
27
|
+
- also make sure any custom Vite plugins or config are compatible with Vite 7.
|
|
28
|
+
|
|
12
29
|
## Update to latest v7.x
|
|
13
30
|
|
|
14
|
-
|
|
31
|
+
Before adopting any future flags or call-site opt-in changes, you should update to the latest minor version of v7.x to make sure you have access to the latest flags. You may see a number of deprecation warnings as you upgrade, which we'll cover below.
|
|
15
32
|
|
|
16
33
|
👉 Update to latest v7
|
|
17
34
|
|
|
@@ -19,7 +36,9 @@ First update to the latest minor version of v7.x to have the latest future flags
|
|
|
19
36
|
npm install react-router@7 @react-router/{dev,node,etc.}@7
|
|
20
37
|
```
|
|
21
38
|
|
|
22
|
-
##
|
|
39
|
+
## Future Flags
|
|
40
|
+
|
|
41
|
+
### `future.v8_middleware`
|
|
23
42
|
|
|
24
43
|
[MODES: framework, data]
|
|
25
44
|
|
|
@@ -47,7 +66,7 @@ export default {
|
|
|
47
66
|
In Data mode:
|
|
48
67
|
|
|
49
68
|
```ts
|
|
50
|
-
import { createBrowserRouter } from "react-router
|
|
69
|
+
import { createBrowserRouter } from "react-router";
|
|
51
70
|
|
|
52
71
|
const router = createBrowserRouter(routes, {
|
|
53
72
|
future: {
|
|
@@ -63,7 +82,7 @@ If you're using the `context` parameter in `loader` and `action` functions, you
|
|
|
63
82
|
- In Framework mode, if you're using `react-router-serve`, you should not need to make any updates. Otherwise, this only applies if you have a custom server with a `getLoadContext` function. Please see the docs on the middleware [`getLoadContext` changes](../how-to/middleware#changes-to-getloadcontextapploadcontext) and the instructions to [migrate to the new API](../how-to/middleware#migration-from-apploadcontext).
|
|
64
83
|
- In Data mode, add the `Future` module augmentation described in the [middleware docs](../how-to/middleware#1-typescript-augment-future-for-loaderaction-context) so `context` is typed correctly.
|
|
65
84
|
|
|
66
|
-
|
|
85
|
+
### `future.v8_splitRouteModules`
|
|
67
86
|
|
|
68
87
|
[MODES: framework]
|
|
69
88
|
|
|
@@ -92,7 +111,7 @@ export default {
|
|
|
92
111
|
|
|
93
112
|
No code changes are required. This is an optimization feature that works automatically once enabled.
|
|
94
113
|
|
|
95
|
-
|
|
114
|
+
### `future.v8_viteEnvironmentApi`
|
|
96
115
|
|
|
97
116
|
[MODES: framework]
|
|
98
117
|
|
|
@@ -150,7 +169,7 @@ import { defineConfig } from "vite";
|
|
|
150
169
|
|
|
151
170
|
See the [`node-custom-server` template][node-custom-server-template] for a complete example.
|
|
152
171
|
|
|
153
|
-
|
|
172
|
+
### `future.v8_passThroughRequests`
|
|
154
173
|
|
|
155
174
|
[MODES: framework]
|
|
156
175
|
|
|
@@ -213,7 +232,7 @@ export async function loader({
|
|
|
213
232
|
}
|
|
214
233
|
```
|
|
215
234
|
|
|
216
|
-
|
|
235
|
+
### `future.v8_trailingSlashAwareDataRequests`
|
|
217
236
|
|
|
218
237
|
[MODES: framework]
|
|
219
238
|
|
|
@@ -266,11 +285,201 @@ export default {
|
|
|
266
285
|
|
|
267
286
|
If you have custom app, CDN, cache, or rewrite logic that matches `.data` request URLs, update it to handle the new trailing-slash-aware `/_.data` format.
|
|
268
287
|
|
|
288
|
+
## Other Planned Breaking Changes
|
|
289
|
+
|
|
290
|
+
The changes in this section are not controlled by future flags, but you can update your code in v7 to be ready for v8.
|
|
291
|
+
|
|
292
|
+
### `meta` `data` Argument
|
|
293
|
+
|
|
294
|
+
[MODES: framework]
|
|
295
|
+
|
|
296
|
+
<br/>
|
|
297
|
+
<br/>
|
|
298
|
+
|
|
299
|
+
**Background**
|
|
300
|
+
|
|
301
|
+
The `data` fields passed to route module `meta` functions are deprecated and will be removed in React Router v8. Use `loaderData` instead on `MetaArgs` and each item in `MetaArgs.matches`.
|
|
302
|
+
|
|
303
|
+
👉 **Update your Code**
|
|
304
|
+
|
|
305
|
+
Replace `data` with `loaderData` in your `meta` functions:
|
|
306
|
+
|
|
307
|
+
```diff
|
|
308
|
+
export function meta({
|
|
309
|
+
- data,
|
|
310
|
+
+ loaderData,
|
|
311
|
+
matches,
|
|
312
|
+
}: Route.MetaArgs) {
|
|
313
|
+
return [
|
|
314
|
+
{
|
|
315
|
+
- title: data.title,
|
|
316
|
+
+ title: loaderData.title,
|
|
317
|
+
},
|
|
318
|
+
];
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
If you read data from parent matches, update those references too:
|
|
323
|
+
|
|
324
|
+
```diff
|
|
325
|
+
export function meta({ matches }: Route.MetaArgs) {
|
|
326
|
+
let rootMatch = matches.find((match) => match.id === "root");
|
|
327
|
+
- let rootData = rootMatch?.data;
|
|
328
|
+
+ let rootData = rootMatch?.loaderData;
|
|
329
|
+
|
|
330
|
+
return [{ title: rootData?.siteTitle }];
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### `react-router-dom`
|
|
335
|
+
|
|
336
|
+
[MODES: framework, data, declarative]
|
|
337
|
+
|
|
338
|
+
<br/>
|
|
339
|
+
<br/>
|
|
340
|
+
|
|
341
|
+
**Background**
|
|
342
|
+
|
|
343
|
+
React Router v8 will remove 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`.
|
|
344
|
+
|
|
345
|
+
👉 **Update your Code**
|
|
346
|
+
|
|
347
|
+
Uninstall `react-router-dom`:
|
|
348
|
+
|
|
349
|
+
```sh
|
|
350
|
+
npm uninstall react-router-dom
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Replace `react-router-dom` imports with `react-router` imports:
|
|
354
|
+
|
|
355
|
+
```diff
|
|
356
|
+
-import { Link, useLocation } from "react-router-dom";
|
|
357
|
+
+import { Link, useLocation } from "react-router";
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
For DOM-specific APIs, import from `react-router/dom`:
|
|
361
|
+
|
|
362
|
+
```diff
|
|
363
|
+
-import { RouterProvider } from "react-router-dom";
|
|
364
|
+
+import { RouterProvider } from "react-router/dom";
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Cloudflare Vite Plugin
|
|
368
|
+
|
|
369
|
+
[MODES: framework]
|
|
370
|
+
|
|
371
|
+
<br/>
|
|
372
|
+
<br/>
|
|
373
|
+
|
|
374
|
+
**Background**
|
|
375
|
+
|
|
376
|
+
React Router v8 will remove the React Router Cloudflare dev proxy. Cloudflare projects should use [`@cloudflare/vite-plugin`][cloudflare-vite-plugin] instead.
|
|
377
|
+
|
|
378
|
+
👉 **Update your Code**
|
|
379
|
+
|
|
380
|
+
Replace `cloudflareDevProxy` with `cloudflare`:
|
|
381
|
+
|
|
382
|
+
```diff filename=vite.config.ts
|
|
383
|
+
import { reactRouter } from "@react-router/dev/vite";
|
|
384
|
+
-import { cloudflareDevProxy } from "@react-router/dev/vite/cloudflare";
|
|
385
|
+
+import { cloudflare } from "@cloudflare/vite-plugin";
|
|
386
|
+
import { defineConfig } from "vite";
|
|
387
|
+
|
|
388
|
+
export default defineConfig({
|
|
389
|
+
plugins: [
|
|
390
|
+
- cloudflareDevProxy(),
|
|
391
|
+
+ cloudflare(),
|
|
392
|
+
reactRouter(),
|
|
393
|
+
],
|
|
394
|
+
});
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### `@react-router/architect` `useRequestContextDomainName`
|
|
398
|
+
|
|
399
|
+
[MODES: framework]
|
|
400
|
+
|
|
401
|
+
<br/>
|
|
402
|
+
<br/>
|
|
403
|
+
|
|
404
|
+
**Background**
|
|
405
|
+
|
|
406
|
+
The `@react-router/architect` adapter currently uses `X-Forwarded-Host` when creating the `request`, falling back to the `Host` header. In React Router v8, the adapter will use `event.requestContext.domainName` by default, falling back to the `Host` header.
|
|
407
|
+
|
|
408
|
+
👉 **Update your Code**
|
|
409
|
+
|
|
410
|
+
Opt in to the v8 behavior now by passing `useRequestContextDomainName: true`:
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
import { createRequestHandler } from "@react-router/architect";
|
|
414
|
+
import * as build from "./build/server";
|
|
415
|
+
|
|
416
|
+
export const handler = createRequestHandler({
|
|
417
|
+
build,
|
|
418
|
+
useRequestContextDomainName: true,
|
|
419
|
+
});
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
This option will be removed in v8 once the `event.requestContext.domainName` behavior is the default.
|
|
423
|
+
|
|
269
424
|
## Unstable Future Flags (Optional)
|
|
270
425
|
|
|
271
|
-
We document some [unstable] flags here as a reference for folks contributing to the project via beta testing, but they are not generally recommended for production use and may
|
|
426
|
+
We document some [unstable] flags here as a reference for folks contributing to the project via beta testing, but they are not generally recommended for production use and may have breaking changes in patch or minor releases - adopt with caution!
|
|
427
|
+
|
|
428
|
+
### `future.unstable_optimizeDeps`
|
|
429
|
+
|
|
430
|
+
[MODES: framework]
|
|
431
|
+
|
|
432
|
+
<br/>
|
|
433
|
+
<br/>
|
|
434
|
+
|
|
435
|
+
**Background**
|
|
436
|
+
|
|
437
|
+
This flag lets React Router provide Vite's dependency optimizer with the client entry file and route module files. This can improve dependency optimization in development, but the behavior is still experimental.
|
|
438
|
+
|
|
439
|
+
👉 **Enable the Flag**
|
|
440
|
+
|
|
441
|
+
```ts filename=react-router.config.ts
|
|
442
|
+
import type { Config } from "@react-router/dev/config";
|
|
443
|
+
|
|
444
|
+
export default {
|
|
445
|
+
future: {
|
|
446
|
+
unstable_optimizeDeps: true,
|
|
447
|
+
},
|
|
448
|
+
} satisfies Config;
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
**Update your Code**
|
|
452
|
+
|
|
453
|
+
No code changes are required. If you run into dependency optimization issues after enabling this flag, remove the flag and restart the dev server.
|
|
454
|
+
|
|
455
|
+
### `future.unstable_previewServerPrerendering`
|
|
456
|
+
|
|
457
|
+
[MODES: framework]
|
|
458
|
+
|
|
459
|
+
<br/>
|
|
460
|
+
<br/>
|
|
461
|
+
|
|
462
|
+
**Background**
|
|
463
|
+
|
|
464
|
+
This flag switches prerendering to use Vite's preview-server request flow instead of the current build-time prerendering path so that it works in non-Node environments such as `workerd`. Enabling this flag also enables `future.v8_viteEnvironmentApi`, so you should review the `future.v8_viteEnvironmentApi` guidance above before adopting it.
|
|
465
|
+
|
|
466
|
+
<docs-info>You do not have to adopt this flag ahead of your upgrade to v8 since it only changes the underlying prerender implementation. There is at least one known bug fixed in v8 where your `react-router.config.ts` `buildEnd` hook would run prior to prerendered files being written to disk.</docs-info>
|
|
467
|
+
|
|
468
|
+
👉 **Enable the Flag**
|
|
469
|
+
|
|
470
|
+
```ts filename=react-router.config.ts
|
|
471
|
+
import type { Config } from "@react-router/dev/config";
|
|
472
|
+
|
|
473
|
+
export default {
|
|
474
|
+
future: {
|
|
475
|
+
unstable_previewServerPrerendering: true,
|
|
476
|
+
},
|
|
477
|
+
} satisfies Config;
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
**Update your Code**
|
|
272
481
|
|
|
273
|
-
|
|
482
|
+
No code changes are required unless your app has a custom Vite configuration that is affected by `future.v8_viteEnvironmentApi`.
|
|
274
483
|
|
|
275
484
|
[api-development-strategy]: ../community/api-development-strategy
|
|
276
485
|
[unstable]: ../community/api-development-strategy#unstable-flags
|
|
@@ -278,3 +487,4 @@ _No current unstable flags to document_
|
|
|
278
487
|
[Response]: https://developer.mozilla.org/en-US/docs/Web/API/Response
|
|
279
488
|
[vite-environment]: https://vite.dev/guide/api-environment
|
|
280
489
|
[node-custom-server-template]: https://github.com/remix-run/react-router-templates/blob/7c617a435510bc3add3a5395c07bc65328b65e9e/node-custom-server/vite.config.ts
|
|
490
|
+
[cloudflare-vite-plugin]: https://developers.cloudflare.com/workers/vite-plugin/
|
package/docs/upgrading/remix.md
CHANGED