react-router 8.1.0 → 8.3.0

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.
Files changed (178) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/dist/development/dom-export.js +1 -1
  3. package/dist/development/index-react-server-client.js +1 -1
  4. package/dist/development/index-react-server.d.ts +109 -19
  5. package/dist/development/index-react-server.js +176 -45
  6. package/dist/development/index.js +1 -1
  7. package/dist/development/lib/actions.js +1 -1
  8. package/dist/development/lib/components.js +1 -1
  9. package/dist/development/lib/context.js +1 -1
  10. package/dist/development/lib/dom/dom.d.ts +24 -24
  11. package/dist/development/lib/dom/dom.js +25 -25
  12. package/dist/development/lib/dom/lib.d.ts +2 -1
  13. package/dist/development/lib/dom/lib.js +5 -4
  14. package/dist/development/lib/dom/server.js +1 -1
  15. package/dist/development/lib/dom/ssr/components.js +1 -1
  16. package/dist/development/lib/dom/ssr/data.js +1 -1
  17. package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
  18. package/dist/development/lib/dom/ssr/fallback.js +1 -1
  19. package/dist/development/lib/dom/ssr/fog-of-war.js +26 -21
  20. package/dist/development/lib/dom/ssr/hydration.js +1 -1
  21. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  22. package/dist/development/lib/dom/ssr/links.js +1 -1
  23. package/dist/development/lib/dom/ssr/markup.js +1 -1
  24. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  25. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +13 -0
  26. package/dist/development/lib/dom/ssr/routes-test-stub.js +14 -1
  27. package/dist/development/lib/dom/ssr/routes.js +1 -1
  28. package/dist/development/lib/dom/ssr/server.js +1 -1
  29. package/dist/development/lib/dom/ssr/single-fetch.js +1 -1
  30. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  31. package/dist/development/lib/dom-export/hydrated-router.js +1 -1
  32. package/dist/development/lib/errors.js +1 -1
  33. package/dist/development/lib/hooks.d.ts +33 -6
  34. package/dist/development/lib/hooks.js +34 -7
  35. package/dist/development/lib/href.d.ts +24 -8
  36. package/dist/development/lib/href.js +31 -11
  37. package/dist/development/lib/router/history.d.ts +6 -0
  38. package/dist/development/lib/router/history.js +7 -1
  39. package/dist/development/lib/router/instrumentation.js +1 -1
  40. package/dist/development/lib/router/router.js +2 -2
  41. package/dist/development/lib/router/url.js +1 -1
  42. package/dist/development/lib/router/utils.d.ts +12 -0
  43. package/dist/development/lib/router/utils.js +61 -5
  44. package/dist/development/lib/rsc/browser.js +34 -24
  45. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  46. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  47. package/dist/development/lib/rsc/html-stream/server.js +29 -10
  48. package/dist/development/lib/rsc/route-modules.js +1 -1
  49. package/dist/development/lib/rsc/server.rsc.d.ts +8 -3
  50. package/dist/development/lib/rsc/server.ssr.d.ts +29 -6
  51. package/dist/development/lib/rsc/server.ssr.js +27 -12
  52. package/dist/development/lib/server-runtime/cookies.d.ts +28 -2
  53. package/dist/development/lib/server-runtime/cookies.js +17 -3
  54. package/dist/development/lib/server-runtime/crypto.js +1 -1
  55. package/dist/development/lib/server-runtime/data.js +1 -1
  56. package/dist/development/lib/server-runtime/dev.js +1 -1
  57. package/dist/development/lib/server-runtime/entry.js +1 -1
  58. package/dist/development/lib/server-runtime/errors.js +1 -1
  59. package/dist/development/lib/server-runtime/headers.js +1 -1
  60. package/dist/development/lib/server-runtime/invariant.js +1 -1
  61. package/dist/development/lib/server-runtime/mode.js +1 -1
  62. package/dist/development/lib/server-runtime/routeMatching.js +1 -1
  63. package/dist/development/lib/server-runtime/routes.js +1 -1
  64. package/dist/development/lib/server-runtime/server.d.ts +12 -0
  65. package/dist/development/lib/server-runtime/server.js +13 -1
  66. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  67. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
  68. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +9 -1
  69. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
  70. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +12 -6
  71. package/dist/development/lib/server-runtime/sessions.d.ts +31 -2
  72. package/dist/development/lib/server-runtime/sessions.js +20 -3
  73. package/dist/development/lib/server-runtime/single-fetch.js +1 -1
  74. package/dist/development/lib/server-runtime/urls.js +1 -1
  75. package/dist/development/lib/server-runtime/warnings.js +1 -1
  76. package/dist/development/lib/types/internal.js +1 -1
  77. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  78. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  79. package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
  80. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  81. package/dist/production/dom-export.js +1 -1
  82. package/dist/production/index-react-server-client.js +1 -1
  83. package/dist/production/index-react-server.d.ts +109 -19
  84. package/dist/production/index-react-server.js +176 -45
  85. package/dist/production/index.js +1 -1
  86. package/dist/production/lib/actions.js +1 -1
  87. package/dist/production/lib/components.js +1 -1
  88. package/dist/production/lib/context.js +1 -1
  89. package/dist/production/lib/dom/dom.d.ts +24 -24
  90. package/dist/production/lib/dom/dom.js +25 -25
  91. package/dist/production/lib/dom/lib.d.ts +2 -1
  92. package/dist/production/lib/dom/lib.js +5 -4
  93. package/dist/production/lib/dom/server.js +1 -1
  94. package/dist/production/lib/dom/ssr/components.js +1 -1
  95. package/dist/production/lib/dom/ssr/data.js +1 -1
  96. package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
  97. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  98. package/dist/production/lib/dom/ssr/fog-of-war.js +26 -21
  99. package/dist/production/lib/dom/ssr/hydration.js +1 -1
  100. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  101. package/dist/production/lib/dom/ssr/links.js +1 -1
  102. package/dist/production/lib/dom/ssr/markup.js +1 -1
  103. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  104. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +13 -0
  105. package/dist/production/lib/dom/ssr/routes-test-stub.js +14 -1
  106. package/dist/production/lib/dom/ssr/routes.js +1 -1
  107. package/dist/production/lib/dom/ssr/server.js +1 -1
  108. package/dist/production/lib/dom/ssr/single-fetch.js +1 -1
  109. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  110. package/dist/production/lib/dom-export/hydrated-router.js +1 -1
  111. package/dist/production/lib/errors.js +1 -1
  112. package/dist/production/lib/hooks.d.ts +33 -6
  113. package/dist/production/lib/hooks.js +34 -7
  114. package/dist/production/lib/href.d.ts +24 -8
  115. package/dist/production/lib/href.js +31 -11
  116. package/dist/production/lib/router/history.d.ts +6 -0
  117. package/dist/production/lib/router/history.js +7 -1
  118. package/dist/production/lib/router/instrumentation.js +1 -1
  119. package/dist/production/lib/router/router.js +2 -2
  120. package/dist/production/lib/router/url.js +1 -1
  121. package/dist/production/lib/router/utils.d.ts +12 -0
  122. package/dist/production/lib/router/utils.js +61 -5
  123. package/dist/production/lib/rsc/browser.js +34 -24
  124. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  125. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  126. package/dist/production/lib/rsc/html-stream/server.js +29 -10
  127. package/dist/production/lib/rsc/route-modules.js +1 -1
  128. package/dist/production/lib/rsc/server.rsc.d.ts +8 -3
  129. package/dist/production/lib/rsc/server.ssr.d.ts +29 -6
  130. package/dist/production/lib/rsc/server.ssr.js +27 -12
  131. package/dist/production/lib/server-runtime/cookies.d.ts +28 -2
  132. package/dist/production/lib/server-runtime/cookies.js +17 -3
  133. package/dist/production/lib/server-runtime/crypto.js +1 -1
  134. package/dist/production/lib/server-runtime/data.js +1 -1
  135. package/dist/production/lib/server-runtime/dev.js +1 -1
  136. package/dist/production/lib/server-runtime/entry.js +1 -1
  137. package/dist/production/lib/server-runtime/errors.js +1 -1
  138. package/dist/production/lib/server-runtime/headers.js +1 -1
  139. package/dist/production/lib/server-runtime/invariant.js +1 -1
  140. package/dist/production/lib/server-runtime/mode.js +1 -1
  141. package/dist/production/lib/server-runtime/routeMatching.js +1 -1
  142. package/dist/production/lib/server-runtime/routes.js +1 -1
  143. package/dist/production/lib/server-runtime/server.d.ts +12 -0
  144. package/dist/production/lib/server-runtime/server.js +13 -1
  145. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  146. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
  147. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +9 -1
  148. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
  149. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +12 -6
  150. package/dist/production/lib/server-runtime/sessions.d.ts +31 -2
  151. package/dist/production/lib/server-runtime/sessions.js +20 -3
  152. package/dist/production/lib/server-runtime/single-fetch.js +1 -1
  153. package/dist/production/lib/server-runtime/urls.js +1 -1
  154. package/dist/production/lib/server-runtime/warnings.js +1 -1
  155. package/dist/production/lib/types/internal.js +1 -1
  156. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  157. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  158. package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
  159. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  160. package/docs/explanation/hot-module-replacement.md +1 -1
  161. package/docs/explanation/sessions-and-cookies.md +13 -13
  162. package/docs/explanation/state-management.md +2 -2
  163. package/docs/how-to/data-strategy.md +1 -1
  164. package/docs/how-to/presets.md +2 -2
  165. package/docs/how-to/react-server-components.md +53 -1
  166. package/docs/how-to/security.md +8 -1
  167. package/docs/how-to/server-bundles.md +2 -2
  168. package/docs/start/data/route-object.md +2 -2
  169. package/docs/start/data/routing.md +1 -1
  170. package/docs/start/framework/deploying.md +4 -0
  171. package/docs/start/framework/pending-ui.md +1 -1
  172. package/docs/start/framework/route-module.md +8 -8
  173. package/docs/start/framework/routing.md +1 -1
  174. package/docs/upgrading/component-routes.md +1 -1
  175. package/docs/upgrading/future.md +33 -0
  176. package/docs/upgrading/router-provider.md +5 -5
  177. package/docs/upgrading/v7.md +39 -22
  178. package/package.json +1 -1
@@ -500,27 +500,27 @@ export function shouldRevalidate(
500
500
 
501
501
  When using [SPA Mode][spa-mode], there are no server loaders to call on navigations, so `shouldRevalidate` behaves the same as it does in [Data Mode][data-mode-should-revalidate].
502
502
 
503
- [`ShouldRevalidateFunctionArgs` Reference Documentation ↗](https://api.reactrouter.com/v7/interfaces/react-router.ShouldRevalidateFunctionArgs.html)
503
+ [`ShouldRevalidateFunctionArgs` Reference Documentation ↗](https://api.reactrouter.com/v8/interfaces/react-router.ShouldRevalidateFunctionArgs.html)
504
504
 
505
505
  ---
506
506
 
507
507
  Next: [Rendering Strategies](./rendering)
508
508
 
509
- [middleware-params]: https://api.reactrouter.com/v7/types/react-router.MiddlewareFunction.html
509
+ [middleware-params]: https://api.reactrouter.com/v8/types/react-router.MiddlewareFunction.html
510
510
  [middleware]: ../../how-to/middleware
511
511
  [when-middleware-runs]: ../../how-to/middleware#when-middleware-runs
512
- [loader-params]: https://api.reactrouter.com/v7/interfaces/react-router.LoaderFunctionArgs
513
- [client-loader-params]: https://api.reactrouter.com/v7/types/react-router.ClientLoaderFunctionArgs
514
- [action-params]: https://api.reactrouter.com/v7/interfaces/react-router.ActionFunctionArgs
515
- [client-action-params]: https://api.reactrouter.com/v7/types/react-router.ClientActionFunctionArgs
512
+ [loader-params]: https://api.reactrouter.com/v8/interfaces/react-router.LoaderFunctionArgs
513
+ [client-loader-params]: https://api.reactrouter.com/v8/types/react-router.ClientLoaderFunctionArgs
514
+ [action-params]: https://api.reactrouter.com/v8/interfaces/react-router.ActionFunctionArgs
515
+ [client-action-params]: https://api.reactrouter.com/v8/types/react-router.ClientActionFunctionArgs
516
516
  [use-route-error]: ../../api/hooks/useRouteError
517
517
  [is-route-error-response]: ../../api/utils/isRouteErrorResponse
518
518
  [headers]: https://developer.mozilla.org/en-US/docs/Web/API/Response/headers
519
519
  [use-matches]: ../../api/hooks/useMatches
520
520
  [link-element]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link
521
521
  [meta-element]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
522
- [meta-params]: https://api.reactrouter.com/v7/interfaces/react-router.MetaArgs
523
- [meta-function]: https://api.reactrouter.com/v7/types/react-router.MetaDescriptor.html
522
+ [meta-params]: https://api.reactrouter.com/v8/interfaces/react-router.MetaArgs
523
+ [meta-function]: https://api.reactrouter.com/v8/types/react-router.MetaDescriptor.html
524
524
  [data-mode-should-revalidate]: ../data/route-object#shouldrevalidate
525
525
  [spa-mode]: ../../how-to/spa
526
526
  [client-data]: ../../how-to/client-data
@@ -359,4 +359,4 @@ Note that these routes do not participate in data loading, actions, code splitti
359
359
  Next: [Route Module](./route-module)
360
360
 
361
361
  [file-route-conventions]: ../../how-to/file-route-conventions
362
- [outlet]: https://api.reactrouter.com/v7/functions/react-router.Outlet.html
362
+ [outlet]: https://api.reactrouter.com/v8/functions/react-router.Outlet.html
@@ -49,7 +49,7 @@ npm install @react-router/node
49
49
 
50
50
  **👉 Swap out the React plugin for React Router.**
51
51
 
52
- ```diff filename=vite.config.ts
52
+ ```tsx diff filename=vite.config.ts
53
53
  -import react from '@vitejs/plugin-react'
54
54
  +import { reactRouter } from "@react-router/dev/vite";
55
55
  import { defineConfig } from "vite";
@@ -46,6 +46,39 @@ _No known planned breaking changes yet_
46
46
 
47
47
  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!
48
48
 
49
+ ### `future.unstable_enableNodeReadableStream`
50
+
51
+ [MODES: framework]
52
+
53
+ <br/>
54
+ <br/>
55
+
56
+ **Background**
57
+
58
+ Now that the Web Streams API is [stable](https://nodejs.org/docs/latest-v22.x/api/webstreams.html) in Node 22+, it's viable for React Router to use React's [`renderToReadableStream`](https://react.dev/reference/react-dom/server/renderToReadableStream) in the server entry.
59
+
60
+ When no `entry.server.tsx` file is present, React Router defaults to [`renderToPipeableStream`](https://react.dev/reference/react-dom/server/renderToPipeableStream) when a Node runtime is detected, and `renderToReadableStream` otherwise.
61
+
62
+ With this flag enabled, React Router will default to `renderToReadableStream` on all runtimes, including Node. You can continue to use `renderToPipeableStream` via a custom `entry.server.tsx` file if needed.
63
+
64
+ <docs-info>Enabling this flag might even provide slight performance gains because we are already using Web Streams internally, so this flag removes some unnecessary transforms between Web and Node streams.</docs-info>
65
+
66
+ 👉 **Enable the Flag**
67
+
68
+ ```ts filename=react-router.config.ts
69
+ import type { Config } from "@react-router/dev/config";
70
+
71
+ export default {
72
+ future: {
73
+ unstable_enableNodeReadableStream: true,
74
+ },
75
+ } satisfies Config;
76
+ ```
77
+
78
+ **Update your Code**
79
+
80
+ No code changes are required. If your app has a custom `entry.server.tsx`, this flag will not change your runtime behavior.
81
+
49
82
  ### `future.unstable_optimizeDeps`
50
83
 
51
84
  [MODES: framework]
@@ -85,7 +85,7 @@ Instead of importing your route modules directly, lazy load and convert them to
85
85
 
86
86
  Not only does your route definition now conform to the Route Module API, but you also get the benefits of code-splitting your routes.
87
87
 
88
- ```diff filename=src/main.tsx
88
+ ```tsx diff filename=src/main.tsx
89
89
  let router = createBrowserRouter([
90
90
  // ... other routes
91
91
  {
@@ -120,7 +120,7 @@ npm install @react-router/node
120
120
 
121
121
  **👉 Swap out the React plugin for React Router**
122
122
 
123
- ```diff filename=vite.config.ts
123
+ ```tsx diff filename=vite.config.ts
124
124
  -import react from '@vitejs/plugin-react'
125
125
  +import { reactRouter } from "@react-router/dev/vite";
126
126
  import { defineConfig } from "vite";
@@ -247,7 +247,7 @@ export default function App() {
247
247
 
248
248
  You would move everything above the `RouterProvider` into `root.tsx`.
249
249
 
250
- ```diff filename=src/root.tsx
250
+ ```tsx diff filename=src/root.tsx
251
251
  +import "./index.css";
252
252
 
253
253
  // ... other imports and Layout
@@ -326,7 +326,7 @@ touch src/routes.ts src/catchall.tsx
326
326
 
327
327
  Move your route definitions to `routes.ts`. Note that the schemas don't match exactly, so you will get type errors; we'll fix this next.
328
328
 
329
- ```diff filename=src/routes.ts
329
+ ```tsx diff filename=src/routes.ts
330
330
  +import type { RouteConfig } from "@react-router/dev/routes";
331
331
 
332
332
  -const router = createBrowserRouter([
@@ -362,7 +362,7 @@ Move your route definitions to `routes.ts`. Note that the schemas don't match ex
362
362
 
363
363
  **👉 Replace the `lazy` loader with a `file` loader**
364
364
 
365
- ```diff filename=src/routes.ts
365
+ ```tsx diff filename=src/routes.ts
366
366
  export default [
367
367
  {
368
368
  path: "/",
@@ -5,7 +5,7 @@ order: 2
5
5
 
6
6
  # Upgrading from v7
7
7
 
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.
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 while still on v7, you should be able to update to React Router v8 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
 
@@ -16,19 +16,19 @@ We highly recommend you make a commit after each step and ship it instead of doi
16
16
  <br/>
17
17
  <br/>
18
18
 
19
- React Router v8 requires the following minimum versions. You can prepare for the upgrade by updating them while still on v7:
19
+ React Router v8 requires the following minimum versions. Update them before updating React Router to v8:
20
20
 
21
21
  - `node@22.22+`
22
22
  - `react@19.2.7+`/`react-dom@19.2.7+`
23
23
 
24
- Framework mode will also require:
24
+ Framework mode also requires:
25
25
 
26
26
  - `vite@7+` (requires `future.v8_viteEnvironmentApi`)
27
27
  - also make sure any custom Vite plugins or config are compatible with Vite 7
28
28
 
29
29
  ## Update to latest v7.x
30
30
 
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.
31
+ Before adopting any future flags or call-site opt-in changes, 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.
32
32
 
33
33
  👉 Update to latest v7
34
34
 
@@ -140,7 +140,7 @@ Most users won't need to make any changes. However, if you have custom Vite conf
140
140
 
141
141
  For example, a custom server build should move its SSR `rollupOptions` from the top-level `build` config into `environments.ssr.build`:
142
142
 
143
- ```diff filename=vite.config.ts
143
+ ```tsx diff filename=vite.config.ts
144
144
  import { reactRouter } from "@react-router/dev/vite";
145
145
  import { defineConfig } from "vite";
146
146
 
@@ -243,7 +243,7 @@ export async function loader({
243
243
 
244
244
  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.
245
245
 
246
- Currently, your HTTP and `request` pathnames would be as follows for `/a/b/c` and `/a/b/c/`
246
+ In v7, your HTTP and `request` pathnames are as follows for `/a/b/c` and `/a/b/c/`
247
247
 
248
248
  | URL `/a/b/c` | **HTTP pathname** | **`request` pathname`** |
249
249
  | ------------ | ----------------- | ----------------------- |
@@ -255,7 +255,7 @@ Currently, your HTTP and `request` pathnames would be as follows for `/a/b/c` an
255
255
  | **Document** | `/a/b/c/` | `/a/b/c/` ✅ |
256
256
  | **Data** | `/a/b/c.data` | `/a/b/c` ⚠️ |
257
257
 
258
- With this flag enabled, these pathnames will be made consistent though a new `_.data` format for client-side `.data` requests:
258
+ With this flag enabled, these pathnames are made consistent through a new `_.data` format for client-side `.data` requests:
259
259
 
260
260
  | URL `/a/b/c` | **HTTP pathname** | **`request` pathname`** |
261
261
  | ------------ | ----------------- | ----------------------- |
@@ -285,11 +285,11 @@ export default {
285
285
 
286
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.
287
287
 
288
- ## Other Planned Breaking Changes
288
+ ## Other Breaking Changes
289
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.
290
+ The changes in this section are not controlled by future flags, but you can update your code while still on v7 before moving to v8.
291
291
 
292
- ### `meta` `data` Argument
292
+ ### `meta`/`matches` `data` Values
293
293
 
294
294
  [MODES: framework]
295
295
 
@@ -298,13 +298,19 @@ The changes in this section are not controlled by future flags, but you can upda
298
298
 
299
299
  **Background**
300
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`.
301
+ React Router v8 removed deprecated `data` fields in favor of `loaderData` in a few places:
302
+
303
+ - `meta` function `data` argument
304
+ - `meta` function `matches` argument (`matches[i].data`)
305
+ - `useMatches()` (`matches[i].data`)
306
+
307
+ Use `loaderData` instead on `MetaArgs`, each item in `MetaArgs.matches`, and each match returned from `useMatches()`
302
308
 
303
309
  👉 **Update your Code**
304
310
 
305
311
  Replace `data` with `loaderData` in your `meta` functions:
306
312
 
307
- ```diff
313
+ ```tsx diff
308
314
  export function meta({
309
315
  - data,
310
316
  + loaderData,
@@ -321,7 +327,7 @@ export function meta({
321
327
 
322
328
  If you read data from parent matches, update those references too:
323
329
 
324
- ```diff
330
+ ```tsx diff
325
331
  export function meta({ matches }: Route.MetaArgs) {
326
332
  let rootMatch = matches.find((match) => match.id === "root");
327
333
  - let rootData = rootMatch?.data;
@@ -331,6 +337,17 @@ export function meta({ matches }: Route.MetaArgs) {
331
337
  }
332
338
  ```
333
339
 
340
+ Replace `data` with `loaderData` on `useMatches()` calls:
341
+
342
+ ```tsx diff
343
+ export default function Component({ matches, loaderData }: ComponentProps) {
344
+ let matches = useMatches();
345
+ - const rootLoaderData = matches[0].data;
346
+ + const rootLoaderData = matches[0].loaderData;
347
+ // ...
348
+ }
349
+ ```
350
+
334
351
  ### `react-router-dom`
335
352
 
336
353
  [MODES: framework, data, declarative]
@@ -340,7 +357,7 @@ export function meta({ matches }: Route.MetaArgs) {
340
357
 
341
358
  **Background**
342
359
 
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`.
360
+ 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`.
344
361
 
345
362
  👉 **Update your Code**
346
363
 
@@ -352,14 +369,14 @@ npm uninstall react-router-dom
352
369
 
353
370
  Replace `react-router-dom` imports with `react-router` imports:
354
371
 
355
- ```diff
372
+ ```tsx diff
356
373
  -import { Link, useLocation } from "react-router-dom";
357
374
  +import { Link, useLocation } from "react-router";
358
375
  ```
359
376
 
360
377
  For DOM-specific APIs, import from `react-router/dom`:
361
378
 
362
- ```diff
379
+ ```tsx diff
363
380
  -import { RouterProvider } from "react-router-dom";
364
381
  +import { RouterProvider } from "react-router/dom";
365
382
  ```
@@ -373,13 +390,13 @@ For DOM-specific APIs, import from `react-router/dom`:
373
390
 
374
391
  **Background**
375
392
 
376
- React Router v8 will remove the React Router Cloudflare dev proxy. Cloudflare projects should use [`@cloudflare/vite-plugin`][cloudflare-vite-plugin] instead.
393
+ React Router v8 removes the React Router Cloudflare dev proxy. Cloudflare projects should use [`@cloudflare/vite-plugin`][cloudflare-vite-plugin] instead.
377
394
 
378
395
  👉 **Update your Code**
379
396
 
380
397
  Replace `cloudflareDevProxy` with `cloudflare`:
381
398
 
382
- ```diff filename=vite.config.ts
399
+ ```tsx diff filename=vite.config.ts
383
400
  import { reactRouter } from "@react-router/dev/vite";
384
401
  -import { cloudflareDevProxy } from "@react-router/dev/vite/cloudflare";
385
402
  +import { cloudflare } from "@cloudflare/vite-plugin";
@@ -403,11 +420,11 @@ export default defineConfig({
403
420
 
404
421
  **Background**
405
422
 
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.
423
+ 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.
407
424
 
408
425
  👉 **Update your Code**
409
426
 
410
- Opt in to the v8 behavior now by passing `useRequestContextDomainName: true`:
427
+ Opt in to the v8 behavior while still on v7 by passing `useRequestContextDomainName: true`:
411
428
 
412
429
  ```ts
413
430
  import { createRequestHandler } from "@react-router/architect";
@@ -419,11 +436,11 @@ export const handler = createRequestHandler({
419
436
  });
420
437
  ```
421
438
 
422
- This option will be removed in v8 once the `event.requestContext.domainName` behavior is the default.
439
+ This option is removed in v8 because the `event.requestContext.domainName` behavior is the default.
423
440
 
424
441
  ## Upgrade to v8
425
442
 
426
- Now that your app is caught up, you can simply update to v8 (theoretically!) without issue.
443
+ Now that your app is caught up, update to v8:
427
444
 
428
445
  ```shellscript nonumber
429
446
  # data/declarative mode
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-router",
3
3
  "type": "module",
4
- "version": "8.1.0",
4
+ "version": "8.3.0",
5
5
  "description": "Declarative routing for React",
6
6
  "keywords": [
7
7
  "react",