react-router 8.3.1 → 8.5.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.
Files changed (218) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/dist/development/dom-export.d.ts +2 -1
  3. package/dist/development/dom-export.js +1 -1
  4. package/dist/development/index-react-server-client.js +2 -2
  5. package/dist/development/index-react-server.d.ts +601 -189
  6. package/dist/development/index-react-server.js +100 -48
  7. package/dist/development/index.d.ts +10 -9
  8. package/dist/development/index.js +6 -5
  9. package/dist/development/lib/actions.js +1 -1
  10. package/dist/development/lib/components.js +66 -10
  11. package/dist/development/lib/context.d.ts +19 -6
  12. package/dist/development/lib/context.js +11 -3
  13. package/dist/development/lib/dom/dom.d.ts +3 -0
  14. package/dist/development/lib/dom/dom.js +1 -1
  15. package/dist/development/lib/dom/global.d.ts +35 -0
  16. package/dist/development/lib/dom/lib.d.ts +34 -9
  17. package/dist/development/lib/dom/lib.js +30 -37
  18. package/dist/development/lib/dom/server.d.ts +6 -1
  19. package/dist/development/lib/dom/server.js +41 -15
  20. package/dist/development/lib/dom/ssr/components.js +26 -31
  21. package/dist/development/lib/dom/ssr/data.js +1 -1
  22. package/dist/development/lib/dom/ssr/entry.d.ts +13 -2
  23. package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
  24. package/dist/development/lib/dom/ssr/fallback.js +1 -1
  25. package/dist/development/lib/dom/ssr/fog-of-war.d.ts +3 -2
  26. package/dist/development/lib/dom/ssr/fog-of-war.js +46 -22
  27. package/dist/development/lib/dom/ssr/hydration.d.ts +3 -1
  28. package/dist/development/lib/dom/ssr/hydration.js +6 -4
  29. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  30. package/dist/development/lib/dom/ssr/links.js +1 -1
  31. package/dist/development/lib/dom/ssr/markup.js +5 -2
  32. package/dist/development/lib/dom/ssr/route-discovery.d.ts +120 -0
  33. package/dist/development/lib/dom/ssr/route-discovery.js +415 -0
  34. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  35. package/dist/development/lib/dom/ssr/routes-test-stub.js +2 -2
  36. package/dist/development/lib/dom/ssr/routes.d.ts +2 -2
  37. package/dist/development/lib/dom/ssr/routes.js +8 -8
  38. package/dist/development/lib/dom/ssr/server.js +4 -2
  39. package/dist/development/lib/dom/ssr/single-fetch.d.ts +28 -2
  40. package/dist/development/lib/dom/ssr/single-fetch.js +80 -71
  41. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  42. package/dist/development/lib/dom-export/hydrated-router.d.ts +28 -0
  43. package/dist/development/lib/dom-export/hydrated-router.js +33 -12
  44. package/dist/development/lib/errors.js +1 -1
  45. package/dist/development/lib/hooks.d.ts +3 -3
  46. package/dist/development/lib/hooks.js +52 -47
  47. package/dist/development/lib/href.js +1 -1
  48. package/dist/development/lib/router/history.js +1 -1
  49. package/dist/development/lib/router/instrumentation.js +1 -1
  50. package/dist/development/lib/router/matcher-route-pattern.d.ts +2 -0
  51. package/dist/development/lib/router/matcher-route-pattern.js +216 -0
  52. package/dist/development/lib/router/matcher-route-pattern.preload.d.ts +20 -0
  53. package/dist/development/lib/router/matcher-route-pattern.preload.js +36 -0
  54. package/dist/development/lib/router/matcher.d.ts +2 -0
  55. package/dist/development/lib/router/matcher.js +29 -0
  56. package/dist/development/lib/router/navigation.js +1 -1
  57. package/dist/development/lib/router/router.d.ts +19 -7
  58. package/dist/development/lib/router/router.js +235 -128
  59. package/dist/development/lib/router/url.js +1 -1
  60. package/dist/development/lib/router/utils.d.ts +30 -5
  61. package/dist/development/lib/router/utils.js +8 -5
  62. package/dist/development/lib/rsc/browser.js +3 -2
  63. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  64. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  65. package/dist/development/lib/rsc/html-stream/server.js +25 -15
  66. package/dist/development/lib/rsc/route-modules.js +1 -1
  67. package/dist/development/lib/rsc/server.rsc.d.ts +10 -2
  68. package/dist/development/lib/rsc/server.ssr.js +25 -21
  69. package/dist/development/lib/server-runtime/build.d.ts +14 -0
  70. package/dist/development/lib/server-runtime/cookies.js +1 -1
  71. package/dist/development/lib/server-runtime/crypto.js +1 -1
  72. package/dist/development/lib/server-runtime/data.js +1 -1
  73. package/dist/development/lib/server-runtime/dev.js +1 -1
  74. package/dist/development/lib/server-runtime/entry.js +1 -1
  75. package/dist/development/lib/server-runtime/errors.js +1 -1
  76. package/dist/development/lib/server-runtime/headers.js +1 -1
  77. package/dist/development/lib/server-runtime/invariant.js +1 -1
  78. package/dist/development/lib/server-runtime/mode.js +1 -1
  79. package/dist/development/lib/server-runtime/routeMatching.js +3 -4
  80. package/dist/development/lib/server-runtime/routes.d.ts +1 -1
  81. package/dist/development/lib/server-runtime/routes.js +1 -1
  82. package/dist/development/lib/server-runtime/server.js +18 -9
  83. package/dist/development/lib/server-runtime/serverHandoff.d.ts +17 -0
  84. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  85. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
  86. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
  87. package/dist/development/lib/server-runtime/sessions.js +1 -1
  88. package/dist/development/lib/server-runtime/single-fetch.js +1 -1
  89. package/dist/development/lib/server-runtime/urls.js +1 -1
  90. package/dist/development/lib/server-runtime/warnings.js +1 -1
  91. package/dist/development/lib/types/internal.js +1 -1
  92. package/dist/development/lib/types/route-data.d.ts +2 -2
  93. package/dist/development/lib/types/route-module-annotations.d.ts +1 -1
  94. package/dist/development/route-pattern.d.ts +3 -0
  95. package/dist/development/route-pattern.js +12 -0
  96. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  97. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  98. package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
  99. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  100. package/dist/production/dom-export.d.ts +2 -1
  101. package/dist/production/dom-export.js +1 -1
  102. package/dist/production/index-react-server-client.js +2 -2
  103. package/dist/production/index-react-server.d.ts +601 -189
  104. package/dist/production/index-react-server.js +100 -48
  105. package/dist/production/index.d.ts +10 -9
  106. package/dist/production/index.js +6 -5
  107. package/dist/production/lib/actions.js +1 -1
  108. package/dist/production/lib/components.js +66 -10
  109. package/dist/production/lib/context.d.ts +19 -6
  110. package/dist/production/lib/context.js +11 -3
  111. package/dist/production/lib/dom/dom.d.ts +3 -0
  112. package/dist/production/lib/dom/dom.js +1 -1
  113. package/dist/production/lib/dom/global.d.ts +35 -0
  114. package/dist/production/lib/dom/lib.d.ts +34 -9
  115. package/dist/production/lib/dom/lib.js +30 -37
  116. package/dist/production/lib/dom/server.d.ts +6 -1
  117. package/dist/production/lib/dom/server.js +41 -15
  118. package/dist/production/lib/dom/ssr/components.js +26 -31
  119. package/dist/production/lib/dom/ssr/data.js +1 -1
  120. package/dist/production/lib/dom/ssr/entry.d.ts +13 -2
  121. package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
  122. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  123. package/dist/production/lib/dom/ssr/fog-of-war.d.ts +3 -2
  124. package/dist/production/lib/dom/ssr/fog-of-war.js +46 -22
  125. package/dist/production/lib/dom/ssr/hydration.d.ts +3 -1
  126. package/dist/production/lib/dom/ssr/hydration.js +6 -4
  127. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  128. package/dist/production/lib/dom/ssr/links.js +1 -1
  129. package/dist/production/lib/dom/ssr/markup.js +5 -2
  130. package/dist/production/lib/dom/ssr/route-discovery.d.ts +120 -0
  131. package/dist/production/lib/dom/ssr/route-discovery.js +415 -0
  132. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  133. package/dist/production/lib/dom/ssr/routes-test-stub.js +2 -2
  134. package/dist/production/lib/dom/ssr/routes.d.ts +2 -2
  135. package/dist/production/lib/dom/ssr/routes.js +8 -8
  136. package/dist/production/lib/dom/ssr/server.js +4 -2
  137. package/dist/production/lib/dom/ssr/single-fetch.d.ts +28 -2
  138. package/dist/production/lib/dom/ssr/single-fetch.js +80 -71
  139. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  140. package/dist/production/lib/dom-export/hydrated-router.d.ts +28 -0
  141. package/dist/production/lib/dom-export/hydrated-router.js +33 -12
  142. package/dist/production/lib/errors.js +1 -1
  143. package/dist/production/lib/hooks.d.ts +3 -3
  144. package/dist/production/lib/hooks.js +51 -46
  145. package/dist/production/lib/href.js +1 -1
  146. package/dist/production/lib/router/history.js +1 -1
  147. package/dist/production/lib/router/instrumentation.js +1 -1
  148. package/dist/production/lib/router/matcher-route-pattern.d.ts +2 -0
  149. package/dist/production/lib/router/matcher-route-pattern.js +216 -0
  150. package/dist/production/lib/router/matcher-route-pattern.preload.d.ts +20 -0
  151. package/dist/production/lib/router/matcher-route-pattern.preload.js +36 -0
  152. package/dist/production/lib/router/matcher.d.ts +2 -0
  153. package/dist/production/lib/router/matcher.js +29 -0
  154. package/dist/production/lib/router/navigation.js +1 -1
  155. package/dist/production/lib/router/router.d.ts +19 -7
  156. package/dist/production/lib/router/router.js +235 -128
  157. package/dist/production/lib/router/url.js +1 -1
  158. package/dist/production/lib/router/utils.d.ts +30 -5
  159. package/dist/production/lib/router/utils.js +8 -5
  160. package/dist/production/lib/rsc/browser.js +3 -2
  161. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  162. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  163. package/dist/production/lib/rsc/html-stream/server.js +25 -15
  164. package/dist/production/lib/rsc/route-modules.js +1 -1
  165. package/dist/production/lib/rsc/server.rsc.d.ts +10 -2
  166. package/dist/production/lib/rsc/server.ssr.js +25 -21
  167. package/dist/production/lib/server-runtime/build.d.ts +14 -0
  168. package/dist/production/lib/server-runtime/cookies.js +1 -1
  169. package/dist/production/lib/server-runtime/crypto.js +1 -1
  170. package/dist/production/lib/server-runtime/data.js +1 -1
  171. package/dist/production/lib/server-runtime/dev.js +1 -1
  172. package/dist/production/lib/server-runtime/entry.js +1 -1
  173. package/dist/production/lib/server-runtime/errors.js +1 -1
  174. package/dist/production/lib/server-runtime/headers.js +1 -1
  175. package/dist/production/lib/server-runtime/invariant.js +1 -1
  176. package/dist/production/lib/server-runtime/mode.js +1 -1
  177. package/dist/production/lib/server-runtime/routeMatching.js +3 -4
  178. package/dist/production/lib/server-runtime/routes.d.ts +1 -1
  179. package/dist/production/lib/server-runtime/routes.js +1 -1
  180. package/dist/production/lib/server-runtime/server.js +18 -9
  181. package/dist/production/lib/server-runtime/serverHandoff.d.ts +17 -0
  182. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  183. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
  184. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
  185. package/dist/production/lib/server-runtime/sessions.js +1 -1
  186. package/dist/production/lib/server-runtime/single-fetch.js +1 -1
  187. package/dist/production/lib/server-runtime/urls.js +1 -1
  188. package/dist/production/lib/server-runtime/warnings.js +1 -1
  189. package/dist/production/lib/types/internal.js +1 -1
  190. package/dist/production/lib/types/route-data.d.ts +2 -2
  191. package/dist/production/lib/types/route-module-annotations.d.ts +1 -1
  192. package/dist/production/route-pattern.d.ts +3 -0
  193. package/dist/production/route-pattern.js +12 -0
  194. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  195. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  196. package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
  197. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  198. package/docs/explanation/lazy-route-discovery.md +4 -0
  199. package/docs/explanation/sessions-and-cookies.md +108 -4
  200. package/docs/how-to/custom-fetch.md +218 -0
  201. package/docs/how-to/data-strategy.md +23 -1
  202. package/docs/how-to/fetchers.md +6 -1
  203. package/docs/how-to/middleware.md +4 -1
  204. package/docs/how-to/optimize-revalidation.md +178 -5
  205. package/docs/how-to/pre-rendering.md +23 -1
  206. package/docs/how-to/react-server-components.md +26 -3
  207. package/docs/how-to/resource-routes.md +3 -0
  208. package/docs/how-to/route-discovery.md +145 -0
  209. package/docs/how-to/spa.md +2 -0
  210. package/docs/how-to/view-transitions.md +80 -13
  211. package/docs/start/data/actions.md +2 -1
  212. package/docs/start/data/route-object.md +21 -6
  213. package/docs/start/framework/actions.md +4 -2
  214. package/docs/start/framework/navigating.md +5 -9
  215. package/docs/start/framework/rendering.md +37 -0
  216. package/docs/start/framework/route-module.md +32 -5
  217. package/docs/upgrading/future.md +68 -0
  218. package/package.json +19 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.3.1
2
+ * react-router v8.5.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -11,10 +11,11 @@
11
11
  import { createMemoryHistory, createPath, invariant, parsePath, warning } from "./router/history.js";
12
12
  import { defaultMapRouteProperties, getResolveToMatches, getRoutePattern, resolveTo, stripBasename } from "./router/utils.js";
13
13
  import { getNavigatorCurrentUrl, validateNavigationTarget } from "./router/navigation.js";
14
- import { createRouter } from "./router/router.js";
15
- import { AwaitContext, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
14
+ import { clientErrors, createRouter } from "./router/router.js";
15
+ import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
16
16
  import { _renderMatches, useActionData, useAsyncValue, useInRouterContext, useLoaderData, useLocation, useMatches, useNavigate, useOutlet, useParams, useRouteError, useRoutes, useRoutesImpl } from "./hooks.js";
17
17
  import { warnOnce } from "./server-runtime/warnings.js";
18
+ import { FrameworkContext } from "./dom/ssr/components.js";
18
19
  import * as React$1 from "react";
19
20
  import { useOptimistic } from "react";
20
21
  //#region lib/components.tsx
@@ -122,13 +123,18 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
122
123
  useTransitions = useIsRSCRouterContext() || useTransitions;
123
124
  let [_state, setStateImpl] = React$1.useState(router.state);
124
125
  let [state, setOptimisticState] = useOptimistic(_state);
126
+ let lastState = React$1.useRef(state);
125
127
  let [pendingState, setPendingState] = React$1.useState();
126
128
  let [vtContext, setVtContext] = React$1.useState({ isTransitioning: false });
127
129
  let [renderDfd, setRenderDfd] = React$1.useState();
128
130
  let [transition, setTransition] = React$1.useState();
129
131
  let [interruption, setInterruption] = React$1.useState();
130
132
  let fetcherData = React$1.useRef(/* @__PURE__ */ new Map());
133
+ let handledErrors = React$1.useRef(/* @__PURE__ */ new WeakSet());
131
134
  let setState = React$1.useCallback((newState, { deletedFetchers, newErrors, flushSync, viewTransitionOpts }) => {
135
+ lastState.current = newState;
136
+ if (newErrors && newState.errors && clientErrors.has(newState.errors)) if (handledErrors.current.has(newState.errors)) newErrors = null;
137
+ else handledErrors.current.add(newState.errors);
132
138
  if (newErrors && onError) Object.values(newErrors).forEach((error) => onError(error, {
133
139
  location: newState.location,
134
140
  params: newState.matches[0]?.params ?? {},
@@ -204,6 +210,15 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
204
210
  onError
205
211
  ]);
206
212
  React$1.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
213
+ React$1.useLayoutEffect(() => {
214
+ let errors = router.state.errors;
215
+ let newErrors = errors ? clientErrors.get(errors) : null;
216
+ if (lastState.current !== router.state || errors && newErrors && !handledErrors.current.has(errors)) setState(router.state, {
217
+ deletedFetchers: [],
218
+ flushSync: false,
219
+ newErrors: newErrors ?? null
220
+ });
221
+ }, [router, setState]);
207
222
  React$1.useEffect(() => {
208
223
  if (vtContext.isTransitioning && !vtContext.flushSync) setRenderDfd(new Deferred());
209
224
  }, [vtContext]);
@@ -284,7 +299,43 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
284
299
  basename,
285
300
  onError
286
301
  ]);
287
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
302
+ let dataRouterState = React$1.useMemo(() => ({
303
+ historyAction: state.historyAction,
304
+ location: state.location,
305
+ matches: state.matches,
306
+ initialized: state.initialized,
307
+ renderFallback: state.renderFallback,
308
+ restoreScrollPosition: state.restoreScrollPosition,
309
+ preventScrollReset: state.preventScrollReset,
310
+ blockers: state.blockers
311
+ }), [
312
+ state.historyAction,
313
+ state.location,
314
+ state.matches,
315
+ state.initialized,
316
+ state.renderFallback,
317
+ state.restoreScrollPosition,
318
+ state.preventScrollReset,
319
+ state.blockers
320
+ ]);
321
+ let dataRouterNavigation = React$1.useMemo(() => ({
322
+ navigation: state.navigation,
323
+ revalidation: state.revalidation
324
+ }), [state.navigation, state.revalidation]);
325
+ let dataRouterData = React$1.useMemo(() => ({
326
+ loaderData: state.loaderData,
327
+ actionData: state.actionData,
328
+ errors: state.errors
329
+ }), [
330
+ state.loaderData,
331
+ state.actionData,
332
+ state.errors
333
+ ]);
334
+ let fetchersContext = React$1.useMemo(() => ({
335
+ fetchers: state.fetchers,
336
+ fetcherData: fetcherData.current
337
+ }), [state.fetchers]);
338
+ return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: dataRouterState }, /* @__PURE__ */ React$1.createElement(DataRouterNavigationContext.Provider, { value: dataRouterNavigation }, /* @__PURE__ */ React$1.createElement(DataRouterDataContext.Provider, { value: dataRouterData }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
288
339
  basename,
289
340
  location: state.location,
290
341
  navigationType: state.historyAction,
@@ -293,11 +344,10 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
293
344
  }, /* @__PURE__ */ React$1.createElement(MemoizedDataRoutes, {
294
345
  routes: router.routes,
295
346
  manifest: router.manifest,
296
- future: router.future,
297
347
  state,
298
348
  isStatic: false,
299
349
  onError
300
- })))))), null);
350
+ })))))))), null);
301
351
  }
302
352
  function getOptimisticRouterState(currentState, newState) {
303
353
  return {
@@ -309,13 +359,19 @@ function getOptimisticRouterState(currentState, newState) {
309
359
  };
310
360
  }
311
361
  const MemoizedDataRoutes = React$1.memo(DataRoutes);
312
- function DataRoutes({ routes, manifest, future, state, isStatic, onError }) {
362
+ function DataRoutes({ routes, manifest, state, isStatic, onError }) {
363
+ let dataRouterContext = React$1.useContext(DataRouterContext);
364
+ invariant(dataRouterContext, "You must render this element inside a <DataRouterContext.Provider> element");
365
+ let discoveryRuntime = React$1.useContext(FrameworkContext)?.routeDiscoveryRuntime;
366
+ React$1.useEffect(() => {
367
+ if (state.initialized) discoveryRuntime?.markReady();
368
+ }, [state.initialized, discoveryRuntime]);
313
369
  return useRoutesImpl(routes, void 0, {
370
+ router: dataRouterContext.router,
314
371
  manifest,
315
372
  state,
316
373
  isStatic,
317
- onError,
318
- future
374
+ onError
319
375
  });
320
376
  }
321
377
  /**
@@ -679,7 +735,7 @@ var AwaitErrorBoundary = class extends React$1.Component {
679
735
  } else {
680
736
  status = 0;
681
737
  Object.defineProperty(resolve, "_tracked", { get: () => true });
682
- promise = resolve.then((data) => Object.defineProperty(resolve, "_data", { get: () => data }), (error) => {
738
+ promise = Promise.resolve(resolve).then((data) => Object.defineProperty(resolve, "_data", { get: () => data }), (error) => {
683
739
  this.props.onError?.(error);
684
740
  Object.defineProperty(resolve, "_error", { get: () => error });
685
741
  });
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { Action, History, Location, To } from "./router/history.js";
3
3
  import { RouteMatch, TrackedPromise } from "./router/utils.js";
4
- import { RelativeRoutingType, Router, RouterState, StaticHandlerContext } from "./router/router.js";
4
+ import { RelativeRoutingType, Router, StaticHandlerContext } from "./router/router.js";
5
5
  import { ClientOnErrorFunction } from "./components.js";
6
6
  import * as React$1 from "react";
7
7
 
@@ -12,7 +12,12 @@ interface DataRouterContextObject extends Omit<NavigationContextObject, "future"
12
12
  onError?: ClientOnErrorFunction;
13
13
  }
14
14
  declare const DataRouterContext: React$1.Context<DataRouterContextObject | null>;
15
- declare const DataRouterStateContext: React$1.Context<RouterState | null>;
15
+ type DataRouterDataContextObject = Pick<Router["state"], "loaderData" | "actionData" | "errors">;
16
+ type DataRouterNavigationContextObject = Pick<Router["state"], "navigation" | "revalidation">;
17
+ type DataRouterStateContextObject = Omit<Router["state"], keyof DataRouterDataContextObject | keyof DataRouterNavigationContextObject | "fetchers">;
18
+ declare const DataRouterStateContext: React$1.Context<DataRouterStateContextObject | null>;
19
+ declare const DataRouterDataContext: React$1.Context<DataRouterDataContextObject | null>;
20
+ declare const DataRouterNavigationContext: React$1.Context<DataRouterNavigationContextObject | null>;
16
21
  type ViewTransitionContextObject = {
17
22
  isTransitioning: false;
18
23
  } | {
@@ -22,8 +27,11 @@ type ViewTransitionContextObject = {
22
27
  nextLocation: Location;
23
28
  };
24
29
  declare const ViewTransitionContext: React$1.Context<ViewTransitionContextObject>;
25
- type FetchersContextObject = Map<string, any>;
26
- declare const FetchersContext: React$1.Context<FetchersContextObject>;
30
+ type FetchersContextObject = {
31
+ fetchers: Router["state"]["fetchers"];
32
+ fetcherData: Map<string, any>;
33
+ };
34
+ declare const FetchersContext: React$1.Context<FetchersContextObject | null>;
27
35
  declare const AwaitContext: React$1.Context<TrackedPromise | null>;
28
36
  declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | null>>;
29
37
  interface NavigateOptions {
@@ -39,7 +47,12 @@ interface NavigateOptions {
39
47
  relative?: RelativeRoutingType;
40
48
  /** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
41
49
  flushSync?: boolean;
42
- /** Enables a {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API View Transition} for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the {@link useViewTransitionState `useViewTransitionState()`} hook. */
50
+ /**
51
+ * Enables a view transition for this navigation.
52
+ *
53
+ * @deprecated Use React's `<ViewTransition>` component instead. See the
54
+ * [migration guide](https://reactrouter.com/how-to/view-transitions).
55
+ */
43
56
  viewTransition?: boolean;
44
57
  /** Specifies the default revalidation behavior after this submission */
45
58
  defaultShouldRevalidate?: boolean;
@@ -81,4 +94,4 @@ interface RouteContextObject {
81
94
  }
82
95
  declare const RouteContext: React$1.Context<RouteContextObject>;
83
96
  //#endregion
84
- export { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext };
97
+ export { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.3.1
2
+ * react-router v8.5.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -14,13 +14,17 @@ const DataRouterContext = React$1.createContext(null);
14
14
  DataRouterContext.displayName = "DataRouter";
15
15
  const DataRouterStateContext = React$1.createContext(null);
16
16
  DataRouterStateContext.displayName = "DataRouterState";
17
+ const DataRouterDataContext = React$1.createContext(null);
18
+ DataRouterDataContext.displayName = "DataRouterData";
19
+ const DataRouterNavigationContext = React$1.createContext(null);
20
+ DataRouterNavigationContext.displayName = "DataRouterNavigation";
17
21
  const RSCRouterContext = React$1.createContext(false);
18
22
  function useIsRSCRouterContext() {
19
23
  return React$1.useContext(RSCRouterContext);
20
24
  }
21
25
  const ViewTransitionContext = React$1.createContext({ isTransitioning: false });
22
26
  ViewTransitionContext.displayName = "ViewTransition";
23
- const FetchersContext = React$1.createContext(/* @__PURE__ */ new Map());
27
+ const FetchersContext = React$1.createContext(null);
24
28
  FetchersContext.displayName = "Fetchers";
25
29
  const AwaitContext = React$1.createContext(null);
26
30
  AwaitContext.displayName = "Await";
@@ -35,7 +39,11 @@ const RouteContext = React$1.createContext({
35
39
  isDataRoute: false
36
40
  });
37
41
  RouteContext.displayName = "Route";
42
+ const IsDataRouteContext = React$1.createContext(false);
43
+ IsDataRouteContext.displayName = "IsDataRoute";
44
+ const RouteIdContext = React$1.createContext(void 0);
45
+ RouteIdContext.displayName = "RouteId";
38
46
  const RouteErrorContext = React$1.createContext(null);
39
47
  RouteErrorContext.displayName = "RouteError";
40
48
  //#endregion
41
- export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, ViewTransitionContext, useIsRSCRouterContext };
49
+ export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext, ViewTransitionContext, useIsRSCRouterContext };
@@ -112,6 +112,9 @@ interface SubmitOptions extends FetcherSubmitOptions {
112
112
  navigate?: boolean;
113
113
  /**
114
114
  * Enable view transitions on this submission navigation
115
+ *
116
+ * @deprecated Use React's `<ViewTransition>` component instead. See the
117
+ * [migration guide](https://reactrouter.com/how-to/view-transitions).
115
118
  */
116
119
  viewTransition?: boolean;
117
120
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.3.1
2
+ * react-router v8.5.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -0,0 +1,35 @@
1
+
2
+ import { HydrationState, Router } from "../router/router.js";
3
+ import { RouteModules } from "./ssr/routeModules.js";
4
+ import { ServerHandoff } from "../server-runtime/serverHandoff.js";
5
+ import { AssetsManifest } from "./ssr/entry.js";
6
+
7
+ //#region lib/dom/global.d.ts
8
+ type WindowReactRouterContext = ServerHandoff & {
9
+ state: HydrationState;
10
+ stream: ReadableStream<Uint8Array> | undefined;
11
+ streamController: ReadableStreamDefaultController<Uint8Array>;
12
+ };
13
+ interface ViewTransition {
14
+ finished: Promise<void>;
15
+ ready: Promise<void>;
16
+ updateCallbackDone: Promise<void>;
17
+ skipTransition(): void;
18
+ }
19
+ declare global {
20
+ var __staticRouterHydrationData: HydrationState | undefined;
21
+ var __reactRouterVersion: string;
22
+ interface Document {
23
+ startViewTransition(cb: () => Promise<void> | void): ViewTransition;
24
+ }
25
+ var __reactRouterContext: WindowReactRouterContext | undefined;
26
+ var __reactRouterManifest: AssetsManifest | undefined;
27
+ var __reactRouterRouteModules: RouteModules | undefined;
28
+ var __reactRouterDataRouter: Router | undefined;
29
+ var __reactRouterHdrActive: boolean;
30
+ var $RefreshRuntime$: {
31
+ performReactRefresh: () => void;
32
+ } | undefined;
33
+ }
34
+ //#endregion
35
+ export { WindowReactRouterContext };
@@ -3,9 +3,9 @@ import { History, To } from "../router/history.js";
3
3
  import { DataStrategyFunction, HTMLFormMethod, PatchRoutesOnNavigationFunction, RouteObject } from "../router/utils.js";
4
4
  import { BlockerFunction, Fetcher, FutureConfig, GetScrollRestorationKeyFunction, HydrationState, RelativeRoutingType, Router, RouterInit } from "../router/router.js";
5
5
  import { NavigateOptions } from "../context.js";
6
+ import { SerializeFrom } from "../types/route-data.js";
6
7
  import { FetcherSubmitOptions, SubmitOptions, SubmitTarget, URLSearchParamsInit } from "./dom.js";
7
8
  import { DiscoverBehavior, PrefetchBehavior, ScriptsProps } from "./ssr/components.js";
8
- import { SerializeFrom } from "../types/route-data.js";
9
9
  import { ClientInstrumentation } from "../router/instrumentation.js";
10
10
  import * as React$1 from "react";
11
11
 
@@ -863,6 +863,9 @@ interface LinkProps extends Omit<React$1.AnchorHTMLAttributes<HTMLAnchorElement>
863
863
  */
864
864
  to: To;
865
865
  /**
866
+ * **Deprecated.** Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
867
+ * component instead. See the [migration guide](../../how-to/view-transitions).
868
+ *
866
869
  * Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
867
870
  * for this navigation.
868
871
  *
@@ -873,6 +876,8 @@ interface LinkProps extends Omit<React$1.AnchorHTMLAttributes<HTMLAnchorElement>
873
876
  * ```
874
877
  *
875
878
  * To apply specific styles for the transition, see {@link useViewTransitionState}
879
+ *
880
+ * @deprecated Use React's `<ViewTransition>` component instead.
876
881
  */
877
882
  viewTransition?: boolean;
878
883
  /**
@@ -1020,6 +1025,10 @@ type NavLinkRenderProps = {
1020
1025
  /**
1021
1026
  * Indicates if a view transition to the link's URL is in progress.
1022
1027
  * See {@link useViewTransitionState}
1028
+ *
1029
+ * @deprecated Only tracks React Router's deprecated view transitions. Use
1030
+ * React's `<ViewTransition>` component to style transitions instead. See the
1031
+ * [migration guide](https://reactrouter.com/how-to/view-transitions).
1023
1032
  */
1024
1033
  isTransitioning: boolean;
1025
1034
  };
@@ -1059,9 +1068,6 @@ interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children
1059
1068
  * a.pending {
1060
1069
  * color: blue;
1061
1070
  * }
1062
- * a.transitioning {
1063
- * view-transition-name: my-transition;
1064
- * }
1065
1071
  * ```
1066
1072
  *
1067
1073
  * Or you can specify a function that receives {@link NavLinkRenderProps} and
@@ -1074,6 +1080,10 @@ interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children
1074
1080
  * ""
1075
1081
  * )} />
1076
1082
  * ```
1083
+ *
1084
+ * The `transitioning` class is deprecated and only tracks React Router's
1085
+ * legacy view transitions. Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
1086
+ * component instead. See the [migration guide](../../how-to/view-transitions).
1077
1087
  */
1078
1088
  className?: string | ((props: NavLinkRenderProps) => string | undefined);
1079
1089
  /**
@@ -1257,9 +1267,14 @@ interface FormProps extends SharedFormProps {
1257
1267
  */
1258
1268
  state?: any;
1259
1269
  /**
1270
+ * **Deprecated.** Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
1271
+ * component instead. See the [migration guide](../../how-to/view-transitions).
1272
+ *
1260
1273
  * Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1261
1274
  * for this navigation. To apply specific styles during the transition, see
1262
1275
  * {@link useViewTransitionState}.
1276
+ *
1277
+ * @deprecated Use React's `<ViewTransition>` component instead.
1263
1278
  */
1264
1279
  viewTransition?: boolean;
1265
1280
  }
@@ -1405,9 +1420,9 @@ declare namespace ScrollRestoration {
1405
1420
  * @param options.state The state to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1406
1421
  * entry for this navigation. Defaults to `undefined`.
1407
1422
  * @param options.target The target attribute for the link. Defaults to `undefined`.
1408
- * @param options.viewTransition Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1409
- * for this navigation. To apply specific styles during the transition, see
1410
- * {@link useViewTransitionState}. Defaults to `false`.
1423
+ * @param options.viewTransition **Deprecated.** Use React's
1424
+ * [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition) component
1425
+ * instead. See the [migration guide](../../how-to/view-transitions).
1411
1426
  * @param options.defaultShouldRevalidate Specify the default revalidation
1412
1427
  * behavior for the navigation. When not specified, loaders revalidate
1413
1428
  * according to the router's standard revalidation behavior.
@@ -1435,10 +1450,9 @@ declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to:
1435
1450
  state?: any;
1436
1451
  preventScrollReset?: boolean;
1437
1452
  relative?: RelativeRoutingType;
1438
- viewTransition?: boolean;
1439
1453
  defaultShouldRevalidate?: boolean;
1440
1454
  useTransitions?: boolean;
1441
- }): (event: React$1.MouseEvent<E, MouseEvent>) => void;
1455
+ } & Pick<NavigateOptions, "viewTransition">): (event: React$1.MouseEvent<E, MouseEvent>) => void;
1442
1456
  /**
1443
1457
  * Returns a tuple of the current URL's [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
1444
1458
  * and a function to update them. Setting the search params causes a navigation.
@@ -1662,6 +1676,10 @@ interface FetcherSubmitFunction {
1662
1676
  * The imperative version of {@link Form | `<Form>`} that lets you submit a form
1663
1677
  * from code instead of a user interaction.
1664
1678
  *
1679
+ * The `viewTransition` submission option is deprecated. Use React's
1680
+ * [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition) component
1681
+ * instead. See the [migration guide](../../how-to/view-transitions).
1682
+ *
1665
1683
  * @example
1666
1684
  * import { useSubmit } from "react-router";
1667
1685
  *
@@ -2025,6 +2043,11 @@ declare function usePrompt({
2025
2043
  message: string;
2026
2044
  }): void;
2027
2045
  /**
2046
+ * **Deprecated.** Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
2047
+ * component to style transitions instead. This hook only tracks React Router's
2048
+ * legacy view transitions, not transitions started by React. See the
2049
+ * [migration guide](../../how-to/view-transitions).
2050
+ *
2028
2051
  * This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
2029
2052
  * and the specified location matches either side of the navigation (the URL you are
2030
2053
  * navigating **to** or the URL you are navigating **from**). This can be used to apply finer-grained styles to
@@ -2044,6 +2067,8 @@ declare function usePrompt({
2044
2067
  * more details.
2045
2068
  * @returns `true` if there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
2046
2069
  * and the resolved path matches the transition's destination or source pathname, otherwise `false`.
2070
+ *
2071
+ * @deprecated Use React's `<ViewTransition>` component instead.
2047
2072
  */
2048
2073
  declare function useViewTransitionState(to: To, {
2049
2074
  relative
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.3.1
2
+ * react-router v8.5.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -12,12 +12,12 @@ import { ABSOLUTE_URL_REGEX } from "../router/url.js";
12
12
  import { createBrowserHistory, createHashHistory, createPath, invariant, warning } from "../router/history.js";
13
13
  import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, defaultMapRouteProperties, joinPaths, matchPath, parseToInfo, resolveTo, stripBasename } from "../router/utils.js";
14
14
  import { IDLE_FETCHER, createRouter } from "../router/router.js";
15
- import { DataRouterContext, DataRouterStateContext, FetchersContext, NavigationContext, RouteContext, ViewTransitionContext } from "../context.js";
16
- import { useBlocker, useHref, useLocation, useMatches, useNavigate, useNavigation, useResolvedPath, useRouteId } from "../hooks.js";
17
- import { Router, hydrationRouteProperties } from "../components.js";
18
- import { createSearchParams, getFormSubmissionInfo, getSearchParamsForLocation, shouldProcessLinkClick } from "./dom.js";
15
+ import { DataRouterNavigationContext, NavigationContext, RouteContext, ViewTransitionContext } from "../context.js";
16
+ import { useBlocker, useCurrentRouteId, useDataRouterContext, useDataRouterFetchers, useDataRouterState, useHref, useLocation, useMatches, useNavigate, useNavigation, useResolvedPath } from "../hooks.js";
19
17
  import { escapeHtml } from "./ssr/markup.js";
20
18
  import { FrameworkContext, PrefetchPageLinks, mergeRefs, usePrefetchBehavior } from "./ssr/components.js";
19
+ import { Router, hydrationRouteProperties } from "../components.js";
20
+ import { createSearchParams, getFormSubmissionInfo, getSearchParamsForLocation, shouldProcessLinkClick } from "./dom.js";
21
21
  import * as React$1 from "react";
22
22
  //#region lib/dom/lib.tsx
23
23
  const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
@@ -372,12 +372,12 @@ Link.displayName = "Link";
372
372
  const NavLink = React$1.forwardRef(function NavLinkWithRef({ "aria-current": ariaCurrentProp = "page", caseSensitive = false, className: classNameProp = "", end = false, style: styleProp, to, viewTransition, children, ...rest }, ref) {
373
373
  let path = useResolvedPath(to, { relative: rest.relative });
374
374
  let location = useLocation();
375
- let routerState = React$1.useContext(DataRouterStateContext);
375
+ let routerNavigation = React$1.useContext(DataRouterNavigationContext);
376
376
  let { navigator, basename } = React$1.useContext(NavigationContext);
377
- let isTransitioning = routerState != null && useViewTransitionState(path) && viewTransition === true;
377
+ let isTransitioning = routerNavigation != null && useViewTransitionState(path) && viewTransition === true;
378
378
  let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
379
379
  let locationPathname = location.pathname;
380
- let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
380
+ let nextLocationPathname = routerNavigation?.navigation.location ? routerNavigation.navigation.location.pathname : null;
381
381
  if (!caseSensitive) {
382
382
  locationPathname = locationPathname.toLowerCase();
383
383
  nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
@@ -573,19 +573,6 @@ function ScrollRestoration({ getKey, storageKey, ...props }) {
573
573
  });
574
574
  }
575
575
  ScrollRestoration.displayName = "ScrollRestoration";
576
- function getDataRouterConsoleError(hookName) {
577
- return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
578
- }
579
- function useDataRouterContext(hookName) {
580
- let ctx = React$1.useContext(DataRouterContext);
581
- invariant(ctx, getDataRouterConsoleError(hookName));
582
- return ctx;
583
- }
584
- function useDataRouterState(hookName) {
585
- let state = React$1.useContext(DataRouterStateContext);
586
- invariant(state, getDataRouterConsoleError(hookName));
587
- return state;
588
- }
589
576
  /**
590
577
  * Handles the click behavior for router {@link Link | `<Link>`} components.This
591
578
  * is useful if you need to create custom {@link Link | `<Link>`} components with
@@ -605,9 +592,9 @@ function useDataRouterState(hookName) {
605
592
  * @param options.state The state to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
606
593
  * entry for this navigation. Defaults to `undefined`.
607
594
  * @param options.target The target attribute for the link. Defaults to `undefined`.
608
- * @param options.viewTransition Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
609
- * for this navigation. To apply specific styles during the transition, see
610
- * {@link useViewTransitionState}. Defaults to `false`.
595
+ * @param options.viewTransition **Deprecated.** Use React's
596
+ * [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition) component
597
+ * instead. See the [migration guide](../../how-to/view-transitions).
611
598
  * @param options.defaultShouldRevalidate Specify the default revalidation
612
599
  * behavior for the navigation. When not specified, loaders revalidate
613
600
  * according to the router's standard revalidation behavior.
@@ -769,6 +756,10 @@ let getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
769
756
  * The imperative version of {@link Form | `<Form>`} that lets you submit a form
770
757
  * from code instead of a user interaction.
771
758
  *
759
+ * The `viewTransition` submission option is deprecated. Use React's
760
+ * [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition) component
761
+ * instead. See the [migration guide](../../how-to/view-transitions).
762
+ *
772
763
  * @example
773
764
  * import { useSubmit } from "react-router";
774
765
  *
@@ -788,7 +779,7 @@ let getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
788
779
  function useSubmit() {
789
780
  let { router } = useDataRouterContext("useSubmit");
790
781
  let { basename } = React$1.useContext(NavigationContext);
791
- let currentRouteId = useRouteId();
782
+ let currentRouteId = useCurrentRouteId("useSubmit");
792
783
  let routerFetch = router.fetch;
793
784
  let routerNavigate = router.navigate;
794
785
  return React$1.useCallback(async (target, options = {}) => {
@@ -947,13 +938,8 @@ function useFormAction(action, { relative } = {}) {
947
938
  */
948
939
  function useFetcher({ key } = {}) {
949
940
  let { router } = useDataRouterContext("useFetcher");
950
- let state = useDataRouterState("useFetcher");
951
- let fetcherData = React$1.useContext(FetchersContext);
952
- let route = React$1.useContext(RouteContext);
953
- let routeId = route.matches[route.matches.length - 1]?.route.id;
954
- invariant(fetcherData, `useFetcher must be used inside a FetchersContext`);
955
- invariant(route, `useFetcher must be used inside a RouteContext`);
956
- invariant(routeId != null, `useFetcher can only be used on routes that contain a unique "id"`);
941
+ let fetchersContext = useDataRouterFetchers("useFetcher");
942
+ let routeId = useCurrentRouteId("useFetcher");
957
943
  let defaultKey = React$1.useId();
958
944
  let [fetcherKey, setFetcherKey] = React$1.useState(key || defaultKey);
959
945
  if (key && key !== fetcherKey) setFetcherKey(key);
@@ -995,8 +981,8 @@ function useFetcher({ key } = {}) {
995
981
  FetcherForm.displayName = "fetcher.Form";
996
982
  return FetcherForm;
997
983
  }, [fetcherKey]);
998
- let fetcher = state.fetchers.get(fetcherKey) || IDLE_FETCHER;
999
- let data = fetcherData.get(fetcherKey);
984
+ let fetcher = fetchersContext.fetchers.get(fetcherKey) || IDLE_FETCHER;
985
+ let data = fetchersContext.fetcherData.get(fetcherKey);
1000
986
  return React$1.useMemo(() => ({
1001
987
  Form: FetcherForm,
1002
988
  submit,
@@ -1036,11 +1022,11 @@ function useFetcher({ key } = {}) {
1036
1022
  * property.
1037
1023
  */
1038
1024
  function useFetchers() {
1039
- let state = useDataRouterState("useFetchers");
1040
- return React$1.useMemo(() => Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
1025
+ let { fetchers } = useDataRouterFetchers("useFetchers");
1026
+ return React$1.useMemo(() => Array.from(fetchers.entries()).map(([key, fetcher]) => ({
1041
1027
  ...fetcher,
1042
1028
  key
1043
- })), [state.fetchers]);
1029
+ })), [fetchers]);
1044
1030
  }
1045
1031
  const SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
1046
1032
  let savedScrollPositions = {};
@@ -1253,6 +1239,11 @@ function usePrompt({ when, message }) {
1253
1239
  }, [blocker, when]);
1254
1240
  }
1255
1241
  /**
1242
+ * **Deprecated.** Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
1243
+ * component to style transitions instead. This hook only tracks React Router's
1244
+ * legacy view transitions, not transitions started by React. See the
1245
+ * [migration guide](../../how-to/view-transitions).
1246
+ *
1256
1247
  * This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1257
1248
  * and the specified location matches either side of the navigation (the URL you are
1258
1249
  * navigating **to** or the URL you are navigating **from**). This can be used to apply finer-grained styles to
@@ -1272,6 +1263,8 @@ function usePrompt({ when, message }) {
1272
1263
  * more details.
1273
1264
  * @returns `true` if there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1274
1265
  * and the resolved path matches the transition's destination or source pathname, otherwise `false`.
1266
+ *
1267
+ * @deprecated Use React's `<ViewTransition>` component instead.
1275
1268
  */
1276
1269
  function useViewTransitionState(to, { relative } = {}) {
1277
1270
  let vtContext = React$1.useContext(ViewTransitionContext);
@@ -127,10 +127,15 @@ declare function StaticRouterProvider({
127
127
  * `query`
128
128
  * @param opts Options
129
129
  * @param opts.future Future flags for the static {@link DataRouter}
130
- * @param opts.branches Optional pre-computed route branches
130
+ * @param opts.branches Deprecated optional pre-computed route branches. This option
131
+ * is no longer used because branch caching is done automatically inside the static router.
131
132
  * @returns A static {@link DataRouter} that can be used to render the provided routes
132
133
  */
133
134
  declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
135
+ /**
136
+ * @deprecated This option is no longer used because branch caching is done
137
+ * automatically inside the static router.
138
+ */
134
139
  branches?: RouteBranch<DataRouteObject>[];
135
140
  future?: Partial<FutureConfig>;
136
141
  }): Router;