react-router 0.0.0-experimental-abd9fc79b → 0.0.0-experimental-2a01b6fd8

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 (195) 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 +172 -47
  5. package/dist/development/index-react-server.js +608 -215
  6. package/dist/development/index.d.ts +2 -2
  7. package/dist/development/index.js +1 -1
  8. package/dist/development/lib/actions.js +1 -1
  9. package/dist/development/lib/components.js +6 -5
  10. package/dist/development/lib/context.js +1 -1
  11. package/dist/development/lib/dom/dom.d.ts +24 -24
  12. package/dist/development/lib/dom/dom.js +26 -26
  13. package/dist/development/lib/dom/lib.d.ts +2 -1
  14. package/dist/development/lib/dom/lib.js +8 -7
  15. package/dist/development/lib/dom/server.d.ts +6 -1
  16. package/dist/development/lib/dom/server.js +13 -9
  17. package/dist/development/lib/dom/ssr/components.js +5 -6
  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 +28 -23
  22. package/dist/development/lib/dom/ssr/hydration.d.ts +3 -1
  23. package/dist/development/lib/dom/ssr/hydration.js +6 -4
  24. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  25. package/dist/development/lib/dom/ssr/links.js +1 -1
  26. package/dist/development/lib/dom/ssr/markup.js +1 -1
  27. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  28. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +13 -0
  29. package/dist/development/lib/dom/ssr/routes-test-stub.js +14 -1
  30. package/dist/development/lib/dom/ssr/routes.js +1 -1
  31. package/dist/development/lib/dom/ssr/server.js +2 -2
  32. package/dist/development/lib/dom/ssr/single-fetch.js +5 -5
  33. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  34. package/dist/development/lib/dom-export/hydrated-router.js +2 -1
  35. package/dist/development/lib/errors.js +1 -1
  36. package/dist/development/lib/hooks.d.ts +33 -6
  37. package/dist/development/lib/hooks.js +38 -8
  38. package/dist/development/lib/href.d.ts +24 -8
  39. package/dist/development/lib/href.js +31 -11
  40. package/dist/development/lib/router/history.d.ts +6 -0
  41. package/dist/development/lib/router/history.js +8 -2
  42. package/dist/development/lib/router/instrumentation.d.ts +33 -8
  43. package/dist/development/lib/router/instrumentation.js +176 -99
  44. package/dist/development/lib/router/matcher-route-pattern.js +213 -0
  45. package/dist/development/lib/router/matcher.d.ts +2 -0
  46. package/dist/development/lib/router/matcher.js +30 -0
  47. package/dist/development/lib/router/router.d.ts +6 -3
  48. package/dist/development/lib/router/router.js +72 -74
  49. package/dist/development/lib/router/url.js +1 -1
  50. package/dist/development/lib/router/utils.d.ts +20 -1
  51. package/dist/development/lib/router/utils.js +81 -8
  52. package/dist/development/lib/rsc/browser.js +35 -24
  53. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  54. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  55. package/dist/development/lib/rsc/html-stream/server.js +30 -11
  56. package/dist/development/lib/rsc/route-modules.js +1 -1
  57. package/dist/development/lib/rsc/server.rsc.d.ts +8 -3
  58. package/dist/development/lib/rsc/server.ssr.d.ts +29 -6
  59. package/dist/development/lib/rsc/server.ssr.js +28 -13
  60. package/dist/development/lib/server-runtime/cookies.d.ts +28 -2
  61. package/dist/development/lib/server-runtime/cookies.js +18 -4
  62. package/dist/development/lib/server-runtime/crypto.js +2 -2
  63. package/dist/development/lib/server-runtime/data.js +1 -1
  64. package/dist/development/lib/server-runtime/dev.js +2 -2
  65. package/dist/development/lib/server-runtime/entry.js +1 -1
  66. package/dist/development/lib/server-runtime/errors.js +1 -1
  67. package/dist/development/lib/server-runtime/headers.js +1 -1
  68. package/dist/development/lib/server-runtime/invariant.js +1 -1
  69. package/dist/development/lib/server-runtime/mode.js +1 -1
  70. package/dist/development/lib/server-runtime/routeMatching.js +3 -4
  71. package/dist/development/lib/server-runtime/routes.js +1 -1
  72. package/dist/development/lib/server-runtime/server.d.ts +12 -0
  73. package/dist/development/lib/server-runtime/server.js +32 -11
  74. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  75. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
  76. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +9 -1
  77. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
  78. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +12 -6
  79. package/dist/development/lib/server-runtime/sessions.d.ts +31 -2
  80. package/dist/development/lib/server-runtime/sessions.js +20 -3
  81. package/dist/development/lib/server-runtime/single-fetch.js +2 -2
  82. package/dist/development/lib/server-runtime/urls.js +1 -1
  83. package/dist/development/lib/server-runtime/warnings.js +1 -1
  84. package/dist/development/lib/types/internal.js +1 -1
  85. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  86. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +4 -4
  87. package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
  88. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  89. package/dist/production/dom-export.js +1 -1
  90. package/dist/production/index-react-server-client.js +1 -1
  91. package/dist/production/index-react-server.d.ts +172 -47
  92. package/dist/production/index-react-server.js +608 -215
  93. package/dist/production/index.d.ts +2 -2
  94. package/dist/production/index.js +1 -1
  95. package/dist/production/lib/actions.js +1 -1
  96. package/dist/production/lib/components.js +6 -5
  97. package/dist/production/lib/context.js +1 -1
  98. package/dist/production/lib/dom/dom.d.ts +24 -24
  99. package/dist/production/lib/dom/dom.js +26 -26
  100. package/dist/production/lib/dom/lib.d.ts +2 -1
  101. package/dist/production/lib/dom/lib.js +8 -7
  102. package/dist/production/lib/dom/server.d.ts +6 -1
  103. package/dist/production/lib/dom/server.js +13 -9
  104. package/dist/production/lib/dom/ssr/components.js +5 -6
  105. package/dist/production/lib/dom/ssr/data.js +1 -1
  106. package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
  107. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  108. package/dist/production/lib/dom/ssr/fog-of-war.js +28 -23
  109. package/dist/production/lib/dom/ssr/hydration.d.ts +3 -1
  110. package/dist/production/lib/dom/ssr/hydration.js +6 -4
  111. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  112. package/dist/production/lib/dom/ssr/links.js +1 -1
  113. package/dist/production/lib/dom/ssr/markup.js +1 -1
  114. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  115. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +13 -0
  116. package/dist/production/lib/dom/ssr/routes-test-stub.js +14 -1
  117. package/dist/production/lib/dom/ssr/routes.js +1 -1
  118. package/dist/production/lib/dom/ssr/server.js +2 -2
  119. package/dist/production/lib/dom/ssr/single-fetch.js +5 -5
  120. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  121. package/dist/production/lib/dom-export/hydrated-router.js +2 -1
  122. package/dist/production/lib/errors.js +1 -1
  123. package/dist/production/lib/hooks.d.ts +33 -6
  124. package/dist/production/lib/hooks.js +38 -8
  125. package/dist/production/lib/href.d.ts +24 -8
  126. package/dist/production/lib/href.js +31 -11
  127. package/dist/production/lib/router/history.d.ts +6 -0
  128. package/dist/production/lib/router/history.js +8 -2
  129. package/dist/production/lib/router/instrumentation.d.ts +33 -8
  130. package/dist/production/lib/router/instrumentation.js +176 -99
  131. package/dist/production/lib/router/matcher-route-pattern.js +213 -0
  132. package/dist/production/lib/router/matcher.d.ts +2 -0
  133. package/dist/production/lib/router/matcher.js +30 -0
  134. package/dist/production/lib/router/router.d.ts +6 -3
  135. package/dist/production/lib/router/router.js +72 -74
  136. package/dist/production/lib/router/url.js +1 -1
  137. package/dist/production/lib/router/utils.d.ts +20 -1
  138. package/dist/production/lib/router/utils.js +81 -8
  139. package/dist/production/lib/rsc/browser.js +35 -24
  140. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  141. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  142. package/dist/production/lib/rsc/html-stream/server.js +30 -11
  143. package/dist/production/lib/rsc/route-modules.js +1 -1
  144. package/dist/production/lib/rsc/server.rsc.d.ts +8 -3
  145. package/dist/production/lib/rsc/server.ssr.d.ts +29 -6
  146. package/dist/production/lib/rsc/server.ssr.js +28 -13
  147. package/dist/production/lib/server-runtime/cookies.d.ts +28 -2
  148. package/dist/production/lib/server-runtime/cookies.js +18 -4
  149. package/dist/production/lib/server-runtime/crypto.js +2 -2
  150. package/dist/production/lib/server-runtime/data.js +1 -1
  151. package/dist/production/lib/server-runtime/dev.js +2 -2
  152. package/dist/production/lib/server-runtime/entry.js +1 -1
  153. package/dist/production/lib/server-runtime/errors.js +1 -1
  154. package/dist/production/lib/server-runtime/headers.js +1 -1
  155. package/dist/production/lib/server-runtime/invariant.js +1 -1
  156. package/dist/production/lib/server-runtime/mode.js +1 -1
  157. package/dist/production/lib/server-runtime/routeMatching.js +3 -4
  158. package/dist/production/lib/server-runtime/routes.js +1 -1
  159. package/dist/production/lib/server-runtime/server.d.ts +12 -0
  160. package/dist/production/lib/server-runtime/server.js +32 -11
  161. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  162. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
  163. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +9 -1
  164. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
  165. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +12 -6
  166. package/dist/production/lib/server-runtime/sessions.d.ts +31 -2
  167. package/dist/production/lib/server-runtime/sessions.js +20 -3
  168. package/dist/production/lib/server-runtime/single-fetch.js +2 -2
  169. package/dist/production/lib/server-runtime/urls.js +1 -1
  170. package/dist/production/lib/server-runtime/warnings.js +1 -1
  171. package/dist/production/lib/types/internal.js +1 -1
  172. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  173. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +4 -4
  174. package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
  175. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  176. package/docs/explanation/hot-module-replacement.md +1 -1
  177. package/docs/explanation/sessions-and-cookies.md +13 -13
  178. package/docs/explanation/state-management.md +2 -2
  179. package/docs/how-to/data-strategy.md +1 -1
  180. package/docs/how-to/instrumentation.md +131 -26
  181. package/docs/how-to/presets.md +2 -2
  182. package/docs/how-to/react-server-components.md +53 -1
  183. package/docs/how-to/security.md +8 -1
  184. package/docs/how-to/server-bundles.md +2 -2
  185. package/docs/start/data/route-object.md +2 -2
  186. package/docs/start/data/routing.md +1 -1
  187. package/docs/start/framework/deploying.md +4 -0
  188. package/docs/start/framework/pending-ui.md +1 -1
  189. package/docs/start/framework/route-module.md +8 -8
  190. package/docs/start/framework/routing.md +1 -1
  191. package/docs/upgrading/component-routes.md +2 -2
  192. package/docs/upgrading/future.md +33 -0
  193. package/docs/upgrading/router-provider.md +6 -6
  194. package/docs/upgrading/v7.md +39 -22
  195. package/package.json +2 -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-2a01b6fd8
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-2a01b6fd8
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
  /**
@@ -49,7 +50,7 @@ interface Path {
49
50
  * An entry in a history stack. A location contains information about the
50
51
  * URL path, as well as possibly some arbitrary state and a key.
51
52
  */
52
- interface Location<State = any> extends Path {
53
+ interface Location$1<State = any> extends Path {
53
54
  /**
54
55
  * A value of arbitrary data associated with this location.
55
56
  */
@@ -78,7 +79,7 @@ interface Update {
78
79
  /**
79
80
  * The new location.
80
81
  */
81
- location: Location;
82
+ location: Location$1;
82
83
  /**
83
84
  * The delta between this location and the former location in the history stack
84
85
  */
@@ -112,7 +113,7 @@ interface History {
112
113
  /**
113
114
  * The current location. This value is mutable.
114
115
  */
115
- readonly location: Location;
116
+ readonly location: Location$1;
116
117
  /**
117
118
  * Returns a valid href for the given `to` value that may be used as
118
119
  * the value of an <a href> attribute.
@@ -487,6 +488,9 @@ interface ShouldRevalidateFunctionArgs {
487
488
  interface ShouldRevalidateFunction {
488
489
  (args: ShouldRevalidateFunctionArgs): boolean;
489
490
  }
491
+ interface UnstableValidateParamsFunction {
492
+ (params: Params): boolean;
493
+ }
490
494
  interface DataStrategyMatch extends RouteMatch<string, DataRouteObject> {
491
495
  /**
492
496
  * @private
@@ -596,7 +600,7 @@ interface MapRoutePropertiesFunction {
596
600
  * onto the route. Either they're meaningful to the router, or they'll get
597
601
  * ignored.
598
602
  */
599
- type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
603
+ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children" | "unstable_validateParams";
600
604
  /**
601
605
  * Keys we cannot change from within a lazy() function. We spread all other keys
602
606
  * onto the route. Either they're meaningful to the router, or they'll get
@@ -654,6 +658,10 @@ type BaseRouteObject = {
654
658
  * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
655
659
  */
656
660
  shouldRevalidate?: ShouldRevalidateFunction;
661
+ /**
662
+ * Validate route params after a route-pattern match.
663
+ */
664
+ unstable_validateParams?: UnstableValidateParamsFunction;
657
665
  /**
658
666
  * The route handle.
659
667
  */
@@ -790,7 +798,7 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {}
790
798
  * Defaults to `/`.
791
799
  * @returns An array of matched routes, or `null` if no matches were found.
792
800
  */
793
- declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
801
+ declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location$1> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
794
802
  interface UIMatch<Data = unknown, Handle = unknown> {
795
803
  id: string;
796
804
  pathname: string;
@@ -1009,6 +1017,19 @@ type ClientInstrumentation = {
1009
1017
  type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
1010
1018
  type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
1011
1019
  type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
1020
+ /**
1021
+ * Route metadata available after React Router has matched an instrumented
1022
+ * request, navigation, or fetcher call.
1023
+ */
1024
+ type InstrumentationResultMeta = {
1025
+ url: LoaderFunctionArgs["url"];
1026
+ pattern: string;
1027
+ params: LoaderFunctionArgs["params"];
1028
+ };
1029
+ /**
1030
+ * Result returned by route-level instrumented handler calls, such as
1031
+ * instrumented loaders, actions, middleware, and lazy route functions.
1032
+ */
1012
1033
  type InstrumentationHandlerResult = {
1013
1034
  status: "success";
1014
1035
  error: undefined;
@@ -1016,7 +1037,21 @@ type InstrumentationHandlerResult = {
1016
1037
  status: "error";
1017
1038
  error: Error;
1018
1039
  };
1019
- type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>;
1040
+ /**
1041
+ * Result returned by client-side router instrumented navigation and fetcher
1042
+ * calls.
1043
+ */
1044
+ type InstrumentationClientRouterResult = InstrumentationHandlerResult & {
1045
+ meta: InstrumentationResultMeta | undefined;
1046
+ };
1047
+ /**
1048
+ * Result returned by server request handler instrumentation.
1049
+ */
1050
+ type InstrumentationServerHandlerResult = InstrumentationHandlerResult & {
1051
+ statusCode: number;
1052
+ meta: InstrumentationResultMeta | undefined;
1053
+ };
1054
+ type InstrumentFunction<T, TInnerResult = InstrumentationHandlerResult> = (handler: () => Promise<TInnerResult>, info: T) => Promise<void>;
1020
1055
  type ReadonlyRequest = {
1021
1056
  method: string;
1022
1057
  url: string;
@@ -1039,18 +1074,16 @@ type RouteInstrumentations = {
1039
1074
  action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1040
1075
  };
1041
1076
  type RouteLazyInstrumentationInfo = undefined;
1042
- type RouteHandlerInstrumentationInfo = Readonly<{
1077
+ type RouteHandlerInstrumentationInfo = Readonly<Omit<LoaderFunctionArgs, "request" | "context"> & {
1043
1078
  request: ReadonlyRequest;
1044
- params: LoaderFunctionArgs["params"];
1045
- pattern: string;
1046
1079
  context: ReadonlyContext;
1047
1080
  }>;
1048
1081
  type InstrumentableRouter = {
1049
1082
  instrument(instrumentations: RouterInstrumentations): void;
1050
1083
  };
1051
1084
  type RouterInstrumentations = {
1052
- navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
1053
- fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
1085
+ navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo, InstrumentationClientRouterResult>;
1086
+ fetch?: InstrumentFunction<RouterFetchInstrumentationInfo, InstrumentationClientRouterResult>;
1054
1087
  };
1055
1088
  type RouterNavigationInstrumentationInfo = Readonly<{
1056
1089
  to: string | number;
@@ -1073,7 +1106,7 @@ type InstrumentableRequestHandler = {
1073
1106
  instrument(instrumentations: RequestHandlerInstrumentations): void;
1074
1107
  };
1075
1108
  type RequestHandlerInstrumentations = {
1076
- request?: InstrumentFunction<RequestHandlerInstrumentationInfo>;
1109
+ request?: InstrumentFunction<RequestHandlerInstrumentationInfo, InstrumentationServerHandlerResult>;
1077
1110
  };
1078
1111
  type RequestHandlerInstrumentationInfo = Readonly<{
1079
1112
  request: ReadonlyRequest;
@@ -1117,9 +1150,10 @@ interface Router$1 {
1117
1150
  * @private
1118
1151
  * PRIVATE - DO NOT USE
1119
1152
  *
1120
- * Return the route branches for this router instance
1153
+ * Match routes against a location using the router's configured route
1154
+ * matching implementation.
1121
1155
  */
1122
- get branches(): RouteBranch<DataRouteObject>[] | undefined;
1156
+ match(locationArg: Partial<Location$1> | string): DataRouteMatch[] | null;
1123
1157
  /**
1124
1158
  * @private
1125
1159
  * PRIVATE - DO NOT USE
@@ -1204,7 +1238,7 @@ interface Router$1 {
1204
1238
  * Utility function to create an href for the given location
1205
1239
  * @param location
1206
1240
  */
1207
- createHref(location: Location | URL): string;
1241
+ createHref(location: Location$1 | URL): string;
1208
1242
  /**
1209
1243
  * @private
1210
1244
  * PRIVATE - DO NOT USE
@@ -1312,7 +1346,7 @@ interface RouterState {
1312
1346
  /**
1313
1347
  * The current location reflected by the router
1314
1348
  */
1315
- location: Location;
1349
+ location: Location$1;
1316
1350
  /**
1317
1351
  * The current set of route matches
1318
1352
  */
@@ -1373,7 +1407,9 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
1373
1407
  /**
1374
1408
  * Future flags to toggle new feature behavior
1375
1409
  */
1376
- interface FutureConfig {}
1410
+ interface FutureConfig {
1411
+ unstable_routePatternMatching?: boolean;
1412
+ }
1377
1413
  /**
1378
1414
  * Initialization options for createRouter
1379
1415
  */
@@ -1469,8 +1505,8 @@ interface StaticHandler {
1469
1505
  }): Promise<any>;
1470
1506
  }
1471
1507
  type ViewTransitionOpts = {
1472
- currentLocation: Location;
1473
- nextLocation: Location;
1508
+ currentLocation: Location$1;
1509
+ nextLocation: Location$1;
1474
1510
  };
1475
1511
  /**
1476
1512
  * Subscriber function signature for changes to router state
@@ -1488,7 +1524,7 @@ interface RouterSubscriber {
1488
1524
  * for a given location
1489
1525
  */
1490
1526
  interface GetScrollRestorationKeyFunction {
1491
- (location: Location, matches: UIMatch[]): string | null;
1527
+ (location: Location$1, matches: UIMatch[]): string | null;
1492
1528
  }
1493
1529
  /**
1494
1530
  * Function signature for determining the current scroll position
@@ -1570,7 +1606,7 @@ type NavigationStates = {
1570
1606
  };
1571
1607
  Loading: {
1572
1608
  state: "loading";
1573
- location: Location;
1609
+ location: Location$1;
1574
1610
  matches: DataRouteMatch[];
1575
1611
  historyAction: Action;
1576
1612
  formMethod: Submission["formMethod"] | undefined;
@@ -1582,7 +1618,7 @@ type NavigationStates = {
1582
1618
  };
1583
1619
  Submitting: {
1584
1620
  state: "submitting";
1585
- location: Location;
1621
+ location: Location$1;
1586
1622
  matches: DataRouteMatch[];
1587
1623
  historyAction: Action;
1588
1624
  formMethod: Submission["formMethod"];
@@ -1672,7 +1708,7 @@ interface BlockerBlocked {
1672
1708
  state: "blocked";
1673
1709
  reset: () => void;
1674
1710
  proceed: () => void;
1675
- location: Location;
1711
+ location: Location$1;
1676
1712
  }
1677
1713
  interface BlockerUnblocked {
1678
1714
  state: "unblocked";
@@ -1684,12 +1720,12 @@ interface BlockerProceeding {
1684
1720
  state: "proceeding";
1685
1721
  reset: undefined;
1686
1722
  proceed: undefined;
1687
- location: Location;
1723
+ location: Location$1;
1688
1724
  }
1689
1725
  type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1690
1726
  type BlockerFunction = (args: {
1691
- currentLocation: Location;
1692
- nextLocation: Location;
1727
+ currentLocation: Location$1;
1728
+ nextLocation: Location$1;
1693
1729
  historyAction: Action;
1694
1730
  }) => boolean;
1695
1731
  interface CreateStaticHandlerOptions {
@@ -1974,7 +2010,7 @@ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoad
1974
2010
  interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
1975
2011
  loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
1976
2012
  params: Params;
1977
- location: Location;
2013
+ location: Location$1;
1978
2014
  matches: MetaMatches<MatchLoaders>;
1979
2015
  error?: unknown;
1980
2016
  }
@@ -2292,14 +2328,14 @@ type RSCRenderPayload = {
2292
2328
  type: "render";
2293
2329
  actionData: Record<string, any> | null;
2294
2330
  basename: string | undefined;
2331
+ clientVersion?: string;
2295
2332
  errors: Record<string, any> | null;
2296
2333
  loaderData: Record<string, any>;
2297
- location: Location;
2334
+ location: Location$1;
2298
2335
  routeDiscovery: RouteDiscovery;
2299
2336
  matches: RSCRouteMatch[];
2300
2337
  patches?: Promise<RSCRouteManifest[]>;
2301
- nonce?: string;
2302
- formState?: unknown;
2338
+ formState?: ReactFormState;
2303
2339
  };
2304
2340
  type RSCManifestPayload = {
2305
2341
  type: "manifest";
@@ -2325,7 +2361,7 @@ type RSCMatch = {
2325
2361
  payload: RSCPayload;
2326
2362
  };
2327
2363
  type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
2328
- type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
2364
+ type DecodeFormStateFunction = (result: unknown, formData: FormData) => Promise<ReactFormState | undefined>;
2329
2365
  type DecodeReplyFunction = (reply: FormData | string, options: {
2330
2366
  temporaryReferences: unknown;
2331
2367
  }) => Promise<unknown[]>;
@@ -2395,6 +2431,8 @@ type RouteDiscovery = {
2395
2431
  * encoding the {@link unstable_RSCPayload}.
2396
2432
  * @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
2397
2433
  * `loadServerAction` function, used to load a server action by ID.
2434
+ * @param opts.clientVersion A version derived from the client build output used
2435
+ * to detect stale clients during lazy route discovery.
2398
2436
  * @param opts.onError An optional error handler that will be called with any
2399
2437
  * errors that occur during the request processing.
2400
2438
  * @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
@@ -2418,6 +2456,7 @@ declare function matchRSCServerRequest({
2418
2456
  loadServerAction,
2419
2457
  decodeAction,
2420
2458
  decodeFormState,
2459
+ clientVersion,
2421
2460
  onError,
2422
2461
  request,
2423
2462
  routes,
@@ -2431,6 +2470,7 @@ declare function matchRSCServerRequest({
2431
2470
  decodeFormState?: DecodeFormStateFunction;
2432
2471
  requestContext?: RouterContextProvider;
2433
2472
  loadServerAction?: LoadServerActionFunction;
2473
+ clientVersion?: string;
2434
2474
  onError?: (error: unknown) => void;
2435
2475
  request: Request;
2436
2476
  routes: RSCRouteConfigEntry[];
@@ -2464,14 +2504,30 @@ type Pages = Register extends {
2464
2504
  type Args = { [K in keyof Pages]: ToArgs<Pages[K]["params"]> };
2465
2505
  type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [Params];
2466
2506
  /**
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
- ```
2507
+ * Returns a resolved URL path for the specified route.
2508
+ *
2509
+ * Param values are percent-encoded for use in a path segment: characters that
2510
+ * would change the URL structure (`/`, `?`, `#`, `%`, whitespace, non-ASCII)
2511
+ * are escaped, while characters that RFC 3986 allows literally in a path
2512
+ * segment (`$ & + , ; = : @`) are kept as-is. Note this differs from query-string
2513
+ * encoding (`encodeURIComponent`/`URLSearchParams`), where those characters are
2514
+ * delimiters and must be escaped. Splat (`*`) values are encoded per segment,
2515
+ * preserving `/` separators.
2516
+ *
2517
+ * See [RFC 3986 §3.3](https://datatracker.ietf.org/doc/html/rfc3986#section-3.3)
2518
+ *
2519
+ * @example
2520
+ * const h = href("/:lang?/about", { lang: "en" })
2521
+ * // -> `/en/about`
2522
+ *
2523
+ * <Link to={href("/products/:id", { id: "abc123" })} />
2524
+ *
2525
+ * @public
2526
+ * @category Utils
2527
+ * @mode framework
2528
+ * @param path The route path to resolve
2529
+ * @param args The route params to use when resolving the path
2530
+ * @returns The resolved URL path
2475
2531
  */
2476
2532
  declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
2477
2533
  //#endregion
@@ -2527,13 +2583,39 @@ interface Cookie {
2527
2583
  }
2528
2584
  /**
2529
2585
  * Creates a logical container for managing a browser cookie from the server.
2586
+ *
2587
+ * @public
2588
+ * @category Utils
2589
+ * @mode framework
2590
+ * @mode data
2591
+ * @param name The name of the cookie.
2592
+ * @param cookieOptions Options for parsing and serializing the cookie.
2593
+ * @returns A {@link Cookie} object for parsing and serializing the cookie.
2530
2594
  */
2531
2595
  declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
2596
+ /**
2597
+ * A function that determines whether a value is a React Router {@link Cookie}
2598
+ * object.
2599
+ *
2600
+ * @public
2601
+ * @category Utils
2602
+ * @mode framework
2603
+ * @mode data
2604
+ * @param object The value to check.
2605
+ * @returns `true` if the value is a React Router {@link Cookie} object;
2606
+ * otherwise, `false`.
2607
+ */
2532
2608
  type IsCookieFunction = (object: any) => object is Cookie;
2533
2609
  /**
2534
- * Returns true if an object is a Remix cookie container.
2610
+ * Returns `true` if a value is a React Router {@link Cookie} object.
2535
2611
  *
2536
- * @see https://remix.run/utils/cookies#iscookie
2612
+ * @public
2613
+ * @category Utils
2614
+ * @mode framework
2615
+ * @mode data
2616
+ * @param object The value to check.
2617
+ * @returns `true` if the value is a React Router {@link Cookie} object;
2618
+ * otherwise, `false`.
2537
2619
  */
2538
2620
  declare const isCookie: IsCookieFunction;
2539
2621
  //#endregion
@@ -2595,13 +2677,37 @@ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?
2595
2677
  *
2596
2678
  * Note: This function is typically not invoked directly by application code.
2597
2679
  * Instead, use a `SessionStorage` object's `getSession` method.
2680
+ *
2681
+ * @category Utils
2682
+ * @param initialData The initial data for the session.
2683
+ * @param id The identifier for the session. Defaults to an empty string for a
2684
+ * new session.
2685
+ * @returns A new {@link Session} object.
2598
2686
  */
2599
2687
  declare const createSession: CreateSessionFunction;
2688
+ /**
2689
+ * A function that determines whether a value is a React Router {@link Session}
2690
+ * object.
2691
+ *
2692
+ * @public
2693
+ * @category Utils
2694
+ * @mode framework
2695
+ * @mode data
2696
+ * @param object The value to check.
2697
+ * @returns `true` if the value is a React Router {@link Session} object;
2698
+ * otherwise, `false`.
2699
+ */
2600
2700
  type IsSessionFunction = (object: any) => object is Session;
2601
2701
  /**
2602
- * Returns true if an object is a React Router session.
2702
+ * Returns `true` if a value is a React Router {@link Session} object.
2603
2703
  *
2604
- * @see https://reactrouter.com/api/utils/isSession
2704
+ * @public
2705
+ * @category Utils
2706
+ * @mode framework
2707
+ * @mode data
2708
+ * @param object The value to check.
2709
+ * @returns `true` if the value is a React Router {@link Session} object;
2710
+ * otherwise, `false`.
2605
2711
  */
2606
2712
  declare const isSession: IsSessionFunction;
2607
2713
  /**
@@ -2668,6 +2774,11 @@ interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
2668
2774
  *
2669
2775
  * Note: This is a low-level API that should only be used if none of the
2670
2776
  * existing session storage options meet your requirements.
2777
+ *
2778
+ * @category Utils
2779
+ * @param strategy The strategy used to store session identifiers and data.
2780
+ * @returns A {@link SessionStorage} object that persists session data using the
2781
+ * provided strategy.
2671
2782
  */
2672
2783
  declare function createSessionStorage<Data = SessionData, FlashData = Data>({
2673
2784
  cookie: cookieArg,
@@ -2693,6 +2804,14 @@ interface CookieSessionStorageOptions {
2693
2804
  * needed, and can help to simplify some load-balanced scenarios. However, it
2694
2805
  * also has the limitation that serialized session data may not exceed the
2695
2806
  * browser's maximum cookie size. Trade-offs!
2807
+ *
2808
+ * @public
2809
+ * @category Utils
2810
+ * @mode framework
2811
+ * @mode data
2812
+ * @param options Options for creating the cookie-backed session storage.
2813
+ * @returns A {@link SessionStorage} object that stores all session data in its
2814
+ * cookie.
2696
2815
  */
2697
2816
  declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({
2698
2817
  cookie: cookieArg
@@ -2707,11 +2826,17 @@ interface MemorySessionStorageOptions {
2707
2826
  cookie?: SessionIdStorageStrategy["cookie"];
2708
2827
  }
2709
2828
  /**
2710
- * Creates and returns a simple in-memory SessionStorage object, mostly useful
2711
- * for testing and as a reference implementation.
2829
+ * Creates and returns a simple in-memory SessionStorage object.
2830
+ *
2831
+ * Intended for local development and testing. It does not scale beyond a single
2832
+ * process, and all session data is lost when the server process stops/restarts.
2712
2833
  *
2713
- * Note: This storage does not scale beyond a single process, so it is not
2714
- * suitable for most production scenarios.
2834
+ * @public
2835
+ * @category Utils
2836
+ * @mode framework
2837
+ * @mode data
2838
+ * @param options Options for creating the in-memory session storage.
2839
+ * @returns A {@link SessionStorage} object that stores session data in memory.
2715
2840
  */
2716
2841
  declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
2717
2842
  cookie