react-router 7.13.2 → 7.14.0-pre.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.
- package/CHANGELOG.md +75 -24
- package/dist/development/{browser-Bfn3xw9E.d.ts → browser-C9Ar1yxG.d.ts} +13 -10
- package/dist/development/{browser-Di6-vSl-.d.mts → browser-vtIR1Kpe.d.mts} +13 -10
- package/dist/development/{chunk-UVKPFVEO.mjs → chunk-47HDNIOI.mjs} +192 -119
- package/dist/development/{chunk-UALY5CBT.mjs → chunk-D73YQQSY.mjs} +21 -7
- package/dist/development/{chunk-GO74ODU3.js → chunk-GE4J47XT.js} +191 -118
- package/dist/{production/chunk-XAAX7KIK.js → development/chunk-KLEV7K4H.js} +99 -99
- package/dist/development/{chunk-LLP6DRWX.js → chunk-MA52INJ5.js} +7 -7
- package/dist/development/dom-export.d.mts +1 -1
- package/dist/development/dom-export.d.ts +1 -1
- package/dist/development/dom-export.js +65 -54
- package/dist/development/dom-export.mjs +34 -23
- package/dist/{production/index-react-server-client-BcrVT7Dd.d.mts → development/index-react-server-client-BwWaHAr3.d.mts} +7 -5
- package/dist/development/{index-react-server-client-CCwMoQIT.d.ts → index-react-server-client-luDbagNU.d.ts} +7 -5
- package/dist/development/index-react-server-client.d.mts +1 -1
- package/dist/development/index-react-server-client.d.ts +1 -1
- 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 +12 -3
- package/dist/development/index-react-server.d.ts +12 -3
- package/dist/development/index-react-server.js +58 -18
- package/dist/development/index-react-server.mjs +58 -18
- package/dist/development/index.d.mts +4 -4
- package/dist/development/index.d.ts +4 -4
- package/dist/development/index.js +101 -87
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +10 -10
- package/dist/development/lib/types/internal.d.ts +10 -10
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/production/{browser-Bfn3xw9E.d.ts → browser-C9Ar1yxG.d.ts} +13 -10
- package/dist/production/{browser-Di6-vSl-.d.mts → browser-vtIR1Kpe.d.mts} +13 -10
- package/dist/production/{chunk-CAFVLUDY.js → chunk-G3YAUWGC.js} +7 -7
- package/dist/production/{chunk-2BDJPJTA.mjs → chunk-MQKMC5YB.mjs} +192 -119
- package/dist/production/{chunk-LKUVSIBA.js → chunk-OBXCYSYK.js} +191 -118
- package/dist/{development/chunk-HPFFRPKK.js → production/chunk-QIHLB25G.js} +99 -99
- package/dist/production/{chunk-PY35PE22.mjs → chunk-XM7AQRW7.mjs} +21 -7
- package/dist/production/dom-export.d.mts +1 -1
- package/dist/production/dom-export.d.ts +1 -1
- package/dist/production/dom-export.js +65 -54
- package/dist/production/dom-export.mjs +34 -23
- package/dist/{development/index-react-server-client-BcrVT7Dd.d.mts → production/index-react-server-client-BwWaHAr3.d.mts} +7 -5
- package/dist/production/{index-react-server-client-CCwMoQIT.d.ts → index-react-server-client-luDbagNU.d.ts} +7 -5
- package/dist/production/index-react-server-client.d.mts +1 -1
- package/dist/production/index-react-server-client.d.ts +1 -1
- 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 +12 -3
- package/dist/production/index-react-server.d.ts +12 -3
- package/dist/production/index-react-server.js +58 -18
- package/dist/production/index-react-server.mjs +58 -18
- package/dist/production/index.d.mts +4 -4
- package/dist/production/index.d.ts +4 -4
- package/dist/production/index.js +101 -87
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +10 -10
- package/dist/production/lib/types/internal.d.ts +10 -10
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## 7.14.0-pre.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- UNSTABLE RSC FRAMEWORK MODE BREAKING CHANGE - Existing route module exports remain unchanged from stable v7 non-RSC mode, but new exports are added for RSC mode. If you want to use RSC features, you will need to update your route modules to export the new annotations. ([#14901](https://github.com/remix-run/react-router/pull/14901))
|
|
8
|
+
|
|
9
|
+
If you are using RSC framework mode currently, you will need to update your route modules to the new conventions. The following route module components have their own mutually exclusive server component counterparts:
|
|
10
|
+
|
|
11
|
+
| Server Component Export | Client Component |
|
|
12
|
+
| ----------------------- | ----------------- |
|
|
13
|
+
| `ServerComponent` | `default` |
|
|
14
|
+
| `ServerErrorBoundary` | `ErrorBoundary` |
|
|
15
|
+
| `ServerLayout` | `Layout` |
|
|
16
|
+
| `ServerHydrateFallback` | `HydrateFallback` |
|
|
17
|
+
|
|
18
|
+
If you were previously exporting a `ServerComponent`, your `ErrorBoundary`, `Layout`, and `HydrateFallback` were also server components. If you want to keep those as server components, you can rename them and prefix them with `Server`. If you were previously importing the implementations of those components from a client module, you can simply inline them.
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
|
|
22
|
+
Before
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { ErrorBoundary as ClientErrorBoundary } from "./client";
|
|
26
|
+
|
|
27
|
+
export function ServerComponent() {
|
|
28
|
+
// ...
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function ErrorBoundary() {
|
|
32
|
+
return <ClientErrorBoundary />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function Layout() {
|
|
36
|
+
// ...
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function HydrateFallback() {
|
|
40
|
+
// ...
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
After
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
export function ServerComponent() {
|
|
48
|
+
// ...
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function ErrorBoundary() {
|
|
52
|
+
// previous implementation of ClientErrorBoundary, this is now a client component
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function ServerLayout() {
|
|
56
|
+
// rename previous Layout export to ServerLayout to make it a server component
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function ServerHydrateFallback() {
|
|
60
|
+
// rename previous HydrateFallback export to ServerHydrateFallback to make it a server component
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- rsc Link prefetch ([#14902](https://github.com/remix-run/react-router/pull/14902))
|
|
65
|
+
- Remove recursion from turbo-stream v2 allowing for encoding / decoding of massive payloads. ([#14838](https://github.com/remix-run/react-router/pull/14838))
|
|
66
|
+
- encodeViaTurboStream leaked memory via unremoved AbortSignal listener ([#14900](https://github.com/remix-run/react-router/pull/14900))
|
|
67
|
+
|
|
3
68
|
## 7.13.2
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
|
@@ -15,7 +80,6 @@
|
|
|
15
80
|
By default, React Router normalizes the `request.url` passed to your `loader`, `action`, and `middleware` functions by removing React Router's internal implementation details (`.data` suffixes, `index` + `_routes` query params).
|
|
16
81
|
|
|
17
82
|
Enabling this flag removes that normalization and passes the raw HTTP `request` instance to your handlers. This provides a few benefits:
|
|
18
|
-
|
|
19
83
|
- Reduces server-side overhead by eliminating multiple `new Request()` calls on the critical path
|
|
20
84
|
- Allows you to distinguish document from data requests in your handlers base don the presence of a `.data` suffix (useful for observability purposes)
|
|
21
85
|
|
|
@@ -65,9 +129,9 @@
|
|
|
65
129
|
|
|
66
130
|
- Fix matchPath optional params matching without a "/" separator. ([#14689](https://github.com/remix-run/react-router/pull/14689))
|
|
67
131
|
- matchPath("/users/:id?", "/usersblah") now returns null.
|
|
68
|
-
- matchPath("/
|
|
132
|
+
- matchPath("/test_route/:part?", "/test_route_more") now returns null.
|
|
69
133
|
|
|
70
|
-
- add RSC
|
|
134
|
+
- add RSC unstable_getRequest ([#14758](https://github.com/remix-run/react-router/pull/14758))
|
|
71
135
|
|
|
72
136
|
- Fix `HydrateFallback` rendering during initial lazy route discovery with matching splat route ([#14740](https://github.com/remix-run/react-router/pull/14740))
|
|
73
137
|
|
|
@@ -113,7 +177,6 @@
|
|
|
113
177
|
```
|
|
114
178
|
|
|
115
179
|
Notes:
|
|
116
|
-
|
|
117
180
|
- The masked location, if present, will be available on `useLocation().unstable_mask` so you can detect whether you are currently masked or not.
|
|
118
181
|
- Masked URLs only work for SPA use cases, and will be removed from `history.state` during SSR.
|
|
119
182
|
- This provides a first-class API to mask URLs in Data Mode to achieve the same behavior you could do in Declarative Mode via [manual `backgroundLocation` management](https://github.com/remix-run/react-router/tree/main/examples/modal).
|
|
@@ -159,25 +222,25 @@
|
|
|
159
222
|
|
|
160
223
|
| URL `/a/b/c` | **HTTP pathname** | **`request` pathname\`** |
|
|
161
224
|
| ------------ | ----------------- | ------------------------ |
|
|
162
|
-
| **Document** | `/a/b/c` | `/a/b/c` ✅
|
|
163
|
-
| **Data** | `/a/b/c.data` | `/a/b/c` ✅
|
|
225
|
+
| **Document** | `/a/b/c` | `/a/b/c` ✅ |
|
|
226
|
+
| **Data** | `/a/b/c.data` | `/a/b/c` ✅ |
|
|
164
227
|
|
|
165
228
|
| URL `/a/b/c/` | **HTTP pathname** | **`request` pathname\`** |
|
|
166
229
|
| ------------- | ----------------- | ------------------------ |
|
|
167
|
-
| **Document** | `/a/b/c/` | `/a/b/c/` ✅
|
|
230
|
+
| **Document** | `/a/b/c/` | `/a/b/c/` ✅ |
|
|
168
231
|
| **Data** | `/a/b/c.data` | `/a/b/c` ⚠️ |
|
|
169
232
|
|
|
170
233
|
With this flag enabled, these pathnames will be made consistent though a new `_.data` format for client-side `.data` requests:
|
|
171
234
|
|
|
172
235
|
| URL `/a/b/c` | **HTTP pathname** | **`request` pathname\`** |
|
|
173
236
|
| ------------ | ----------------- | ------------------------ |
|
|
174
|
-
| **Document** | `/a/b/c` | `/a/b/c` ✅
|
|
175
|
-
| **Data** | `/a/b/c.data` | `/a/b/c` ✅
|
|
237
|
+
| **Document** | `/a/b/c` | `/a/b/c` ✅ |
|
|
238
|
+
| **Data** | `/a/b/c.data` | `/a/b/c` ✅ |
|
|
176
239
|
|
|
177
240
|
| URL `/a/b/c/` | **HTTP pathname** | **`request` pathname\`** |
|
|
178
241
|
| ------------- | ------------------ | ------------------------ |
|
|
179
|
-
| **Document** | `/a/b/c/` | `/a/b/c/` ✅
|
|
180
|
-
| **Data** | `/a/b/c/_.data` ⬅️ | `/a/b/c/` ✅
|
|
242
|
+
| **Document** | `/a/b/c/` | `/a/b/c/` ✅ |
|
|
243
|
+
| **Data** | `/a/b/c/_.data` ⬅️ | `/a/b/c/` ✅ |
|
|
181
244
|
|
|
182
245
|
This a bug fix but we are putting it behind an opt-in flag because it has the potential to be a "breaking bug fix" if you are relying on the URL format for any other application or caching logic.
|
|
183
246
|
|
|
@@ -204,14 +267,12 @@
|
|
|
204
267
|
- \[UNSTABLE] Add a new `unstable_defaultShouldRevalidate` flag to various APIs to allow opt-ing out of standard revalidation behaviors. ([#14542](https://github.com/remix-run/react-router/pull/14542))
|
|
205
268
|
|
|
206
269
|
If active routes include a `shouldRevalidate` function, then your value will be passed as `defaultShouldRevalidate` in those function so that the route always has the final revalidation determination.
|
|
207
|
-
|
|
208
270
|
- `<Form method="post" unstable_defaultShouldRevalidate={false}>`
|
|
209
271
|
- `submit(data, { method: "post", unstable_defaultShouldRevalidate: false })`
|
|
210
272
|
- `<fetcher.Form method="post" unstable_defaultShouldRevalidate={false}>`
|
|
211
273
|
- `fetcher.submit(data, { method: "post", unstable_defaultShouldRevalidate: false })`
|
|
212
274
|
|
|
213
275
|
This is also available on non-submission APIs that may trigger revalidations due to changing search params:
|
|
214
|
-
|
|
215
276
|
- `<Link to="/" unstable_defaultShouldRevalidate={false}>`
|
|
216
277
|
- `navigate("/?foo=bar", { unstable_defaultShouldRevalidate: false })`
|
|
217
278
|
- `setSearchParams(params, { unstable_defaultShouldRevalidate: false })`
|
|
@@ -234,7 +295,6 @@
|
|
|
234
295
|
- ⚠️ This is a breaking change if you have begun using `fetcher.unstable_reset()`
|
|
235
296
|
|
|
236
297
|
- Stabilize the `dataStrategy` `match.shouldRevalidateArgs`/`match.shouldCallHandler()` APIs. ([#14592](https://github.com/remix-run/react-router/pull/14592))
|
|
237
|
-
|
|
238
298
|
- The `match.shouldLoad` API is now marked deprecated in favor of these more powerful alternatives
|
|
239
299
|
|
|
240
300
|
- If you're using this API in a custom `dataStrategy` today, you can swap to the new API at your convenience:
|
|
@@ -363,7 +423,6 @@
|
|
|
363
423
|
- Ensure action handlers run for routes with middleware even if no loader is present ([#14443](https://github.com/remix-run/react-router/pull/14443))
|
|
364
424
|
|
|
365
425
|
- Add `unstable_instrumentations` API to allow users to add observablity to their apps by instrumenting route loaders, actions, middlewares, lazy, as well as server-side request handlers and client side navigations/fetches ([#14412](https://github.com/remix-run/react-router/pull/14412))
|
|
366
|
-
|
|
367
426
|
- Framework Mode:
|
|
368
427
|
- `entry.server.tsx`: `export const unstable_instrumentations = [...]`
|
|
369
428
|
- `entry.client.tsx`: `<HydratedRouter unstable_instrumentations={[...]} />`
|
|
@@ -525,7 +584,6 @@
|
|
|
525
584
|
- Stabilize middleware and context APIs. ([#14215](https://github.com/remix-run/react-router/pull/14215))
|
|
526
585
|
|
|
527
586
|
We have removed the `unstable_` prefix from the following APIs and they are now considered stable and ready for production use:
|
|
528
|
-
|
|
529
587
|
- [`RouterContextProvider`](https://reactrouter.com/api/utils/RouterContextProvider)
|
|
530
588
|
- [`createContext`](https://reactrouter.com/api/utils/createContext)
|
|
531
589
|
- `createBrowserRouter` [`getContext`](https://reactrouter.com/api/data-routers/createBrowserRouter#optsgetcontext) option
|
|
@@ -552,7 +610,7 @@
|
|
|
552
610
|
|
|
553
611
|
- \[UNSTABLE] Add `<RouterProvider unstable_onError>`/`<HydratedRouter unstable_onError>` prop for client side error reporting ([#14162](https://github.com/remix-run/react-router/pull/14162))
|
|
554
612
|
|
|
555
|
-
- server action revalidation opt out via $
|
|
613
|
+
- server action revalidation opt out via $SKIP_REVALIDATION field ([#14154](https://github.com/remix-run/react-router/pull/14154))
|
|
556
614
|
|
|
557
615
|
- Properly escape interpolated param values in `generatePath()` ([#13530](https://github.com/remix-run/react-router/pull/13530))
|
|
558
616
|
|
|
@@ -601,7 +659,6 @@
|
|
|
601
659
|
- Remove dependency on `@types/node` in TypeScript declaration files ([#14059](https://github.com/remix-run/react-router/pull/14059))
|
|
602
660
|
|
|
603
661
|
- Fix types for `UIMatch` to reflect that the `loaderData`/`data` properties may be `undefined` ([#12206](https://github.com/remix-run/react-router/pull/12206))
|
|
604
|
-
|
|
605
662
|
- When an `ErrorBoundary` is being rendered, not all active matches will have loader data available, since it may have been their `loader` that threw to trigger the boundary
|
|
606
663
|
- The `UIMatch.data` type was not correctly handing this and would always reflect the presence of data, leading to the unexpected runtime errors when an `ErrorBoundary` was rendered
|
|
607
664
|
- ⚠️ This may cause some type errors to show up in your code for unguarded `match.data` accesses - you should properly guard for `undefined` values in those scenarios.
|
|
@@ -635,7 +692,6 @@
|
|
|
635
692
|
- \[UNSTABLE] When middleware is enabled, make the `context` parameter read-only (via `Readonly<unstable_RouterContextProvider>`) so that TypeScript will not allow you to write arbitrary fields to it in loaders, actions, or middleware. ([#14097](https://github.com/remix-run/react-router/pull/14097))
|
|
636
693
|
|
|
637
694
|
- \[UNSTABLE] Rename and alter the signature/functionality of the `unstable_respond` API in `staticHandler.query`/`staticHandler.queryRoute` ([#14103](https://github.com/remix-run/react-router/pull/14103))
|
|
638
|
-
|
|
639
695
|
- The API has been renamed to `unstable_generateMiddlewareResponse` for clarity
|
|
640
696
|
- The main functional change is that instead of running the loaders/actions before calling `unstable_respond` and handing you the result, we now pass a `query`/`queryRoute` function as a parameter and you execute the loaders/actions inside your callback, giving you full access to pre-processing and error handling
|
|
641
697
|
- The `query` version of the API now has a signature of `(query: (r: Request) => Promise<StaticHandlerContext | Response>) => Promise<Response>`
|
|
@@ -1281,7 +1337,6 @@
|
|
|
1281
1337
|
```
|
|
1282
1338
|
|
|
1283
1339
|
Similar to server-side requests, a fresh `context` will be created per navigation (or `fetcher` call). If you have initial data you'd like to populate in the context for every request, you can provide an `unstable_getContext` function at the root of your app:
|
|
1284
|
-
|
|
1285
1340
|
- Library mode - `createBrowserRouter(routes, { unstable_getContext })`
|
|
1286
1341
|
- Framework mode - `<HydratedRouter unstable_getContext>`
|
|
1287
1342
|
|
|
@@ -1469,7 +1524,6 @@ _No changes_
|
|
|
1469
1524
|
- Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
|
|
1470
1525
|
|
|
1471
1526
|
- For Remix consumers migrating to React Router, the `crypto` global from the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is now required when using cookie and session APIs. This means that the following APIs are provided from `react-router` rather than platform-specific packages: ([#11837](https://github.com/remix-run/react-router/pull/11837))
|
|
1472
|
-
|
|
1473
1527
|
- `createCookie`
|
|
1474
1528
|
- `createCookieSessionStorage`
|
|
1475
1529
|
- `createMemorySessionStorage`
|
|
@@ -1478,7 +1532,6 @@ _No changes_
|
|
|
1478
1532
|
For consumers running older versions of Node, the `installGlobals` function from `@remix-run/node` has been updated to define `globalThis.crypto`, using [Node's `require('node:crypto').webcrypto` implementation.](https://nodejs.org/api/webcrypto.html)
|
|
1479
1533
|
|
|
1480
1534
|
Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
|
|
1481
|
-
|
|
1482
1535
|
- `createCookieFactory`
|
|
1483
1536
|
- `createSessionStorageFactory`
|
|
1484
1537
|
- `createCookieSessionStorageFactory`
|
|
@@ -1634,7 +1687,6 @@ _No changes_
|
|
|
1634
1687
|
```
|
|
1635
1688
|
|
|
1636
1689
|
This initial implementation targets type inference for:
|
|
1637
|
-
|
|
1638
1690
|
- `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
|
|
1639
1691
|
- `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
|
|
1640
1692
|
- `ActionData` : Action data from `action` and/or `clientAction` within your route module
|
|
@@ -1649,7 +1701,6 @@ _No changes_
|
|
|
1649
1701
|
```
|
|
1650
1702
|
|
|
1651
1703
|
Check out our docs for more:
|
|
1652
|
-
|
|
1653
1704
|
- [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
|
|
1654
1705
|
- [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
|
|
1655
1706
|
|
|
@@ -65,14 +65,15 @@ type RSCRenderPayload = {
|
|
|
65
65
|
errors: Record<string, any> | null;
|
|
66
66
|
loaderData: Record<string, any>;
|
|
67
67
|
location: Location;
|
|
68
|
+
routeDiscovery: RouteDiscovery;
|
|
68
69
|
matches: RSCRouteMatch[];
|
|
69
|
-
patches?: RSCRouteManifest[]
|
|
70
|
+
patches?: Promise<RSCRouteManifest[]>;
|
|
70
71
|
nonce?: string;
|
|
71
72
|
formState?: unknown;
|
|
72
73
|
};
|
|
73
74
|
type RSCManifestPayload = {
|
|
74
75
|
type: "manifest";
|
|
75
|
-
patches: RSCRouteManifest[]
|
|
76
|
+
patches: Promise<RSCRouteManifest[]>;
|
|
76
77
|
};
|
|
77
78
|
type RSCActionPayload = {
|
|
78
79
|
type: "action";
|
|
@@ -99,6 +100,12 @@ type DecodeReplyFunction = (reply: FormData | string, options: {
|
|
|
99
100
|
temporaryReferences: unknown;
|
|
100
101
|
}) => Promise<unknown[]>;
|
|
101
102
|
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
103
|
+
type RouteDiscovery = {
|
|
104
|
+
mode: "lazy";
|
|
105
|
+
manifestPath?: string | undefined;
|
|
106
|
+
} | {
|
|
107
|
+
mode: "initial";
|
|
108
|
+
};
|
|
102
109
|
/**
|
|
103
110
|
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
104
111
|
* and returns an [RSC](https://react.dev/reference/rsc/server-components)
|
|
@@ -165,12 +172,13 @@ type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
|
165
172
|
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
166
173
|
* that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
|
|
167
174
|
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
175
|
+
* @param opts.routeDiscovery The route discovery configuration, used to determine how the router should discover new routes during navigations.
|
|
168
176
|
* @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
|
|
169
177
|
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
170
178
|
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
171
179
|
* data for hydration.
|
|
172
180
|
*/
|
|
173
|
-
declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
|
|
181
|
+
declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, routeDiscovery, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
|
|
174
182
|
allowedActionOrigins?: string[];
|
|
175
183
|
createTemporaryReferenceSet: () => unknown;
|
|
176
184
|
basename?: string;
|
|
@@ -182,6 +190,7 @@ declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRe
|
|
|
182
190
|
onError?: (error: unknown) => void;
|
|
183
191
|
request: Request;
|
|
184
192
|
routes: RSCRouteConfigEntry[];
|
|
193
|
+
routeDiscovery?: RouteDiscovery;
|
|
185
194
|
generateResponse: (match: RSCMatch, { onError, temporaryReferences, }: {
|
|
186
195
|
onError(error: unknown): string | undefined;
|
|
187
196
|
temporaryReferences: unknown;
|
|
@@ -256,11 +265,6 @@ interface RSCHydratedRouterProps {
|
|
|
256
265
|
* The decoded {@link unstable_RSCPayload} to hydrate.
|
|
257
266
|
*/
|
|
258
267
|
payload: RSCPayload;
|
|
259
|
-
/**
|
|
260
|
-
* `"eager"` or `"lazy"` - Determines if links are eagerly discovered, or
|
|
261
|
-
* delayed until clicked.
|
|
262
|
-
*/
|
|
263
|
-
routeDiscovery?: "eager" | "lazy";
|
|
264
268
|
/**
|
|
265
269
|
* A function that returns an {@link RouterContextProvider} instance
|
|
266
270
|
* which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
|
|
@@ -306,10 +310,9 @@ interface RSCHydratedRouterProps {
|
|
|
306
310
|
* @param {unstable_RSCHydratedRouterProps.fetch} props.fetch n/a
|
|
307
311
|
* @param {unstable_RSCHydratedRouterProps.getContext} props.getContext n/a
|
|
308
312
|
* @param {unstable_RSCHydratedRouterProps.payload} props.payload n/a
|
|
309
|
-
* @param {unstable_RSCHydratedRouterProps.routeDiscovery} props.routeDiscovery n/a
|
|
310
313
|
* @returns A hydrated {@link DataRouter} that can be used to navigate and
|
|
311
314
|
* render routes.
|
|
312
315
|
*/
|
|
313
|
-
declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload,
|
|
316
|
+
declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload, getContext, }: RSCHydratedRouterProps): React.JSX.Element;
|
|
314
317
|
|
|
315
318
|
export { type BrowserCreateFromReadableStreamFunction as B, type DecodeActionFunction as D, type EncodeReplyFunction as E, type LoadServerActionFunction as L, RSCHydratedRouter as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, createCallServer as c, type RSCManifestPayload as d, type RSCPayload as e, type RSCRenderPayload as f, getRequest as g, type RSCHydratedRouterProps as h, type RSCMatch as i, type RSCRouteManifest as j, type RSCRouteMatch as k, type RSCRouteConfigEntry as l, matchRSCServerRequest as m, type RSCRouteConfig as n };
|
|
@@ -65,14 +65,15 @@ type RSCRenderPayload = {
|
|
|
65
65
|
errors: Record<string, any> | null;
|
|
66
66
|
loaderData: Record<string, any>;
|
|
67
67
|
location: Location;
|
|
68
|
+
routeDiscovery: RouteDiscovery;
|
|
68
69
|
matches: RSCRouteMatch[];
|
|
69
|
-
patches?: RSCRouteManifest[]
|
|
70
|
+
patches?: Promise<RSCRouteManifest[]>;
|
|
70
71
|
nonce?: string;
|
|
71
72
|
formState?: unknown;
|
|
72
73
|
};
|
|
73
74
|
type RSCManifestPayload = {
|
|
74
75
|
type: "manifest";
|
|
75
|
-
patches: RSCRouteManifest[]
|
|
76
|
+
patches: Promise<RSCRouteManifest[]>;
|
|
76
77
|
};
|
|
77
78
|
type RSCActionPayload = {
|
|
78
79
|
type: "action";
|
|
@@ -99,6 +100,12 @@ type DecodeReplyFunction = (reply: FormData | string, options: {
|
|
|
99
100
|
temporaryReferences: unknown;
|
|
100
101
|
}) => Promise<unknown[]>;
|
|
101
102
|
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
103
|
+
type RouteDiscovery = {
|
|
104
|
+
mode: "lazy";
|
|
105
|
+
manifestPath?: string | undefined;
|
|
106
|
+
} | {
|
|
107
|
+
mode: "initial";
|
|
108
|
+
};
|
|
102
109
|
/**
|
|
103
110
|
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
104
111
|
* and returns an [RSC](https://react.dev/reference/rsc/server-components)
|
|
@@ -165,12 +172,13 @@ type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
|
165
172
|
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
166
173
|
* that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
|
|
167
174
|
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
175
|
+
* @param opts.routeDiscovery The route discovery configuration, used to determine how the router should discover new routes during navigations.
|
|
168
176
|
* @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
|
|
169
177
|
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
170
178
|
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
171
179
|
* data for hydration.
|
|
172
180
|
*/
|
|
173
|
-
declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
|
|
181
|
+
declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, routeDiscovery, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
|
|
174
182
|
allowedActionOrigins?: string[];
|
|
175
183
|
createTemporaryReferenceSet: () => unknown;
|
|
176
184
|
basename?: string;
|
|
@@ -182,6 +190,7 @@ declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRe
|
|
|
182
190
|
onError?: (error: unknown) => void;
|
|
183
191
|
request: Request;
|
|
184
192
|
routes: RSCRouteConfigEntry[];
|
|
193
|
+
routeDiscovery?: RouteDiscovery;
|
|
185
194
|
generateResponse: (match: RSCMatch, { onError, temporaryReferences, }: {
|
|
186
195
|
onError(error: unknown): string | undefined;
|
|
187
196
|
temporaryReferences: unknown;
|
|
@@ -256,11 +265,6 @@ interface RSCHydratedRouterProps {
|
|
|
256
265
|
* The decoded {@link unstable_RSCPayload} to hydrate.
|
|
257
266
|
*/
|
|
258
267
|
payload: RSCPayload;
|
|
259
|
-
/**
|
|
260
|
-
* `"eager"` or `"lazy"` - Determines if links are eagerly discovered, or
|
|
261
|
-
* delayed until clicked.
|
|
262
|
-
*/
|
|
263
|
-
routeDiscovery?: "eager" | "lazy";
|
|
264
268
|
/**
|
|
265
269
|
* A function that returns an {@link RouterContextProvider} instance
|
|
266
270
|
* which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
|
|
@@ -306,10 +310,9 @@ interface RSCHydratedRouterProps {
|
|
|
306
310
|
* @param {unstable_RSCHydratedRouterProps.fetch} props.fetch n/a
|
|
307
311
|
* @param {unstable_RSCHydratedRouterProps.getContext} props.getContext n/a
|
|
308
312
|
* @param {unstable_RSCHydratedRouterProps.payload} props.payload n/a
|
|
309
|
-
* @param {unstable_RSCHydratedRouterProps.routeDiscovery} props.routeDiscovery n/a
|
|
310
313
|
* @returns A hydrated {@link DataRouter} that can be used to navigate and
|
|
311
314
|
* render routes.
|
|
312
315
|
*/
|
|
313
|
-
declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload,
|
|
316
|
+
declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload, getContext, }: RSCHydratedRouterProps): React.JSX.Element;
|
|
314
317
|
|
|
315
318
|
export { type BrowserCreateFromReadableStreamFunction as B, type DecodeActionFunction as D, type EncodeReplyFunction as E, type LoadServerActionFunction as L, RSCHydratedRouter as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, createCallServer as c, type RSCManifestPayload as d, type RSCPayload as e, type RSCRenderPayload as f, getRequest as g, type RSCHydratedRouterProps as h, type RSCMatch as i, type RSCRouteManifest as j, type RSCRouteMatch as k, type RSCRouteConfigEntry as l, matchRSCServerRequest as m, type RSCRouteConfig as n };
|