react-router 0.0.0-experimental-abd9fc79b → 0.0.0-experimental-479e73b7b

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 (185) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/dist/development/dom-export.js +1 -1
  3. package/dist/development/index-react-server-client.js +1 -1
  4. package/dist/development/index-react-server.d.ts +141 -26
  5. package/dist/development/index-react-server.js +355 -196
  6. package/dist/development/index.d.ts +3 -3
  7. package/dist/development/index.js +3 -3
  8. package/dist/development/lib/actions.js +1 -1
  9. package/dist/development/lib/components.js +38 -4
  10. package/dist/development/lib/context.d.ts +8 -3
  11. package/dist/development/lib/context.js +8 -2
  12. package/dist/development/lib/dom/dom.d.ts +24 -24
  13. package/dist/development/lib/dom/dom.js +25 -25
  14. package/dist/development/lib/dom/lib.d.ts +2 -1
  15. package/dist/development/lib/dom/lib.js +9 -8
  16. package/dist/development/lib/dom/server.js +24 -4
  17. package/dist/development/lib/dom/ssr/components.js +13 -5
  18. package/dist/development/lib/dom/ssr/data.js +1 -1
  19. package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
  20. package/dist/development/lib/dom/ssr/fallback.js +1 -1
  21. package/dist/development/lib/dom/ssr/fog-of-war.js +26 -21
  22. package/dist/development/lib/dom/ssr/hydration.js +1 -1
  23. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  24. package/dist/development/lib/dom/ssr/links.js +1 -1
  25. package/dist/development/lib/dom/ssr/markup.js +1 -1
  26. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  27. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +13 -0
  28. package/dist/development/lib/dom/ssr/routes-test-stub.js +14 -1
  29. package/dist/development/lib/dom/ssr/routes.js +1 -1
  30. package/dist/development/lib/dom/ssr/server.js +1 -1
  31. package/dist/development/lib/dom/ssr/single-fetch.js +1 -1
  32. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  33. package/dist/development/lib/dom-export/hydrated-router.js +1 -1
  34. package/dist/development/lib/errors.js +1 -1
  35. package/dist/development/lib/hooks.d.ts +33 -6
  36. package/dist/development/lib/hooks.js +70 -36
  37. package/dist/development/lib/href.d.ts +24 -8
  38. package/dist/development/lib/href.js +31 -11
  39. package/dist/development/lib/router/history.d.ts +6 -0
  40. package/dist/development/lib/router/history.js +7 -1
  41. package/dist/development/lib/router/instrumentation.d.ts +33 -8
  42. package/dist/development/lib/router/instrumentation.js +176 -99
  43. package/dist/development/lib/router/router.js +27 -22
  44. package/dist/development/lib/router/url.js +1 -1
  45. package/dist/development/lib/router/utils.d.ts +12 -0
  46. package/dist/development/lib/router/utils.js +76 -5
  47. package/dist/development/lib/rsc/browser.js +34 -24
  48. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  49. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  50. package/dist/development/lib/rsc/html-stream/server.js +29 -10
  51. package/dist/development/lib/rsc/route-modules.js +1 -1
  52. package/dist/development/lib/rsc/server.rsc.d.ts +8 -3
  53. package/dist/development/lib/rsc/server.ssr.d.ts +29 -6
  54. package/dist/development/lib/rsc/server.ssr.js +27 -12
  55. package/dist/development/lib/server-runtime/cookies.d.ts +28 -2
  56. package/dist/development/lib/server-runtime/cookies.js +17 -3
  57. package/dist/development/lib/server-runtime/crypto.js +1 -1
  58. package/dist/development/lib/server-runtime/data.js +1 -1
  59. package/dist/development/lib/server-runtime/dev.js +1 -1
  60. package/dist/development/lib/server-runtime/entry.js +1 -1
  61. package/dist/development/lib/server-runtime/errors.js +1 -1
  62. package/dist/development/lib/server-runtime/headers.js +1 -1
  63. package/dist/development/lib/server-runtime/invariant.js +1 -1
  64. package/dist/development/lib/server-runtime/mode.js +1 -1
  65. package/dist/development/lib/server-runtime/routeMatching.js +1 -1
  66. package/dist/development/lib/server-runtime/routes.js +1 -1
  67. package/dist/development/lib/server-runtime/server.d.ts +12 -0
  68. package/dist/development/lib/server-runtime/server.js +24 -5
  69. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  70. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
  71. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +9 -1
  72. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
  73. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +12 -6
  74. package/dist/development/lib/server-runtime/sessions.d.ts +31 -2
  75. package/dist/development/lib/server-runtime/sessions.js +20 -3
  76. package/dist/development/lib/server-runtime/single-fetch.js +1 -1
  77. package/dist/development/lib/server-runtime/urls.js +1 -1
  78. package/dist/development/lib/server-runtime/warnings.js +1 -1
  79. package/dist/development/lib/types/internal.js +1 -1
  80. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  81. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  82. package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
  83. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  84. package/dist/production/dom-export.js +1 -1
  85. package/dist/production/index-react-server-client.js +1 -1
  86. package/dist/production/index-react-server.d.ts +141 -26
  87. package/dist/production/index-react-server.js +355 -196
  88. package/dist/production/index.d.ts +3 -3
  89. package/dist/production/index.js +3 -3
  90. package/dist/production/lib/actions.js +1 -1
  91. package/dist/production/lib/components.js +38 -4
  92. package/dist/production/lib/context.d.ts +8 -3
  93. package/dist/production/lib/context.js +8 -2
  94. package/dist/production/lib/dom/dom.d.ts +24 -24
  95. package/dist/production/lib/dom/dom.js +25 -25
  96. package/dist/production/lib/dom/lib.d.ts +2 -1
  97. package/dist/production/lib/dom/lib.js +9 -8
  98. package/dist/production/lib/dom/server.js +24 -4
  99. package/dist/production/lib/dom/ssr/components.js +13 -5
  100. package/dist/production/lib/dom/ssr/data.js +1 -1
  101. package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
  102. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  103. package/dist/production/lib/dom/ssr/fog-of-war.js +26 -21
  104. package/dist/production/lib/dom/ssr/hydration.js +1 -1
  105. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  106. package/dist/production/lib/dom/ssr/links.js +1 -1
  107. package/dist/production/lib/dom/ssr/markup.js +1 -1
  108. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  109. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +13 -0
  110. package/dist/production/lib/dom/ssr/routes-test-stub.js +14 -1
  111. package/dist/production/lib/dom/ssr/routes.js +1 -1
  112. package/dist/production/lib/dom/ssr/server.js +1 -1
  113. package/dist/production/lib/dom/ssr/single-fetch.js +1 -1
  114. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  115. package/dist/production/lib/dom-export/hydrated-router.js +1 -1
  116. package/dist/production/lib/errors.js +1 -1
  117. package/dist/production/lib/hooks.d.ts +33 -6
  118. package/dist/production/lib/hooks.js +70 -36
  119. package/dist/production/lib/href.d.ts +24 -8
  120. package/dist/production/lib/href.js +31 -11
  121. package/dist/production/lib/router/history.d.ts +6 -0
  122. package/dist/production/lib/router/history.js +7 -1
  123. package/dist/production/lib/router/instrumentation.d.ts +33 -8
  124. package/dist/production/lib/router/instrumentation.js +176 -99
  125. package/dist/production/lib/router/router.js +27 -22
  126. package/dist/production/lib/router/url.js +1 -1
  127. package/dist/production/lib/router/utils.d.ts +12 -0
  128. package/dist/production/lib/router/utils.js +76 -5
  129. package/dist/production/lib/rsc/browser.js +34 -24
  130. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  131. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  132. package/dist/production/lib/rsc/html-stream/server.js +29 -10
  133. package/dist/production/lib/rsc/route-modules.js +1 -1
  134. package/dist/production/lib/rsc/server.rsc.d.ts +8 -3
  135. package/dist/production/lib/rsc/server.ssr.d.ts +29 -6
  136. package/dist/production/lib/rsc/server.ssr.js +27 -12
  137. package/dist/production/lib/server-runtime/cookies.d.ts +28 -2
  138. package/dist/production/lib/server-runtime/cookies.js +17 -3
  139. package/dist/production/lib/server-runtime/crypto.js +1 -1
  140. package/dist/production/lib/server-runtime/data.js +1 -1
  141. package/dist/production/lib/server-runtime/dev.js +1 -1
  142. package/dist/production/lib/server-runtime/entry.js +1 -1
  143. package/dist/production/lib/server-runtime/errors.js +1 -1
  144. package/dist/production/lib/server-runtime/headers.js +1 -1
  145. package/dist/production/lib/server-runtime/invariant.js +1 -1
  146. package/dist/production/lib/server-runtime/mode.js +1 -1
  147. package/dist/production/lib/server-runtime/routeMatching.js +1 -1
  148. package/dist/production/lib/server-runtime/routes.js +1 -1
  149. package/dist/production/lib/server-runtime/server.d.ts +12 -0
  150. package/dist/production/lib/server-runtime/server.js +24 -5
  151. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  152. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
  153. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +9 -1
  154. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
  155. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +12 -6
  156. package/dist/production/lib/server-runtime/sessions.d.ts +31 -2
  157. package/dist/production/lib/server-runtime/sessions.js +20 -3
  158. package/dist/production/lib/server-runtime/single-fetch.js +1 -1
  159. package/dist/production/lib/server-runtime/urls.js +1 -1
  160. package/dist/production/lib/server-runtime/warnings.js +1 -1
  161. package/dist/production/lib/types/internal.js +1 -1
  162. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  163. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  164. package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
  165. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  166. package/docs/explanation/hot-module-replacement.md +1 -1
  167. package/docs/explanation/sessions-and-cookies.md +13 -13
  168. package/docs/explanation/state-management.md +2 -2
  169. package/docs/how-to/data-strategy.md +1 -1
  170. package/docs/how-to/instrumentation.md +131 -26
  171. package/docs/how-to/presets.md +2 -2
  172. package/docs/how-to/react-server-components.md +53 -1
  173. package/docs/how-to/security.md +8 -1
  174. package/docs/how-to/server-bundles.md +2 -2
  175. package/docs/start/data/route-object.md +2 -2
  176. package/docs/start/data/routing.md +1 -1
  177. package/docs/start/framework/deploying.md +4 -0
  178. package/docs/start/framework/pending-ui.md +1 -1
  179. package/docs/start/framework/route-module.md +8 -8
  180. package/docs/start/framework/routing.md +1 -1
  181. package/docs/upgrading/component-routes.md +2 -2
  182. package/docs/upgrading/future.md +33 -0
  183. package/docs/upgrading/router-provider.md +6 -6
  184. package/docs/upgrading/v7.md +39 -22
  185. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,95 @@
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
+ - Add `nonce` options to `unstable_routeRSCServerRequest` and `unstable_RSCStaticRouter`
39
+ - Forward the nonce to the HTML renderer and apply it to injected RSC payload scripts and nonce-aware framework components
40
+
41
+ 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:
42
+
43
+ ```tsx
44
+ const nonce = crypto.randomUUID();
45
+ const response = await routeRSCServerRequest({
46
+ request,
47
+ serverResponse,
48
+ createFromReadableStream,
49
+ nonce,
50
+ async renderHTML(getPayload, options) {
51
+ const payload = getPayload();
52
+ return renderHTMLToReadableStream(
53
+ <RSCStaticRouter getPayload={getPayload} nonce={options.nonce} />,
54
+ {
55
+ ...options,
56
+ bootstrapScriptContent,
57
+ formState: await payload.formState,
58
+ signal: request.signal,
59
+ },
60
+ );
61
+ },
62
+ });
63
+ response.headers.set(
64
+ "Content-Security-Policy",
65
+ `script-src 'self' 'nonce-${nonce}'`,
66
+ );
67
+ ```
68
+
69
+ ## v8.2.0
70
+
71
+ ### Patch Changes
72
+
73
+ - Fix `href()` to properly stringify and URL-encode param values, matching `generatePath()` ([#15277](https://github.com/remix-run/react-router/pull/15277))
74
+ - splat params preserve path separators while encoding each segment individually
75
+ - Fix dynamic param extraction for routes with optional static segments ([#15200](https://github.com/remix-run/react-router/pull/15200))
76
+ - When a route path contains optional static segments (e.g. `/school?/user/:id`), the internal regex's incorrectly shifted parameter indices resulting in incorrect parameter extraction
77
+ - Consecutive optional static segments (e.g. `/one?/two?`) were only partially handled
78
+ - Preserve navigation blocker state through a revalidation ([#15246](https://github.com/remix-run/react-router/pull/15246))
79
+ - Fix route ranking for dynamic parameters with static extension suffixes ([#15273](https://github.com/remix-run/react-router/pull/15273))
80
+ - These were not being detected as dynamic param segments and instead got incorrectly scored higher as a static segment
81
+ - This meant they could potentially tie truly static routes like `/sitemap.xml` and outrank them based on definition order
82
+ - These are now correctly identified as dynamic parameter segments and scored correctly
83
+ - Use ReactFormState types instead of unknown ([#15263](https://github.com/remix-run/react-router/pull/15263))
84
+
85
+ ## v8.1.0
86
+
87
+ ### Minor Changes
88
+
89
+ - Return route metadata from server request, client navigation, and client fetcher instrumentations ([#15235](https://github.com/remix-run/react-router/pull/15235))
90
+ - Adds result metadata after instrumented calls complete, including the URL, matched route pattern, and params
91
+ - Adds known HTTP status codes to server request handler instrumentation results
92
+
3
93
  ## v8.0.1
4
94
 
5
95
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-abd9fc79b
2
+ * react-router v0.0.0-experimental-479e73b7b
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-abd9fc79b
2
+ * react-router v0.0.0-experimental-479e73b7b
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2,6 +2,7 @@
2
2
  import * as React from "react";
3
3
  import { CookieParseOptions, CookieParseOptions as CookieParseOptions$1, CookieSerializeOptions, CookieSerializeOptions as CookieSerializeOptions$1 } from "cookie-es";
4
4
  import { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from "react-router/internal/react-server-client";
5
+ import { ReactFormState } from "react-dom/client";
5
6
 
6
7
  //#region lib/router/history.d.ts
7
8
  /**
@@ -1009,6 +1010,19 @@ type ClientInstrumentation = {
1009
1010
  type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
1010
1011
  type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
1011
1012
  type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
1013
+ /**
1014
+ * Route metadata available after React Router has matched an instrumented
1015
+ * request, navigation, or fetcher call.
1016
+ */
1017
+ type InstrumentationResultMeta = {
1018
+ url: LoaderFunctionArgs["url"];
1019
+ pattern: string;
1020
+ params: LoaderFunctionArgs["params"];
1021
+ };
1022
+ /**
1023
+ * Result returned by route-level instrumented handler calls, such as
1024
+ * instrumented loaders, actions, middleware, and lazy route functions.
1025
+ */
1012
1026
  type InstrumentationHandlerResult = {
1013
1027
  status: "success";
1014
1028
  error: undefined;
@@ -1016,7 +1030,21 @@ type InstrumentationHandlerResult = {
1016
1030
  status: "error";
1017
1031
  error: Error;
1018
1032
  };
1019
- type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>;
1033
+ /**
1034
+ * Result returned by client-side router instrumented navigation and fetcher
1035
+ * calls.
1036
+ */
1037
+ type InstrumentationClientRouterResult = InstrumentationHandlerResult & {
1038
+ meta: InstrumentationResultMeta | undefined;
1039
+ };
1040
+ /**
1041
+ * Result returned by server request handler instrumentation.
1042
+ */
1043
+ type InstrumentationServerHandlerResult = InstrumentationHandlerResult & {
1044
+ statusCode: number;
1045
+ meta: InstrumentationResultMeta | undefined;
1046
+ };
1047
+ type InstrumentFunction<T, TInnerResult = InstrumentationHandlerResult> = (handler: () => Promise<TInnerResult>, info: T) => Promise<void>;
1020
1048
  type ReadonlyRequest = {
1021
1049
  method: string;
1022
1050
  url: string;
@@ -1039,18 +1067,16 @@ type RouteInstrumentations = {
1039
1067
  action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1040
1068
  };
1041
1069
  type RouteLazyInstrumentationInfo = undefined;
1042
- type RouteHandlerInstrumentationInfo = Readonly<{
1070
+ type RouteHandlerInstrumentationInfo = Readonly<Omit<LoaderFunctionArgs, "request" | "context"> & {
1043
1071
  request: ReadonlyRequest;
1044
- params: LoaderFunctionArgs["params"];
1045
- pattern: string;
1046
1072
  context: ReadonlyContext;
1047
1073
  }>;
1048
1074
  type InstrumentableRouter = {
1049
1075
  instrument(instrumentations: RouterInstrumentations): void;
1050
1076
  };
1051
1077
  type RouterInstrumentations = {
1052
- navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
1053
- fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
1078
+ navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo, InstrumentationClientRouterResult>;
1079
+ fetch?: InstrumentFunction<RouterFetchInstrumentationInfo, InstrumentationClientRouterResult>;
1054
1080
  };
1055
1081
  type RouterNavigationInstrumentationInfo = Readonly<{
1056
1082
  to: string | number;
@@ -1073,7 +1099,7 @@ type InstrumentableRequestHandler = {
1073
1099
  instrument(instrumentations: RequestHandlerInstrumentations): void;
1074
1100
  };
1075
1101
  type RequestHandlerInstrumentations = {
1076
- request?: InstrumentFunction<RequestHandlerInstrumentationInfo>;
1102
+ request?: InstrumentFunction<RequestHandlerInstrumentationInfo, InstrumentationServerHandlerResult>;
1077
1103
  };
1078
1104
  type RequestHandlerInstrumentationInfo = Readonly<{
1079
1105
  request: ReadonlyRequest;
@@ -2292,14 +2318,14 @@ type RSCRenderPayload = {
2292
2318
  type: "render";
2293
2319
  actionData: Record<string, any> | null;
2294
2320
  basename: string | undefined;
2321
+ clientVersion?: string;
2295
2322
  errors: Record<string, any> | null;
2296
2323
  loaderData: Record<string, any>;
2297
2324
  location: Location;
2298
2325
  routeDiscovery: RouteDiscovery;
2299
2326
  matches: RSCRouteMatch[];
2300
2327
  patches?: Promise<RSCRouteManifest[]>;
2301
- nonce?: string;
2302
- formState?: unknown;
2328
+ formState?: ReactFormState;
2303
2329
  };
2304
2330
  type RSCManifestPayload = {
2305
2331
  type: "manifest";
@@ -2325,7 +2351,7 @@ type RSCMatch = {
2325
2351
  payload: RSCPayload;
2326
2352
  };
2327
2353
  type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
2328
- type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
2354
+ type DecodeFormStateFunction = (result: unknown, formData: FormData) => Promise<ReactFormState | undefined>;
2329
2355
  type DecodeReplyFunction = (reply: FormData | string, options: {
2330
2356
  temporaryReferences: unknown;
2331
2357
  }) => Promise<unknown[]>;
@@ -2395,6 +2421,8 @@ type RouteDiscovery = {
2395
2421
  * encoding the {@link unstable_RSCPayload}.
2396
2422
  * @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
2397
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.
2398
2426
  * @param opts.onError An optional error handler that will be called with any
2399
2427
  * errors that occur during the request processing.
2400
2428
  * @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
@@ -2418,6 +2446,7 @@ declare function matchRSCServerRequest({
2418
2446
  loadServerAction,
2419
2447
  decodeAction,
2420
2448
  decodeFormState,
2449
+ clientVersion,
2421
2450
  onError,
2422
2451
  request,
2423
2452
  routes,
@@ -2431,6 +2460,7 @@ declare function matchRSCServerRequest({
2431
2460
  decodeFormState?: DecodeFormStateFunction;
2432
2461
  requestContext?: RouterContextProvider;
2433
2462
  loadServerAction?: LoadServerActionFunction;
2463
+ clientVersion?: string;
2434
2464
  onError?: (error: unknown) => void;
2435
2465
  request: Request;
2436
2466
  routes: RSCRouteConfigEntry[];
@@ -2464,14 +2494,30 @@ type Pages = Register extends {
2464
2494
  type Args = { [K in keyof Pages]: ToArgs<Pages[K]["params"]> };
2465
2495
  type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [Params];
2466
2496
  /**
2467
- Returns a resolved URL path for the specified route.
2468
-
2469
- ```tsx
2470
- const h = href("/:lang?/about", { lang: "en" })
2471
- // -> `/en/about`
2472
-
2473
- <Link to={href("/products/:id", { id: "abc123" })} />
2474
- ```
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
2475
2521
  */
2476
2522
  declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
2477
2523
  //#endregion
@@ -2527,13 +2573,39 @@ interface Cookie {
2527
2573
  }
2528
2574
  /**
2529
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.
2530
2584
  */
2531
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
+ */
2532
2598
  type IsCookieFunction = (object: any) => object is Cookie;
2533
2599
  /**
2534
- * Returns true if an object is a Remix cookie container.
2600
+ * Returns `true` if a value is a React Router {@link Cookie} object.
2535
2601
  *
2536
- * @see https://remix.run/utils/cookies#iscookie
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`.
2537
2609
  */
2538
2610
  declare const isCookie: IsCookieFunction;
2539
2611
  //#endregion
@@ -2595,13 +2667,37 @@ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?
2595
2667
  *
2596
2668
  * Note: This function is typically not invoked directly by application code.
2597
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.
2598
2676
  */
2599
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
+ */
2600
2690
  type IsSessionFunction = (object: any) => object is Session;
2601
2691
  /**
2602
- * Returns true if an object is a React Router session.
2692
+ * Returns `true` if a value is a React Router {@link Session} object.
2603
2693
  *
2604
- * @see https://reactrouter.com/api/utils/isSession
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`.
2605
2701
  */
2606
2702
  declare const isSession: IsSessionFunction;
2607
2703
  /**
@@ -2668,6 +2764,11 @@ interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
2668
2764
  *
2669
2765
  * Note: This is a low-level API that should only be used if none of the
2670
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.
2671
2772
  */
2672
2773
  declare function createSessionStorage<Data = SessionData, FlashData = Data>({
2673
2774
  cookie: cookieArg,
@@ -2693,6 +2794,14 @@ interface CookieSessionStorageOptions {
2693
2794
  * needed, and can help to simplify some load-balanced scenarios. However, it
2694
2795
  * also has the limitation that serialized session data may not exceed the
2695
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.
2696
2805
  */
2697
2806
  declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({
2698
2807
  cookie: cookieArg
@@ -2707,11 +2816,17 @@ interface MemorySessionStorageOptions {
2707
2816
  cookie?: SessionIdStorageStrategy["cookie"];
2708
2817
  }
2709
2818
  /**
2710
- * Creates and returns a simple in-memory SessionStorage object, mostly useful
2711
- * for testing and as a reference implementation.
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.
2712
2823
  *
2713
- * Note: This storage does not scale beyond a single process, so it is not
2714
- * suitable for most production scenarios.
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.
2715
2830
  */
2716
2831
  declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
2717
2832
  cookie