react-router 7.18.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{production/chunk-3Z6WS2WZ.js → development/chunk-EVX4J2F5.js} +7 -7
  3. package/dist/development/{chunk-YL5M26XI.js → chunk-G5KIBF6U.js} +103 -103
  4. package/dist/development/{chunk-E4MTK73K.mjs → chunk-IJF3QNGC.mjs} +2 -2
  5. package/dist/development/{chunk-4ZMWKKQ3.mjs → chunk-KS7C4IRE.mjs} +2 -2
  6. package/dist/development/{chunk-U7ORXROY.js → chunk-SA4DP3SF.js} +1 -1
  7. package/dist/development/dom-export.js +32 -32
  8. package/dist/development/dom-export.mjs +3 -3
  9. package/dist/development/index-react-server-client.js +4 -4
  10. package/dist/development/index-react-server-client.mjs +2 -2
  11. package/dist/development/index-react-server.js +1 -1
  12. package/dist/development/index-react-server.mjs +1 -1
  13. package/dist/development/index.js +90 -90
  14. package/dist/development/index.mjs +3 -3
  15. package/dist/development/lib/types/internal.js +1 -1
  16. package/dist/development/lib/types/internal.mjs +1 -1
  17. package/dist/production/{chunk-EGOTSXNH.mjs → chunk-3MA7PLKB.mjs} +2 -2
  18. package/dist/production/{chunk-M7NGGUU6.mjs → chunk-3WDNQUW5.mjs} +2 -2
  19. package/dist/{development/chunk-WW7PN6QI.js → production/chunk-GOIER6ML.js} +7 -7
  20. package/dist/production/{chunk-IUPBOWYO.js → chunk-IEF7VMTA.js} +1 -1
  21. package/dist/production/{chunk-BIP66BKV.js → chunk-WICLSFKL.js} +103 -103
  22. package/dist/production/dom-export.js +32 -32
  23. package/dist/production/dom-export.mjs +3 -3
  24. package/dist/production/index-react-server-client.js +4 -4
  25. package/dist/production/index-react-server-client.mjs +2 -2
  26. package/dist/production/index-react-server.js +1 -1
  27. package/dist/production/index-react-server.mjs +1 -1
  28. package/dist/production/index.js +90 -90
  29. package/dist/production/index.mjs +3 -3
  30. package/dist/production/lib/types/internal.js +1 -1
  31. package/dist/production/lib/types/internal.mjs +1 -1
  32. package/docs/how-to/status.md +1 -1
  33. package/docs/upgrading/future.md +222 -12
  34. package/docs/upgrading/remix.md +2 -2
  35. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.18.0
2
+ * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -27,7 +27,7 @@ import {
27
27
  isSession,
28
28
  routeRSCServerRequest,
29
29
  setDevServerHooks
30
- } from "./chunk-EGOTSXNH.mjs";
30
+ } from "./chunk-3MA7PLKB.mjs";
31
31
  import {
32
32
  Action,
33
33
  Await,
@@ -141,7 +141,7 @@ import {
141
141
  withComponentProps,
142
142
  withErrorBoundaryProps,
143
143
  withHydrateFallbackProps
144
- } from "./chunk-M7NGGUU6.mjs";
144
+ } from "./chunk-3WDNQUW5.mjs";
145
145
  export {
146
146
  Await,
147
147
  BrowserRouter,
@@ -1,5 +1,5 @@
1
1
  "use strict";/**
2
- * react-router v7.18.0
2
+ * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.18.0
2
+ * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -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(null, { status: 404 });
57
+ throw data("Not Found", { status: 404 });
58
58
  }
59
59
  return project;
60
60
  }
@@ -1,17 +1,34 @@
1
1
  ---
2
- title: Future Flags
2
+ title: Future Changes
3
3
  order: 1
4
4
  ---
5
5
 
6
- # Future Flags and Deprecations
6
+ # Future Changes
7
7
 
8
- This guide walks you through the process of adopting future flags in your React Router app. By following this strategy, you will be able to upgrade to the next major version of React Router with minimal changes. To read more about future flags see [API Development Strategy][api-development-strategy].
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
- First update to the latest minor version of v7.x to have the latest future 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, 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
- ## `future.v8_middleware`
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/dom";
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
- ## `future.v8_splitRouteModules`
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
- ## `future.v8_viteEnvironmentApi`
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
- ## `future.v8_passThroughRequests`
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
- ## `future.v8_trailingSlashAwareDataRequests`
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 having breaking changes patch/minor releases - adopt with caution!
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
- _No current unstable flags to document_
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/
@@ -1,9 +1,9 @@
1
1
  ---
2
- title: Upgrading from Remix
2
+ title: Upgrading from Remix v2
3
3
  order: 3
4
4
  ---
5
5
 
6
- # Upgrading from Remix
6
+ # Upgrading from Remix v2
7
7
 
8
8
  <docs-info>
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router",
3
- "version": "7.18.0",
3
+ "version": "7.18.1",
4
4
  "description": "Declarative routing for React",
5
5
  "keywords": [
6
6
  "react",