react-router 8.2.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.
- package/CHANGELOG.md +67 -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.d.ts +106 -17
- package/dist/development/index-react-server.js +168 -42
- 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.d.ts +24 -24
- package/dist/development/lib/dom/dom.js +25 -25
- package/dist/development/lib/dom/lib.d.ts +2 -1
- package/dist/development/lib/dom/lib.js +5 -4
- 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 +26 -21
- 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.d.ts +13 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.js +14 -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.d.ts +24 -8
- package/dist/development/lib/href.js +28 -11
- package/dist/development/lib/router/history.d.ts +6 -0
- package/dist/development/lib/router/history.js +7 -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.d.ts +12 -0
- package/dist/development/lib/router/utils.js +57 -3
- package/dist/development/lib/rsc/browser.js +34 -24
- 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 +29 -10
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +5 -1
- package/dist/development/lib/rsc/server.ssr.d.ts +29 -6
- package/dist/development/lib/rsc/server.ssr.js +27 -12
- package/dist/development/lib/server-runtime/cookies.d.ts +28 -2
- package/dist/development/lib/server-runtime/cookies.js +17 -3
- 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.d.ts +12 -0
- package/dist/development/lib/server-runtime/server.js +13 -1
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +9 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +12 -6
- package/dist/development/lib/server-runtime/sessions.d.ts +31 -2
- package/dist/development/lib/server-runtime/sessions.js +20 -3
- 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.d.ts +106 -17
- package/dist/production/index-react-server.js +168 -42
- 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.d.ts +24 -24
- package/dist/production/lib/dom/dom.js +25 -25
- package/dist/production/lib/dom/lib.d.ts +2 -1
- package/dist/production/lib/dom/lib.js +5 -4
- 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 +26 -21
- 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.d.ts +13 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.js +14 -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.d.ts +24 -8
- package/dist/production/lib/href.js +28 -11
- package/dist/production/lib/router/history.d.ts +6 -0
- package/dist/production/lib/router/history.js +7 -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.d.ts +12 -0
- package/dist/production/lib/router/utils.js +57 -3
- package/dist/production/lib/rsc/browser.js +34 -24
- 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 +29 -10
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +5 -1
- package/dist/production/lib/rsc/server.ssr.d.ts +29 -6
- package/dist/production/lib/rsc/server.ssr.js +27 -12
- package/dist/production/lib/server-runtime/cookies.d.ts +28 -2
- package/dist/production/lib/server-runtime/cookies.js +17 -3
- 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.d.ts +12 -0
- package/dist/production/lib/server-runtime/server.js +13 -1
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +9 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +12 -6
- package/dist/production/lib/server-runtime/sessions.d.ts +31 -2
- package/dist/production/lib/server-runtime/sessions.js +20 -3
- 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/explanation/sessions-and-cookies.md +13 -13
- package/docs/explanation/state-management.md +2 -2
- package/docs/how-to/presets.md +2 -2
- package/docs/how-to/react-server-components.md +53 -1
- package/docs/how-to/security.md +8 -1
- package/docs/how-to/server-bundles.md +2 -2
- package/docs/start/data/route-object.md +2 -2
- package/docs/start/data/routing.md +1 -1
- package/docs/start/framework/pending-ui.md +1 -1
- package/docs/start/framework/route-module.md +8 -8
- package/docs/start/framework/routing.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## v8.3.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Encode path params in `href`/`generatePath` per RFC 3986 path-segment rules instead of `encodeURIComponent` ([#15310](https://github.com/remix-run/react-router/pull/15310))
|
|
8
|
+
- Characters that are valid literally in a path segment (`$ & + , ; = : @` — RFC 3986 `pchar`) are no longer percent-encoded, so values like a semver build `1.0.0+1` interpolate unchanged instead of becoming `1.0.0%2B1`
|
|
9
|
+
- Structural/unsafe characters (`/ ? # %`, whitespace, non-ASCII) are still escaped exactly as before
|
|
10
|
+
- Use `crypto.randomUUID()` for `createMemorySessionStorage` session ids ([#15302](https://github.com/remix-run/react-router/pull/15302))
|
|
11
|
+
- `createMemorySessionStorage` is only intended for local development and testing - sessions are lost when the server restarts
|
|
12
|
+
- Fix `NavLink` not applying its `pending` state when `to` has a trailing slash ([#15300](https://github.com/remix-run/react-router/pull/15300))
|
|
13
|
+
- Preserve RSC route component metadata so routes with a `clientLoader` can skip unnecessary server requests once their components have rendered while still fetching missing server-rendered elements ([#15323](https://github.com/remix-run/react-router/pull/15323))
|
|
14
|
+
- Harden RSC CSRF code paths ([#15311](https://github.com/remix-run/react-router/pull/15311))
|
|
15
|
+
- Fix server crash (`TypeError: Invalid state: Unable to enqueue`) when a request is aborted while the RSC HTML stream has a pending flush ([#15286](https://github.com/remix-run/react-router/pull/15286))
|
|
16
|
+
- Handle cancellation of the `injectRSCPayload` readable side, clear the pending flush, and cancel the underlying RSC payload stream
|
|
17
|
+
|
|
18
|
+
### Unstable Changes
|
|
19
|
+
|
|
20
|
+
⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
|
|
21
|
+
|
|
22
|
+
- Detect stale RSC clients during lazy route discovery and reload the destination document ([#15318](https://github.com/remix-run/react-router/pull/15318))
|
|
23
|
+
|
|
24
|
+
#### Migration
|
|
25
|
+
|
|
26
|
+
Apps using the default RSC Framework entry do not need to make any changes. Apps with a custom `entry.rsc.tsx` should import the generated client version and pass it to `unstable_matchRSCServerRequest`:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import clientVersion from "virtual:react-router/unstable_rsc/client-version";
|
|
30
|
+
|
|
31
|
+
return unstable_matchRSCServerRequest({
|
|
32
|
+
// ...
|
|
33
|
+
clientVersion,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- Add CSP nonce support to RSC document rendering ([#15320](https://github.com/remix-run/react-router/pull/15320))
|
|
38
|
+
|
|
39
|
+
- Add `nonce` options to `unstable_routeRSCServerRequest` and `unstable_RSCStaticRouter`
|
|
40
|
+
- Forward the nonce to the HTML renderer and apply it to injected RSC payload scripts and nonce-aware framework components
|
|
41
|
+
|
|
42
|
+
To adopt nonce-based CSP, update your `entry.ssr.tsx` (run `react-router reveal entry.ssr` first in RSC Framework Mode) to generate a fresh nonce for each request. Pass it to `routeRSCServerRequest`, spread the `renderHTML` options into React's HTML renderer, pass `options.nonce` to `RSCStaticRouter`, and use the same nonce in the `Content-Security-Policy` response header:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
const nonce = crypto.randomUUID();
|
|
46
|
+
const response = await routeRSCServerRequest({
|
|
47
|
+
request,
|
|
48
|
+
serverResponse,
|
|
49
|
+
createFromReadableStream,
|
|
50
|
+
nonce,
|
|
51
|
+
async renderHTML(getPayload, options) {
|
|
52
|
+
const payload = getPayload();
|
|
53
|
+
return renderHTMLToReadableStream(
|
|
54
|
+
<RSCStaticRouter getPayload={getPayload} nonce={options.nonce} />,
|
|
55
|
+
{
|
|
56
|
+
...options,
|
|
57
|
+
bootstrapScriptContent,
|
|
58
|
+
formState: await payload.formState,
|
|
59
|
+
signal: request.signal,
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
response.headers.set(
|
|
65
|
+
"Content-Security-Policy",
|
|
66
|
+
`script-src 'self' 'nonce-${nonce}'`,
|
|
67
|
+
);
|
|
68
|
+
```
|
|
69
|
+
|
|
3
70
|
## v8.2.0
|
|
4
71
|
|
|
5
72
|
### Patch Changes
|
|
@@ -2318,13 +2318,13 @@ type RSCRenderPayload = {
|
|
|
2318
2318
|
type: "render";
|
|
2319
2319
|
actionData: Record<string, any> | null;
|
|
2320
2320
|
basename: string | undefined;
|
|
2321
|
+
clientVersion?: string;
|
|
2321
2322
|
errors: Record<string, any> | null;
|
|
2322
2323
|
loaderData: Record<string, any>;
|
|
2323
2324
|
location: Location;
|
|
2324
2325
|
routeDiscovery: RouteDiscovery;
|
|
2325
2326
|
matches: RSCRouteMatch[];
|
|
2326
2327
|
patches?: Promise<RSCRouteManifest[]>;
|
|
2327
|
-
nonce?: string;
|
|
2328
2328
|
formState?: ReactFormState;
|
|
2329
2329
|
};
|
|
2330
2330
|
type RSCManifestPayload = {
|
|
@@ -2421,6 +2421,8 @@ type RouteDiscovery = {
|
|
|
2421
2421
|
* encoding the {@link unstable_RSCPayload}.
|
|
2422
2422
|
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
|
2423
2423
|
* `loadServerAction` function, used to load a server action by ID.
|
|
2424
|
+
* @param opts.clientVersion A version derived from the client build output used
|
|
2425
|
+
* to detect stale clients during lazy route discovery.
|
|
2424
2426
|
* @param opts.onError An optional error handler that will be called with any
|
|
2425
2427
|
* errors that occur during the request processing.
|
|
2426
2428
|
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
@@ -2444,6 +2446,7 @@ declare function matchRSCServerRequest({
|
|
|
2444
2446
|
loadServerAction,
|
|
2445
2447
|
decodeAction,
|
|
2446
2448
|
decodeFormState,
|
|
2449
|
+
clientVersion,
|
|
2447
2450
|
onError,
|
|
2448
2451
|
request,
|
|
2449
2452
|
routes,
|
|
@@ -2457,6 +2460,7 @@ declare function matchRSCServerRequest({
|
|
|
2457
2460
|
decodeFormState?: DecodeFormStateFunction;
|
|
2458
2461
|
requestContext?: RouterContextProvider;
|
|
2459
2462
|
loadServerAction?: LoadServerActionFunction;
|
|
2463
|
+
clientVersion?: string;
|
|
2460
2464
|
onError?: (error: unknown) => void;
|
|
2461
2465
|
request: Request;
|
|
2462
2466
|
routes: RSCRouteConfigEntry[];
|
|
@@ -2490,14 +2494,30 @@ type Pages = Register extends {
|
|
|
2490
2494
|
type Args = { [K in keyof Pages]: ToArgs<Pages[K]["params"]> };
|
|
2491
2495
|
type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [Params];
|
|
2492
2496
|
/**
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2497
|
+
* Returns a resolved URL path for the specified route.
|
|
2498
|
+
*
|
|
2499
|
+
* Param values are percent-encoded for use in a path segment: characters that
|
|
2500
|
+
* would change the URL structure (`/`, `?`, `#`, `%`, whitespace, non-ASCII)
|
|
2501
|
+
* are escaped, while characters that RFC 3986 allows literally in a path
|
|
2502
|
+
* segment (`$ & + , ; = : @`) are kept as-is. Note this differs from query-string
|
|
2503
|
+
* encoding (`encodeURIComponent`/`URLSearchParams`), where those characters are
|
|
2504
|
+
* delimiters and must be escaped. Splat (`*`) values are encoded per segment,
|
|
2505
|
+
* preserving `/` separators.
|
|
2506
|
+
*
|
|
2507
|
+
* See [RFC 3986 §3.3](https://datatracker.ietf.org/doc/html/rfc3986#section-3.3)
|
|
2508
|
+
*
|
|
2509
|
+
* @example
|
|
2510
|
+
* const h = href("/:lang?/about", { lang: "en" })
|
|
2511
|
+
* // -> `/en/about`
|
|
2512
|
+
*
|
|
2513
|
+
* <Link to={href("/products/:id", { id: "abc123" })} />
|
|
2514
|
+
*
|
|
2515
|
+
* @public
|
|
2516
|
+
* @category Utils
|
|
2517
|
+
* @mode framework
|
|
2518
|
+
* @param path The route path to resolve
|
|
2519
|
+
* @param args The route params to use when resolving the path
|
|
2520
|
+
* @returns The resolved URL path
|
|
2501
2521
|
*/
|
|
2502
2522
|
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
|
|
2503
2523
|
//#endregion
|
|
@@ -2553,13 +2573,39 @@ interface Cookie {
|
|
|
2553
2573
|
}
|
|
2554
2574
|
/**
|
|
2555
2575
|
* Creates a logical container for managing a browser cookie from the server.
|
|
2576
|
+
*
|
|
2577
|
+
* @public
|
|
2578
|
+
* @category Utils
|
|
2579
|
+
* @mode framework
|
|
2580
|
+
* @mode data
|
|
2581
|
+
* @param name The name of the cookie.
|
|
2582
|
+
* @param cookieOptions Options for parsing and serializing the cookie.
|
|
2583
|
+
* @returns A {@link Cookie} object for parsing and serializing the cookie.
|
|
2556
2584
|
*/
|
|
2557
2585
|
declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
|
|
2586
|
+
/**
|
|
2587
|
+
* A function that determines whether a value is a React Router {@link Cookie}
|
|
2588
|
+
* object.
|
|
2589
|
+
*
|
|
2590
|
+
* @public
|
|
2591
|
+
* @category Utils
|
|
2592
|
+
* @mode framework
|
|
2593
|
+
* @mode data
|
|
2594
|
+
* @param object The value to check.
|
|
2595
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
2596
|
+
* otherwise, `false`.
|
|
2597
|
+
*/
|
|
2558
2598
|
type IsCookieFunction = (object: any) => object is Cookie;
|
|
2559
2599
|
/**
|
|
2560
|
-
* Returns true if
|
|
2600
|
+
* Returns `true` if a value is a React Router {@link Cookie} object.
|
|
2561
2601
|
*
|
|
2562
|
-
* @
|
|
2602
|
+
* @public
|
|
2603
|
+
* @category Utils
|
|
2604
|
+
* @mode framework
|
|
2605
|
+
* @mode data
|
|
2606
|
+
* @param object The value to check.
|
|
2607
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
2608
|
+
* otherwise, `false`.
|
|
2563
2609
|
*/
|
|
2564
2610
|
declare const isCookie: IsCookieFunction;
|
|
2565
2611
|
//#endregion
|
|
@@ -2621,13 +2667,37 @@ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?
|
|
|
2621
2667
|
*
|
|
2622
2668
|
* Note: This function is typically not invoked directly by application code.
|
|
2623
2669
|
* Instead, use a `SessionStorage` object's `getSession` method.
|
|
2670
|
+
*
|
|
2671
|
+
* @category Utils
|
|
2672
|
+
* @param initialData The initial data for the session.
|
|
2673
|
+
* @param id The identifier for the session. Defaults to an empty string for a
|
|
2674
|
+
* new session.
|
|
2675
|
+
* @returns A new {@link Session} object.
|
|
2624
2676
|
*/
|
|
2625
2677
|
declare const createSession: CreateSessionFunction;
|
|
2678
|
+
/**
|
|
2679
|
+
* A function that determines whether a value is a React Router {@link Session}
|
|
2680
|
+
* object.
|
|
2681
|
+
*
|
|
2682
|
+
* @public
|
|
2683
|
+
* @category Utils
|
|
2684
|
+
* @mode framework
|
|
2685
|
+
* @mode data
|
|
2686
|
+
* @param object The value to check.
|
|
2687
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
2688
|
+
* otherwise, `false`.
|
|
2689
|
+
*/
|
|
2626
2690
|
type IsSessionFunction = (object: any) => object is Session;
|
|
2627
2691
|
/**
|
|
2628
|
-
* Returns true if
|
|
2692
|
+
* Returns `true` if a value is a React Router {@link Session} object.
|
|
2629
2693
|
*
|
|
2630
|
-
* @
|
|
2694
|
+
* @public
|
|
2695
|
+
* @category Utils
|
|
2696
|
+
* @mode framework
|
|
2697
|
+
* @mode data
|
|
2698
|
+
* @param object The value to check.
|
|
2699
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
2700
|
+
* otherwise, `false`.
|
|
2631
2701
|
*/
|
|
2632
2702
|
declare const isSession: IsSessionFunction;
|
|
2633
2703
|
/**
|
|
@@ -2694,6 +2764,11 @@ interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
|
|
|
2694
2764
|
*
|
|
2695
2765
|
* Note: This is a low-level API that should only be used if none of the
|
|
2696
2766
|
* existing session storage options meet your requirements.
|
|
2767
|
+
*
|
|
2768
|
+
* @category Utils
|
|
2769
|
+
* @param strategy The strategy used to store session identifiers and data.
|
|
2770
|
+
* @returns A {@link SessionStorage} object that persists session data using the
|
|
2771
|
+
* provided strategy.
|
|
2697
2772
|
*/
|
|
2698
2773
|
declare function createSessionStorage<Data = SessionData, FlashData = Data>({
|
|
2699
2774
|
cookie: cookieArg,
|
|
@@ -2719,6 +2794,14 @@ interface CookieSessionStorageOptions {
|
|
|
2719
2794
|
* needed, and can help to simplify some load-balanced scenarios. However, it
|
|
2720
2795
|
* also has the limitation that serialized session data may not exceed the
|
|
2721
2796
|
* browser's maximum cookie size. Trade-offs!
|
|
2797
|
+
*
|
|
2798
|
+
* @public
|
|
2799
|
+
* @category Utils
|
|
2800
|
+
* @mode framework
|
|
2801
|
+
* @mode data
|
|
2802
|
+
* @param options Options for creating the cookie-backed session storage.
|
|
2803
|
+
* @returns A {@link SessionStorage} object that stores all session data in its
|
|
2804
|
+
* cookie.
|
|
2722
2805
|
*/
|
|
2723
2806
|
declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({
|
|
2724
2807
|
cookie: cookieArg
|
|
@@ -2733,11 +2816,17 @@ interface MemorySessionStorageOptions {
|
|
|
2733
2816
|
cookie?: SessionIdStorageStrategy["cookie"];
|
|
2734
2817
|
}
|
|
2735
2818
|
/**
|
|
2736
|
-
* Creates and returns a simple in-memory SessionStorage object
|
|
2737
|
-
*
|
|
2819
|
+
* Creates and returns a simple in-memory SessionStorage object.
|
|
2820
|
+
*
|
|
2821
|
+
* Intended for local development and testing. It does not scale beyond a single
|
|
2822
|
+
* process, and all session data is lost when the server process stops/restarts.
|
|
2738
2823
|
*
|
|
2739
|
-
*
|
|
2740
|
-
*
|
|
2824
|
+
* @public
|
|
2825
|
+
* @category Utils
|
|
2826
|
+
* @mode framework
|
|
2827
|
+
* @mode data
|
|
2828
|
+
* @param options Options for creating the in-memory session storage.
|
|
2829
|
+
* @returns A {@link SessionStorage} object that stores session data in memory.
|
|
2741
2830
|
*/
|
|
2742
2831
|
declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
|
|
2743
2832
|
cookie
|