react-router 8.0.0-pre.1 → 8.0.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 +51 -0
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +1 -1
- package/dist/development/index-react-server.js +1 -1
- package/dist/development/index.d.ts +1 -2
- package/dist/development/index.js +1 -1
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/components.js +1 -1
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.js +2 -2
- 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 +1 -1
- 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/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.js +1 -1
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +1 -1
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.js +1 -1
- 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/router.js +1 -1
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.js +1 -1
- package/dist/development/lib/rsc/browser.js +3 -4
- 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 +1 -1
- 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 +1 -1
- 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/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 +1 -1
- 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.js +1 -1
- package/dist/production/index.d.ts +1 -2
- package/dist/production/index.js +1 -1
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/components.js +1 -1
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.js +2 -2
- 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 +1 -1
- 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/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.js +1 -1
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +1 -1
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.js +1 -1
- 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/router.js +1 -1
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.js +1 -1
- package/dist/production/lib/rsc/browser.js +3 -4
- 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 +1 -1
- 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 +1 -1
- 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/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 +1 -1
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/how-to/middleware.md +9 -90
- package/docs/how-to/route-module-type-safety.md +1 -16
- package/docs/how-to/status.md +1 -1
- package/docs/index.md +3 -6
- package/docs/start/framework/deploying.md +1 -1
- package/docs/start/modes.md +1 -2
- package/docs/upgrading/component-routes.md +2 -2
- package/docs/upgrading/future.md +58 -11
- package/docs/upgrading/router-provider.md +6 -3
- package/docs/upgrading/v7.md +443 -0
- package/package.json +6 -6
- package/dist/development/lib/server-runtime/data.d.ts +0 -13
- package/dist/production/lib/server-runtime/data.d.ts +0 -13
- package/docs/upgrading/remix.md +0 -403
- package/docs/upgrading/v6.md +0 -382
|
@@ -91,24 +91,18 @@ export default function Dashboard({
|
|
|
91
91
|
}
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
### 3.
|
|
94
|
+
### 3. Add a `getLoadContext` function (if applicable)
|
|
95
95
|
|
|
96
|
-
If you're using a custom server
|
|
96
|
+
If you're using a custom server, you can use a `getLoadContext` function to pass information to into the react router handlers:
|
|
97
97
|
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
+ RouterContextProvider,
|
|
102
|
-
+} from "react-router";
|
|
103
|
-
import { createDb } from "./db";
|
|
104
|
-
|
|
105
|
-
+const dbContext = createContext<Database>();
|
|
98
|
+
```tsx
|
|
99
|
+
import { RouterContextProvider } from "react-router";
|
|
100
|
+
import { dbContext, createDb } from "./db";
|
|
106
101
|
|
|
107
102
|
function getLoadContext(req, res) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
+ return context;
|
|
103
|
+
const context = new RouterContextProvider();
|
|
104
|
+
context.set(dbContext, createDb());
|
|
105
|
+
return context;
|
|
112
106
|
}
|
|
113
107
|
```
|
|
114
108
|
|
|
@@ -341,7 +335,7 @@ Client middleware is simpler because since we are already on the client and are
|
|
|
341
335
|
|
|
342
336
|
### Context API
|
|
343
337
|
|
|
344
|
-
The
|
|
338
|
+
The context system provides type safety, prevents naming conflicts, and allows you to provide data to nested middlewares and `action`/`loader` functions.
|
|
345
339
|
|
|
346
340
|
```ts
|
|
347
341
|
// ✅ Type-safe
|
|
@@ -474,72 +468,6 @@ export const middleware: Route.MiddlewareFunction[] = [
|
|
|
474
468
|
|
|
475
469
|
Which `ErrorBoundary` is rendered will differ based on whether your middleware threw _before_ or _after_ calling then `next()` function. If it throws _after_ then it will bubble up from the throwing route just like a normal loader error because we've already run the loaders and have the appropriate `loaderData` to render in the route components. However, if an error is thrown _before_ calling `next()`, then we haven't called any loaders yet and there is no `loaderData` available. When this happens, we must bubble up to the highest route with a `loader` and start looking for an `ErrorBoundary` there. We cannot render any route components at that level or below without any `loaderData`.
|
|
476
470
|
|
|
477
|
-
## Changes to `getLoadContext`/`AppLoadContext`
|
|
478
|
-
|
|
479
|
-
<docs-info>This only applies if you are using a custom server and a custom `getLoadContext` function</docs-info>
|
|
480
|
-
|
|
481
|
-
Middleware introduces a breaking change to the `context` parameter generated by `getLoadContext` and passed to your `action`s and `loader`s. The current approach of a module-augmented `AppLoadContext` isn't really type-safe and instead just sort of tells TypeScript to "trust me".
|
|
482
|
-
|
|
483
|
-
Middleware needs an equivalent `context` on the client for `clientMiddleware`, but we didn't want to duplicate this pattern from the server that we already weren't thrilled with, so we decided to introduce a new API where we could tackle type-safety.
|
|
484
|
-
|
|
485
|
-
When opting into middleware, the `context` parameter changes to an instance of [`RouterContextProvider`][RouterContextProvider]:
|
|
486
|
-
|
|
487
|
-
```ts
|
|
488
|
-
let dbContext = createContext<Database>();
|
|
489
|
-
let context = new RouterContextProvider();
|
|
490
|
-
context.set(dbContext, getDb());
|
|
491
|
-
// ^ type-safe
|
|
492
|
-
let db = context.get(dbContext);
|
|
493
|
-
// ^ Database
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
If you're using a custom server and a `getLoadContext` function, you will need to update your implementation to return an instance of [`RouterContextProvider`][RouterContextProvider], instead of a plain JavaScript object:
|
|
497
|
-
|
|
498
|
-
```diff
|
|
499
|
-
+import {
|
|
500
|
-
+ createContext,
|
|
501
|
-
+ RouterContextProvider,
|
|
502
|
-
+} from "react-router";
|
|
503
|
-
import { createDb } from "./db";
|
|
504
|
-
|
|
505
|
-
+const dbContext = createContext<Database>();
|
|
506
|
-
|
|
507
|
-
function getLoadContext(req, res) {
|
|
508
|
-
- return { db: createDb() };
|
|
509
|
-
+ const context = new RouterContextProvider();
|
|
510
|
-
+ context.set(dbContext, createDb());
|
|
511
|
-
+ return context;
|
|
512
|
-
}
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
### Migration from `AppLoadContext`
|
|
516
|
-
|
|
517
|
-
If you're currently using `AppLoadContext`, you can migrate incrementally by using your existing module augmentation to augment [`RouterContextProvider`][RouterContextProvider] instead of `AppLoadContext`. Then, update your `getLoadContext` function to return an instance of [`RouterContextProvider`][RouterContextProvider]:
|
|
518
|
-
|
|
519
|
-
```diff
|
|
520
|
-
declare module "react-router" {
|
|
521
|
-
- interface AppLoadContext {
|
|
522
|
-
+ interface RouterContextProvider {
|
|
523
|
-
db: Database;
|
|
524
|
-
user: User;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
function getLoadContext() {
|
|
529
|
-
const loadContext = {...};
|
|
530
|
-
- return loadContext;
|
|
531
|
-
+ let context = new RouterContextProvider();
|
|
532
|
-
+ Object.assign(context, loadContext);
|
|
533
|
-
+ return context;
|
|
534
|
-
}
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
This allows you to leave your `action`s/`loader`s untouched during initial adoption of middleware, since they can still read values directly (i.e., `context.db`).
|
|
538
|
-
|
|
539
|
-
<docs-warning>This approach is only intended to be used as a migration strategy when adopting middleware in React Router v7, allowing you to incrementally migrate to `context.set`/`context.get`. It is not safe to assume this approach will work in the next major version of React Router.</docs-warning>
|
|
540
|
-
|
|
541
|
-
<docs-warning>The [`RouterContextProvider`][RouterContextProvider] class is also used for the client-side `context` parameter via `<HydratedRouter getContext>` and `<RouterProvider getContext>`. Since `AppLoadContext` is primarily intended as a hand-off from your HTTP server into the React Router handlers, you need to be aware that these augmented fields will not be available in `clientMiddleware`, `clientLoader`, or `clientAction` functions even thought TypeScript will tell you they are (unless, of course, you provide the fields via `getContext` on the client).</docs-warning>
|
|
542
|
-
|
|
543
471
|
## Common Patterns
|
|
544
472
|
|
|
545
473
|
### Authentication
|
|
@@ -700,24 +628,15 @@ export async function loader({
|
|
|
700
628
|
}
|
|
701
629
|
```
|
|
702
630
|
|
|
703
|
-
[future-flags]: ../upgrading/future
|
|
704
631
|
[Response]: https://developer.mozilla.org/en-US/docs/Web/API/Response
|
|
705
632
|
[common-patterns]: #common-patterns
|
|
706
633
|
[server-client]: #server-vs-client-middleware
|
|
707
|
-
[create-browser-router]: ../api/data-routers/createBrowserRouter
|
|
708
|
-
[create-hash-router]: ../api/data-routers/createHashRouter
|
|
709
|
-
[create-memory-router]: ../api/data-routers/createMemoryRouter
|
|
710
|
-
[create-static-handler]: ../api/data-routers/createStaticHandler
|
|
711
634
|
[framework-action]: ../start/framework/route-module#action
|
|
712
635
|
[framework-loader]: ../start/framework/route-module#loader
|
|
713
|
-
[getloadcontext]: #changes-to-getloadcontextapploadcontext
|
|
714
636
|
[datastrategy]: ../api/data-routers/createBrowserRouter#optsdatastrategy
|
|
715
637
|
[cms-redirect]: #cms-redirect-on-404
|
|
716
638
|
[createContext]: ../api/utils/createContext
|
|
717
|
-
[RouterContextProvider]: ../api/utils/RouterContextProvider
|
|
718
639
|
[getContext]: ../api/data-routers/createBrowserRouter#optsgetContext
|
|
719
|
-
[window]: https://developer.mozilla.org/en-US/docs/Web/API/Window
|
|
720
|
-
[document]: https://developer.mozilla.org/en-US/docs/Web/API/Document
|
|
721
640
|
[request]: https://developer.mozilla.org/en-US/docs/Web/API/Request
|
|
722
641
|
[data-action]: ../start/data/route-object#action
|
|
723
642
|
[data-loader]: ../start/data/route-object#loader
|
|
@@ -50,22 +50,7 @@ If you want to run type checking as its own command — for example, as part of
|
|
|
50
50
|
}
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
## 4.
|
|
54
|
-
|
|
55
|
-
## Extending app `Context` types
|
|
56
|
-
|
|
57
|
-
To define your app's `context` type, add the following in a `.ts` or `.d.ts` file within your project:
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
import "react-router";
|
|
61
|
-
declare module "react-router" {
|
|
62
|
-
interface AppLoadContext {
|
|
63
|
-
// add context properties here
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## 5. Type-only auto-imports (optional)
|
|
53
|
+
## 4. Type-only auto-imports (optional)
|
|
69
54
|
|
|
70
55
|
When auto-importing the `Route` type helper, TypeScript will generate:
|
|
71
56
|
|
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
|
}
|
package/docs/index.md
CHANGED
|
@@ -5,7 +5,7 @@ order: 1
|
|
|
5
5
|
|
|
6
6
|
# React Router Home
|
|
7
7
|
|
|
8
|
-
React Router is a multi-strategy router for React
|
|
8
|
+
React Router is a multi-strategy router for React. You can use it maximally as a React framework or as minimally as you want.
|
|
9
9
|
|
|
10
10
|
## Getting Started
|
|
11
11
|
|
|
@@ -29,11 +29,8 @@ These icons indicate which mode the content is relevant to.
|
|
|
29
29
|
|
|
30
30
|
Additional auto-generated reference documentation is available:
|
|
31
31
|
|
|
32
|
-
[Autogenerated Reference Docs ↗](https://api.reactrouter.com/
|
|
32
|
+
[Autogenerated Reference Docs ↗](https://api.reactrouter.com/v8/)
|
|
33
33
|
|
|
34
34
|
## Upgrading
|
|
35
35
|
|
|
36
|
-
If you are caught up on future flags, upgrading from React Router
|
|
37
|
-
|
|
38
|
-
- [Upgrade from v6](./upgrading/v6)
|
|
39
|
-
- [Upgrade from Remix](./upgrading/remix)
|
|
36
|
+
If you are caught up on future flags, [upgrading from React Router v7](./upgrading/v7) is generally non-breaking.
|
|
@@ -97,4 +97,4 @@ EdgeOne Pages maintains their own template for React Router. Checkout the [EdgeO
|
|
|
97
97
|
|
|
98
98
|
### DeployHQ
|
|
99
99
|
|
|
100
|
-
DeployHQ maintains their own guide for deploying React Router
|
|
100
|
+
DeployHQ maintains their own guide for deploying React Router to your own server. Checkout the [DeployHQ Guide](https://www.deployhq.com/guides/deploy-react-router-from-github) for more information.
|
package/docs/start/modes.md
CHANGED
|
@@ -98,7 +98,6 @@ Every mode supports any architecture and deployment target, so the question isn'
|
|
|
98
98
|
- are considering Next.js, Solid Start, SvelteKit, Astro, TanStack Start, etc. and want to compare
|
|
99
99
|
- just want to build something with React
|
|
100
100
|
- might want to server render, might not
|
|
101
|
-
- are coming from Remix (React Router v7 is the "next version" after Remix v2)
|
|
102
101
|
- are migrating from Next.js
|
|
103
102
|
|
|
104
103
|
[→ Get Started with Framework Mode](./framework/installation).
|
|
@@ -113,7 +112,7 @@ Every mode supports any architecture and deployment target, so the question isn'
|
|
|
113
112
|
**Use Declarative Mode if you:**
|
|
114
113
|
|
|
115
114
|
- want to use React Router as simply as possible
|
|
116
|
-
- are coming from
|
|
115
|
+
- are coming from earlier React Router versions and are happy with the `<BrowserRouter>`
|
|
117
116
|
- have a data layer that either skips pending states (like local first, background data replication/sync) or has its own abstractions for them
|
|
118
117
|
- are coming from Create React App (you may want to consider framework mode though)
|
|
119
118
|
|
|
@@ -28,8 +28,8 @@ The initial setup requires the most work. However, once complete, you can adopt
|
|
|
28
28
|
|
|
29
29
|
To use the Vite plugin, your project requires:
|
|
30
30
|
|
|
31
|
-
- Node.js
|
|
32
|
-
- Vite
|
|
31
|
+
- Node.js 22.22.0+
|
|
32
|
+
- Vite 7+ or Vite 8+
|
|
33
33
|
|
|
34
34
|
## 1. Install the Vite plugin
|
|
35
35
|
|
package/docs/upgrading/future.md
CHANGED
|
@@ -1,31 +1,78 @@
|
|
|
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
|
+
|
|
10
|
+
We plan to ship new major versions roughly once a year as described in our [Open Governance Model][governance], so this guide will continue to track future changes you can adopt ahead of the next major release. v9 is currently estimated for mid-2027 when Node 22 reaches EOL.
|
|
9
11
|
|
|
10
12
|
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
13
|
|
|
12
|
-
|
|
14
|
+
<docs-info>This is an evolving document that will be updated throughout the duration of v8</docs-info>
|
|
15
|
+
|
|
16
|
+
## Minimum Versions
|
|
17
|
+
|
|
18
|
+
[MODES: framework, data, declarative]
|
|
19
|
+
|
|
20
|
+
<br/>
|
|
21
|
+
<br/>
|
|
22
|
+
|
|
23
|
+
React Router v9 will require the following minimum versions (as of now). You can prepare for the upgrade by updating them while still on v8:
|
|
24
|
+
|
|
25
|
+
- `node@24+`
|
|
13
26
|
|
|
14
|
-
|
|
27
|
+
## Update to latest v8.x
|
|
15
28
|
|
|
16
|
-
|
|
29
|
+
Before adopting any future flags or call-site opt-in changes, you should update to the latest minor version of v8.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.
|
|
30
|
+
|
|
31
|
+
👉 Update to latest v8
|
|
17
32
|
|
|
18
33
|
```sh
|
|
19
|
-
npm install react-router@
|
|
34
|
+
npm install react-router@8 @react-router/{dev,node,etc.}@8
|
|
20
35
|
```
|
|
21
36
|
|
|
37
|
+
## Future Flags
|
|
38
|
+
|
|
39
|
+
_No future flags yet_
|
|
40
|
+
|
|
41
|
+
## Other Planned Breaking Changes
|
|
42
|
+
|
|
43
|
+
_No known planned breaking changes yet_
|
|
44
|
+
|
|
22
45
|
## Unstable Future Flags (Optional)
|
|
23
46
|
|
|
24
|
-
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
|
|
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
|
+
|
|
49
|
+
### `future.unstable_optimizeDeps`
|
|
50
|
+
|
|
51
|
+
[MODES: framework]
|
|
52
|
+
|
|
53
|
+
<br/>
|
|
54
|
+
<br/>
|
|
55
|
+
|
|
56
|
+
**Background**
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
👉 **Enable the Flag**
|
|
61
|
+
|
|
62
|
+
```ts filename=react-router.config.ts
|
|
63
|
+
import type { Config } from "@react-router/dev/config";
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
future: {
|
|
67
|
+
unstable_optimizeDeps: true,
|
|
68
|
+
},
|
|
69
|
+
} satisfies Config;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Update your Code**
|
|
25
73
|
|
|
26
|
-
|
|
74
|
+
No code changes are required. If you run into dependency optimization issues after enabling this flag, remove the flag and restart the dev server.
|
|
27
75
|
|
|
28
76
|
[api-development-strategy]: ../community/api-development-strategy
|
|
77
|
+
[governance]: https://github.com/remix-run/react-router/blob/main/GOVERNANCE.md#design-goals
|
|
29
78
|
[unstable]: ../community/api-development-strategy#unstable-flags
|
|
30
|
-
[observability]: ../how-to/instrumentation
|
|
31
|
-
[vite-environment]: https://vite.dev/guide/api-environment
|
|
@@ -26,8 +26,8 @@ The initial setup requires the most work. However, once complete, you can adopt
|
|
|
26
26
|
|
|
27
27
|
To use the Vite plugin, your project requires:
|
|
28
28
|
|
|
29
|
-
- Node.js
|
|
30
|
-
- Vite
|
|
29
|
+
- Node.js 22.22.0+
|
|
30
|
+
- Vite 7+ or Vite 8+
|
|
31
31
|
|
|
32
32
|
## 1. Move route definitions into route modules
|
|
33
33
|
|
|
@@ -276,7 +276,10 @@ If your current `src/main.tsx` looks like this:
|
|
|
276
276
|
```tsx filename=src/main.tsx
|
|
277
277
|
import React from "react";
|
|
278
278
|
import ReactDOM from "react-dom/client";
|
|
279
|
-
import {
|
|
279
|
+
import {
|
|
280
|
+
createBrowserRouter,
|
|
281
|
+
RouterProvider,
|
|
282
|
+
} from "react-router";
|
|
280
283
|
import App from "./App";
|
|
281
284
|
|
|
282
285
|
const router = createBrowserRouter([
|