react-router 7.8.0 → 7.8.1-pre.1

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 (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/development/{chunk-VC6RBZTR.js → chunk-3JDDYHAM.js} +130 -130
  3. package/dist/development/{chunk-EVX7OBGB.js → chunk-5556IWOV.js} +98 -83
  4. package/dist/development/{chunk-ZYFC6VSF.mjs → chunk-74543KUN.mjs} +62 -47
  5. package/dist/{production/chunk-XPGU3ZMH.mjs → development/chunk-NL6TORMN.mjs} +147 -33
  6. package/dist/development/dom-export.js +3 -3
  7. package/dist/development/dom-export.mjs +3 -3
  8. package/dist/{production/index-react-server-client-DXb0OgpJ.d.mts → development/index-react-server-client-11fLy3qB.d.mts} +1 -1
  9. package/dist/development/{index-react-server-client-CMphySRb.d.ts → index-react-server-client-BQ6FxdA_.d.ts} +1 -1
  10. package/dist/development/index-react-server-client.d.mts +2 -2
  11. package/dist/development/index-react-server-client.d.ts +2 -2
  12. package/dist/development/index-react-server-client.js +4 -4
  13. package/dist/development/index-react-server-client.mjs +2 -2
  14. package/dist/development/index-react-server.d.mts +38 -1
  15. package/dist/development/index-react-server.d.ts +38 -1
  16. package/dist/development/index-react-server.js +56 -45
  17. package/dist/development/index-react-server.mjs +56 -46
  18. package/dist/development/index.d.mts +42 -4
  19. package/dist/development/index.d.ts +42 -4
  20. package/dist/development/index.js +242 -128
  21. package/dist/development/index.mjs +3 -3
  22. package/dist/development/lib/types/internal.d.mts +6 -3
  23. package/dist/development/lib/types/internal.d.ts +6 -3
  24. package/dist/development/lib/types/internal.js +1 -1
  25. package/dist/development/lib/types/internal.mjs +1 -1
  26. package/dist/development/{route-data-CpB5xtMm.d.mts → route-data-CNjObrhZ.d.mts} +1 -1
  27. package/dist/development/{routeModules-qBivMBjd.d.ts → routeModules-C3oqzPpI.d.ts} +1 -1
  28. package/dist/production/{chunk-BOD6JCOU.js → chunk-3OSMCWIR.js} +98 -83
  29. package/dist/production/{chunk-SIHON65V.mjs → chunk-HVGIEXH6.mjs} +62 -47
  30. package/dist/{development/chunk-HZX6U7MI.mjs → production/chunk-J44BHEXU.mjs} +147 -33
  31. package/dist/production/{chunk-O6DRQPUD.js → chunk-OE6UW5JS.js} +130 -130
  32. package/dist/production/dom-export.js +3 -3
  33. package/dist/production/dom-export.mjs +3 -3
  34. package/dist/{development/index-react-server-client-DXb0OgpJ.d.mts → production/index-react-server-client-11fLy3qB.d.mts} +1 -1
  35. package/dist/production/{index-react-server-client-CMphySRb.d.ts → index-react-server-client-BQ6FxdA_.d.ts} +1 -1
  36. package/dist/production/index-react-server-client.d.mts +2 -2
  37. package/dist/production/index-react-server-client.d.ts +2 -2
  38. package/dist/production/index-react-server-client.js +4 -4
  39. package/dist/production/index-react-server-client.mjs +2 -2
  40. package/dist/production/index-react-server.d.mts +38 -1
  41. package/dist/production/index-react-server.d.ts +38 -1
  42. package/dist/production/index-react-server.js +56 -45
  43. package/dist/production/index-react-server.mjs +56 -46
  44. package/dist/production/index.d.mts +42 -4
  45. package/dist/production/index.d.ts +42 -4
  46. package/dist/production/index.js +242 -128
  47. package/dist/production/index.mjs +3 -3
  48. package/dist/production/lib/types/internal.d.mts +6 -3
  49. package/dist/production/lib/types/internal.d.ts +6 -3
  50. package/dist/production/lib/types/internal.js +1 -1
  51. package/dist/production/lib/types/internal.mjs +1 -1
  52. package/dist/production/{route-data-CpB5xtMm.d.mts → route-data-CNjObrhZ.d.mts} +1 -1
  53. package/dist/production/{routeModules-qBivMBjd.d.ts → routeModules-C3oqzPpI.d.ts} +1 -1
  54. package/package.json +1 -1
@@ -6,7 +6,7 @@ export { Await, BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta
6
6
  import { serialize, parse } from 'cookie';
7
7
 
8
8
  /**
9
- * react-router v7.8.0
9
+ * react-router v7.8.1-pre.1
10
10
  *
11
11
  * Copyright (c) Remix Software Inc.
12
12
  *
@@ -238,8 +238,8 @@ function convertRouteMatchToUiMatch(match, loaderData) {
238
238
  handle: route.handle
239
239
  };
240
240
  }
241
- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "") {
242
- let flattenRoute = (route, index, relativePath) => {
241
+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
242
+ let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
243
243
  let meta = {
244
244
  relativePath: relativePath === void 0 ? route.path || "" : relativePath,
245
245
  caseSensitive: route.caseSensitive === true,
@@ -247,6 +247,9 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
247
247
  route
248
248
  };
249
249
  if (meta.relativePath.startsWith("/")) {
250
+ if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
251
+ return;
252
+ }
250
253
  invariant(
251
254
  meta.relativePath.startsWith(parentPath),
252
255
  `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
@@ -262,7 +265,13 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
262
265
  route.index !== true,
263
266
  `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
264
267
  );
265
- flattenRoutes(route.children, branches, routesMeta, path);
268
+ flattenRoutes(
269
+ route.children,
270
+ branches,
271
+ routesMeta,
272
+ path,
273
+ hasParentOptionalSegments
274
+ );
266
275
  }
267
276
  if (route.path == null && !route.index) {
268
277
  return;
@@ -278,7 +287,7 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "")
278
287
  flattenRoute(route, index);
279
288
  } else {
280
289
  for (let exploded of explodeOptionalSegments(route.path)) {
281
- flattenRoute(route, index, exploded);
290
+ flattenRoute(route, index, true, exploded);
282
291
  }
283
292
  }
284
293
  });
@@ -442,7 +451,7 @@ function compilePath(path, caseSensitive = false, end = true) {
442
451
  params.push({ paramName, isOptional: isOptional != null });
443
452
  return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
444
453
  }
445
- );
454
+ ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
446
455
  if (path.endsWith("*")) {
447
456
  params.push({ paramName: "*" });
448
457
  regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
@@ -752,9 +761,23 @@ function createStaticHandler(routes, opts) {
752
761
  return res;
753
762
  },
754
763
  async (error, routeId) => {
755
- if (isResponse(error)) {
764
+ if (isRedirectResponse(error)) {
756
765
  return error;
757
766
  }
767
+ if (isResponse(error)) {
768
+ try {
769
+ error = new ErrorResponseImpl(
770
+ error.status,
771
+ error.statusText,
772
+ await parseResponseBody(error)
773
+ );
774
+ } catch (e) {
775
+ error = e;
776
+ }
777
+ }
778
+ if (isDataWithResponseInit(error)) {
779
+ error = dataWithResponseInitToErrorResponse(error);
780
+ }
758
781
  if (renderedStaticContext) {
759
782
  if (routeId in renderedStaticContext.loaderData) {
760
783
  renderedStaticContext.loaderData[routeId] = void 0;
@@ -880,8 +903,8 @@ function createStaticHandler(routes, opts) {
880
903
  return res;
881
904
  },
882
905
  (error) => {
883
- if (isRouteErrorResponse(error)) {
884
- return Promise.resolve(errorResponseToResponse(error));
906
+ if (isDataWithResponseInit(error)) {
907
+ return Promise.resolve(dataWithResponseInitToResponse(error));
885
908
  }
886
909
  if (isResponse(error)) {
887
910
  return Promise.resolve(error);
@@ -1208,8 +1231,12 @@ function createStaticHandler(routes, opts) {
1208
1231
  basename
1209
1232
  );
1210
1233
  }
1211
- if (isResponse(result.result) && isRouteRequest) {
1212
- throw result;
1234
+ if (isRouteRequest) {
1235
+ if (isResponse(result.result)) {
1236
+ throw result;
1237
+ } else if (isDataWithResponseInit(result.result)) {
1238
+ throw dataWithResponseInitToResponse(result.result);
1239
+ }
1213
1240
  }
1214
1241
  dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
1215
1242
  })
@@ -1518,11 +1545,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
1518
1545
  nextResult = result;
1519
1546
  return nextResult;
1520
1547
  } catch (e) {
1521
- nextResult = await errorHandler(
1522
- // Convert thrown data() values to ErrorResponses
1523
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
1524
- routeId
1525
- );
1548
+ nextResult = await errorHandler(e, routeId);
1526
1549
  return nextResult;
1527
1550
  }
1528
1551
  };
@@ -1547,11 +1570,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
1547
1570
  return nextResult;
1548
1571
  }
1549
1572
  } catch (e) {
1550
- let response = await errorHandler(
1551
- // Convert thrown data() values to ErrorResponses
1552
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
1553
- routeId
1554
- );
1573
+ let response = await errorHandler(e, routeId);
1555
1574
  return response;
1556
1575
  }
1557
1576
  }
@@ -1777,21 +1796,19 @@ async function callLoaderOrAction({
1777
1796
  }
1778
1797
  return result;
1779
1798
  }
1799
+ async function parseResponseBody(response) {
1800
+ let contentType = response.headers.get("Content-Type");
1801
+ if (contentType && /\bapplication\/json\b/.test(contentType)) {
1802
+ return response.body == null ? null : response.json();
1803
+ }
1804
+ return response.text();
1805
+ }
1780
1806
  async function convertDataStrategyResultToDataResult(dataStrategyResult) {
1781
1807
  let { result, type } = dataStrategyResult;
1782
1808
  if (isResponse(result)) {
1783
1809
  let data2;
1784
1810
  try {
1785
- let contentType = result.headers.get("Content-Type");
1786
- if (contentType && /\bapplication\/json\b/.test(contentType)) {
1787
- if (result.body == null) {
1788
- data2 = null;
1789
- } else {
1790
- data2 = await result.json();
1791
- }
1792
- } else {
1793
- data2 = await result.text();
1794
- }
1811
+ data2 = await parseResponseBody(result);
1795
1812
  } catch (e) {
1796
1813
  return { type: "error" /* error */, error: e };
1797
1814
  }
@@ -1991,10 +2008,7 @@ function getInternalRouterError(status, {
1991
2008
  );
1992
2009
  }
1993
2010
  function dataWithResponseInitToResponse(data2) {
1994
- return new Response(
1995
- typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
1996
- data2.init || void 0
1997
- );
2011
+ return Response.json(data2.data, data2.init ?? void 0);
1998
2012
  }
1999
2013
  function dataWithResponseInitToErrorResponse(data2) {
2000
2014
  return new ErrorResponseImpl(
@@ -2003,15 +2017,6 @@ function dataWithResponseInitToErrorResponse(data2) {
2003
2017
  data2.data
2004
2018
  );
2005
2019
  }
2006
- function errorResponseToResponse(error) {
2007
- return new Response(
2008
- typeof error.data === "string" ? error.data : JSON.stringify(error.data),
2009
- {
2010
- status: error.status,
2011
- statusText: error.statusText
2012
- }
2013
- );
2014
- }
2015
2020
  function isDataStrategyResult(result) {
2016
2021
  return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
2017
2022
  }
@@ -2719,7 +2724,12 @@ async function getRSCRouteMatch({
2719
2724
  path: match.route.path,
2720
2725
  pathname: match.pathname,
2721
2726
  pathnameBase: match.pathnameBase,
2722
- shouldRevalidate: match.route.shouldRevalidate
2727
+ shouldRevalidate: match.route.shouldRevalidate,
2728
+ // Add an unused client-only export (if present) so HMR can support
2729
+ // switching between server-first and client-only routes during development
2730
+ ...match.route.__ensureClientRouteModuleForHMR ? {
2731
+ __ensureClientRouteModuleForHMR: match.route.__ensureClientRouteModuleForHMR
2732
+ } : {}
2723
2733
  };
2724
2734
  }
2725
2735
  async function getManifestRoute(route) {
@@ -3144,4 +3154,4 @@ function createMemorySessionStorage({ cookie } = {}) {
3144
3154
  });
3145
3155
  }
3146
3156
 
3147
- export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRoutes, redirect2 as redirect, redirectDocument2 as redirectDocument, replace2 as replace, unstable_RouterContextProvider, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
3157
+ export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect2 as redirect, redirectDocument2 as redirectDocument, replace2 as replace, unstable_RouterContextProvider, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
@@ -4,10 +4,10 @@ import { a as RouteComponentType, H as HydrateFallbackType, E as ErrorBoundaryTy
4
4
  export { f as Await, A as AwaitProps, I as IndexRouteProps, L as LayoutRouteProps, g as MemoryRouter, M as MemoryRouterOpts, b as MemoryRouterProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, P as PathRouteProps, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, W as UNSAFE_WithComponentProps, v as UNSAFE_WithErrorBoundaryProps, t as UNSAFE_WithHydrateFallbackProps, q as UNSAFE_hydrationRouteProperties, s as UNSAFE_mapRouteProperties, w as UNSAFE_withComponentProps, x as UNSAFE_withErrorBoundaryProps, u as UNSAFE_withHydrateFallbackProps, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, r as renderMatches } from './components-CuPfnyiZ.mjs';
5
5
  import * as React from 'react';
6
6
  import React__default, { ReactElement } from 'react';
7
- import { c as RouteModules, d as SerializeFrom, e as MetaFunction, f as LinksFunction, A as AppLoadContext, E as Equal, g as ClientActionFunction, h as ClientLoaderFunction, H as HeadersFunction } from './route-data-CpB5xtMm.mjs';
8
- export { i as ClientActionFunctionArgs, j as ClientLoaderFunctionArgs, k as HeadersArgs, n as HtmlLinkDescriptor, L as LinkDescriptor, l as MetaArgs, M as MetaDescriptor, m as PageLinkDescriptor, u as unstable_SerializesTo } from './route-data-CpB5xtMm.mjs';
9
- import { A as AssetsManifest, E as EntryContext, F as FutureConfig, S as ServerBuild } from './index-react-server-client-DXb0OgpJ.mjs';
10
- export { l as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, a1 as DiscoverBehavior, c as FetcherFormProps, h as FetcherSubmitFunction, G as FetcherSubmitOptions, i as FetcherWithComponents, q as Form, d as FormProps, a2 as HandleDataRequestFunction, a3 as HandleDocumentRequestFunction, a4 as HandleErrorFunction, m as HashRouter, H as HashRouterProps, a as HistoryRouterProps, n as Link, L as LinkProps, X as Links, _ as LinksProps, W as Meta, p as NavLink, N as NavLinkProps, b as NavLinkRenderProps, P as ParamKeyValuePair, a0 as PrefetchBehavior, Z as PrefetchPageLinks, Y as Scripts, $ as ScriptsProps, r as ScrollRestoration, e as ScrollRestorationProps, a5 as ServerEntryModule, f as SetURLSearchParams, T as StaticRouter, M as StaticRouterProps, V as StaticRouterProvider, O as StaticRouterProviderProps, g as SubmitFunction, I as SubmitOptions, J as SubmitTarget, a6 as UNSAFE_FrameworkContext, a7 as UNSAFE_createClientRoutes, a8 as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, a9 as UNSAFE_shouldHydrateRouteLoader, aa as UNSAFE_useScrollRestoration, U as URLSearchParamsInit, j as createBrowserRouter, k as createHashRouter, K as createSearchParams, Q as createStaticHandler, R as createStaticRouter, o as unstable_HistoryRouter, z as unstable_usePrompt, y as useBeforeUnload, w as useFetcher, x as useFetchers, v as useFormAction, u as useLinkClickHandler, s as useSearchParams, t as useSubmit, C as useViewTransitionState } from './index-react-server-client-DXb0OgpJ.mjs';
7
+ import { c as RouteModules, d as SerializeFrom, e as MetaFunction, f as LinksFunction, A as AppLoadContext, E as Equal, g as ClientActionFunction, h as ClientLoaderFunction, H as HeadersFunction } from './route-data-CNjObrhZ.mjs';
8
+ export { i as ClientActionFunctionArgs, j as ClientLoaderFunctionArgs, k as HeadersArgs, n as HtmlLinkDescriptor, L as LinkDescriptor, l as MetaArgs, M as MetaDescriptor, m as PageLinkDescriptor, u as unstable_SerializesTo } from './route-data-CNjObrhZ.mjs';
9
+ import { A as AssetsManifest, E as EntryContext, F as FutureConfig, S as ServerBuild } from './index-react-server-client-11fLy3qB.mjs';
10
+ export { l as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, a1 as DiscoverBehavior, c as FetcherFormProps, h as FetcherSubmitFunction, G as FetcherSubmitOptions, i as FetcherWithComponents, q as Form, d as FormProps, a2 as HandleDataRequestFunction, a3 as HandleDocumentRequestFunction, a4 as HandleErrorFunction, m as HashRouter, H as HashRouterProps, a as HistoryRouterProps, n as Link, L as LinkProps, X as Links, _ as LinksProps, W as Meta, p as NavLink, N as NavLinkProps, b as NavLinkRenderProps, P as ParamKeyValuePair, a0 as PrefetchBehavior, Z as PrefetchPageLinks, Y as Scripts, $ as ScriptsProps, r as ScrollRestoration, e as ScrollRestorationProps, a5 as ServerEntryModule, f as SetURLSearchParams, T as StaticRouter, M as StaticRouterProps, V as StaticRouterProvider, O as StaticRouterProviderProps, g as SubmitFunction, I as SubmitOptions, J as SubmitTarget, a6 as UNSAFE_FrameworkContext, a7 as UNSAFE_createClientRoutes, a8 as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, a9 as UNSAFE_shouldHydrateRouteLoader, aa as UNSAFE_useScrollRestoration, U as URLSearchParamsInit, j as createBrowserRouter, k as createHashRouter, K as createSearchParams, Q as createStaticHandler, R as createStaticRouter, o as unstable_HistoryRouter, z as unstable_usePrompt, y as useBeforeUnload, w as useFetcher, x as useFetchers, v as useFormAction, u as useLinkClickHandler, s as useSearchParams, t as useSubmit, C as useViewTransitionState } from './index-react-server-client-11fLy3qB.mjs';
11
11
  import { ParseOptions, SerializeOptions } from 'cookie';
12
12
  export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
13
13
  import { P as Pages } from './register-DiOIlEq5.mjs';
@@ -220,6 +220,44 @@ interface NavigateFunction {
220
220
  * middle of a page, and you don't want it to scroll to the top when a tab is
221
221
  * clicked.
222
222
  *
223
+ * ### Return Type Augmentation
224
+ *
225
+ * Internally, `useNavigate` uses a separate implementation when you are in
226
+ * Declarative mode versus Data/Framework mode - the primary difference being
227
+ * that the latter is able to return a stable reference that does not change
228
+ * identity across navigations. The implementation in Data/Framework mode also
229
+ * returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
230
+ * that resolves when the navigation is completed. This means the return type of
231
+ * `useNavigate` is `void | Promise<void>`. This is accurate, but can lead to
232
+ * some red squigglies based on the union in the return value:
233
+ *
234
+ * - If you're using `typescript-eslint`, you may see errors from
235
+ * [`@typescript-eslint/no-floating-promises`](https://typescript-eslint.io/rules/no-floating-promises)
236
+ * - In Framework/Data mode, `React.use(navigate())` will show a false-positive
237
+ * `Argument of type 'void | Promise<void>' is not assignable to parameter of
238
+ * type 'Usable<void>'` error
239
+ *
240
+ * The easiest way to work around these issues is to augment the type based on the
241
+ * router you're using:
242
+ *
243
+ * ```ts
244
+ * // If using <BrowserRouter>
245
+ * declare module "react-router" {
246
+ * interface NavigateFunction {
247
+ * (to: To, options?: NavigateOptions): void;
248
+ * (delta: number): void;
249
+ * }
250
+ * }
251
+ *
252
+ * // If using <RouterProvider> or Framework mode
253
+ * declare module "react-router" {
254
+ * interface NavigateFunction {
255
+ * (to: To, options?: NavigateOptions): Promise<void>;
256
+ * (delta: number): Promise<void>;
257
+ * }
258
+ * }
259
+ * ```
260
+ *
223
261
  * @public
224
262
  * @category Hooks
225
263
  * @returns A navigate function for programmatic navigation
@@ -1,7 +1,7 @@
1
- import { d as Router, e as RouteModules, D as DataStrategyFunction, T as To, f as NavigateOptions, B as BlockerFunction, g as Blocker, h as SerializeFrom, i as RelativeRoutingType, a as Location, j as ParamParseKey, k as Path, l as PathPattern, m as PathMatch, U as UIMatch, n as Navigation, A as Action, o as Params, p as RouteObject, I as InitialEntry, H as HydrationState, q as IndexRouteObject, r as LoaderFunction, s as ActionFunction, t as MetaFunction, v as LinksFunction, w as NonIndexRouteObject, x as AppLoadContext, y as unstable_RouterContextProvider, z as MiddlewareEnabled, E as Equal, F as ClientActionFunction, J as ClientLoaderFunction, K as HeadersFunction, O as ShouldRevalidateFunction, Q as RouterInit, V as RouterState, W as PatchRoutesOnNavigationFunction, X as DataRouteObject } from './routeModules-qBivMBjd.js';
2
- export { a6 as ActionFunctionArgs, aF as ClientActionFunctionArgs, aG as ClientLoaderFunctionArgs, aB as DataRouteMatch, a7 as DataStrategyFunctionArgs, a8 as DataStrategyMatch, a9 as DataStrategyResult, ab as ErrorResponse, a0 as Fetcher, ac as FormEncType, ad as FormMethod, aL as Future, Z as GetScrollPositionFunction, _ as GetScrollRestorationKeyFunction, ae as HTMLFormMethod, aH as HeadersArgs, aK as HtmlLinkDescriptor, ar as IDLE_BLOCKER, aq as IDLE_FETCHER, ap as IDLE_NAVIGATION, af as LazyRouteFunction, L as LinkDescriptor, ag as LoaderFunctionArgs, aI as MetaArgs, M as MetaDescriptor, a1 as NavigationStates, aC as Navigator, aJ as PageLinkDescriptor, aD as PatchRoutesOnNavigationFunctionArgs, ai as PathParam, aj as RedirectFunction, a5 as RevalidationState, aE as RouteMatch, a4 as RouterFetchOptions, a3 as RouterNavigateOptions, a2 as RouterSubscriber, al as ShouldRevalidateFunctionArgs, Y as StaticHandler, $ as StaticHandlerContext, aR as UNSAFE_DataRouterContext, aS as UNSAFE_DataRouterStateContext, aa as UNSAFE_DataWithResponseInit, aQ as UNSAFE_ErrorResponseImpl, aT as UNSAFE_FetchersContext, aU as UNSAFE_LocationContext, aV as UNSAFE_NavigationContext, aW as UNSAFE_RouteContext, aX as UNSAFE_ViewTransitionContext, aN as UNSAFE_createBrowserHistory, aP as UNSAFE_createRouter, aO as UNSAFE_invariant, an as createPath, as as data, at as generatePath, au as isRouteErrorResponse, av as matchPath, aw as matchRoutes, ao as parsePath, ax as redirect, ay as redirectDocument, az as replace, aA as resolvePath, ah as unstable_MiddlewareFunction, ak as unstable_RouterContext, aM as unstable_SerializesTo, am as unstable_createContext } from './routeModules-qBivMBjd.js';
3
- import { A as AssetsManifest, E as EntryContext, F as FutureConfig, R as RouteComponentType, H as HydrateFallbackType, a as ErrorBoundaryType, S as ServerBuild } from './index-react-server-client-CMphySRb.js';
4
- export { h as Await, b as AwaitProps, V as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, as as DiscoverBehavior, y as FetcherFormProps, K as FetcherSubmitFunction, a9 as FetcherSubmitOptions, Q as FetcherWithComponents, _ as Form, z as FormProps, at as HandleDataRequestFunction, au as HandleDocumentRequestFunction, av as HandleErrorFunction, W as HashRouter, t as HashRouterProps, u as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, X as Link, v as LinkProps, am as Links, ap as LinksProps, i as MemoryRouter, M as MemoryRouterOpts, c as MemoryRouterProps, al as Meta, Z as NavLink, w as NavLinkProps, x as NavLinkRenderProps, j as Navigate, N as NavigateProps, k as Outlet, O as OutletProps, aa as ParamKeyValuePair, P as PathRouteProps, ar as PrefetchBehavior, ao as PrefetchPageLinks, l as Route, d as RouteProps, m as Router, e as RouterProps, n as RouterProvider, f as RouterProviderProps, o as Routes, g as RoutesProps, an as Scripts, aq as ScriptsProps, $ as ScrollRestoration, C as ScrollRestorationProps, aw as ServerEntryModule, G as SetURLSearchParams, aj as StaticRouter, af as StaticRouterProps, ak as StaticRouterProvider, ag as StaticRouterProviderProps, J as SubmitFunction, ab as SubmitOptions, ad as SubmitTarget, aF as UNSAFE_FrameworkContext, az as UNSAFE_WithComponentProps, aD as UNSAFE_WithErrorBoundaryProps, aB as UNSAFE_WithHydrateFallbackProps, aG as UNSAFE_createClientRoutes, aH as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ax as UNSAFE_hydrationRouteProperties, ay as UNSAFE_mapRouteProperties, aI as UNSAFE_shouldHydrateRouteLoader, aJ as UNSAFE_useScrollRestoration, aA as UNSAFE_withComponentProps, aE as UNSAFE_withErrorBoundaryProps, aC as UNSAFE_withHydrateFallbackProps, ac as URLSearchParamsInit, T as createBrowserRouter, U as createHashRouter, p as createMemoryRouter, q as createRoutesFromChildren, r as createRoutesFromElements, ae as createSearchParams, ah as createStaticHandler, ai as createStaticRouter, s as renderMatches, Y as unstable_HistoryRouter, a7 as unstable_usePrompt, a6 as useBeforeUnload, a4 as useFetcher, a5 as useFetchers, a3 as useFormAction, a0 as useLinkClickHandler, a1 as useSearchParams, a2 as useSubmit, a8 as useViewTransitionState } from './index-react-server-client-CMphySRb.js';
1
+ import { d as Router, e as RouteModules, D as DataStrategyFunction, T as To, f as NavigateOptions, B as BlockerFunction, g as Blocker, h as SerializeFrom, i as RelativeRoutingType, a as Location, j as ParamParseKey, k as Path, l as PathPattern, m as PathMatch, U as UIMatch, n as Navigation, A as Action, o as Params, p as RouteObject, I as InitialEntry, H as HydrationState, q as IndexRouteObject, r as LoaderFunction, s as ActionFunction, t as MetaFunction, v as LinksFunction, w as NonIndexRouteObject, x as AppLoadContext, y as unstable_RouterContextProvider, z as MiddlewareEnabled, E as Equal, J as ClientActionFunction, K as ClientLoaderFunction, O as HeadersFunction, Q as ShouldRevalidateFunction, V as RouterInit, W as RouterState, X as PatchRoutesOnNavigationFunction, Y as DataRouteObject } from './routeModules-C3oqzPpI.js';
2
+ export { a7 as ActionFunctionArgs, aG as ClientActionFunctionArgs, aH as ClientLoaderFunctionArgs, aC as DataRouteMatch, a8 as DataStrategyFunctionArgs, a9 as DataStrategyMatch, aa as DataStrategyResult, ac as ErrorResponse, a1 as Fetcher, ad as FormEncType, ae as FormMethod, aM as Future, _ as GetScrollPositionFunction, $ as GetScrollRestorationKeyFunction, af as HTMLFormMethod, aI as HeadersArgs, aL as HtmlLinkDescriptor, as as IDLE_BLOCKER, ar as IDLE_FETCHER, aq as IDLE_NAVIGATION, ag as LazyRouteFunction, L as LinkDescriptor, ah as LoaderFunctionArgs, aJ as MetaArgs, M as MetaDescriptor, a2 as NavigationStates, aD as Navigator, aK as PageLinkDescriptor, aE as PatchRoutesOnNavigationFunctionArgs, aj as PathParam, ak as RedirectFunction, a6 as RevalidationState, aF as RouteMatch, a5 as RouterFetchOptions, a4 as RouterNavigateOptions, a3 as RouterSubscriber, am as ShouldRevalidateFunctionArgs, Z as StaticHandler, a0 as StaticHandlerContext, aS as UNSAFE_DataRouterContext, aT as UNSAFE_DataRouterStateContext, ab as UNSAFE_DataWithResponseInit, aR as UNSAFE_ErrorResponseImpl, aU as UNSAFE_FetchersContext, aV as UNSAFE_LocationContext, aW as UNSAFE_NavigationContext, aX as UNSAFE_RouteContext, aY as UNSAFE_ViewTransitionContext, aO as UNSAFE_createBrowserHistory, aQ as UNSAFE_createRouter, aP as UNSAFE_invariant, ao as createPath, at as data, au as generatePath, av as isRouteErrorResponse, aw as matchPath, ax as matchRoutes, ap as parsePath, ay as redirect, az as redirectDocument, aA as replace, aB as resolvePath, ai as unstable_MiddlewareFunction, al as unstable_RouterContext, aN as unstable_SerializesTo, an as unstable_createContext } from './routeModules-C3oqzPpI.js';
3
+ import { A as AssetsManifest, E as EntryContext, F as FutureConfig, R as RouteComponentType, H as HydrateFallbackType, a as ErrorBoundaryType, S as ServerBuild } from './index-react-server-client-BQ6FxdA_.js';
4
+ export { h as Await, b as AwaitProps, V as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, as as DiscoverBehavior, y as FetcherFormProps, K as FetcherSubmitFunction, a9 as FetcherSubmitOptions, Q as FetcherWithComponents, _ as Form, z as FormProps, at as HandleDataRequestFunction, au as HandleDocumentRequestFunction, av as HandleErrorFunction, W as HashRouter, t as HashRouterProps, u as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, X as Link, v as LinkProps, am as Links, ap as LinksProps, i as MemoryRouter, M as MemoryRouterOpts, c as MemoryRouterProps, al as Meta, Z as NavLink, w as NavLinkProps, x as NavLinkRenderProps, j as Navigate, N as NavigateProps, k as Outlet, O as OutletProps, aa as ParamKeyValuePair, P as PathRouteProps, ar as PrefetchBehavior, ao as PrefetchPageLinks, l as Route, d as RouteProps, m as Router, e as RouterProps, n as RouterProvider, f as RouterProviderProps, o as Routes, g as RoutesProps, an as Scripts, aq as ScriptsProps, $ as ScrollRestoration, C as ScrollRestorationProps, aw as ServerEntryModule, G as SetURLSearchParams, aj as StaticRouter, af as StaticRouterProps, ak as StaticRouterProvider, ag as StaticRouterProviderProps, J as SubmitFunction, ab as SubmitOptions, ad as SubmitTarget, aF as UNSAFE_FrameworkContext, az as UNSAFE_WithComponentProps, aD as UNSAFE_WithErrorBoundaryProps, aB as UNSAFE_WithHydrateFallbackProps, aG as UNSAFE_createClientRoutes, aH as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ax as UNSAFE_hydrationRouteProperties, ay as UNSAFE_mapRouteProperties, aI as UNSAFE_shouldHydrateRouteLoader, aJ as UNSAFE_useScrollRestoration, aA as UNSAFE_withComponentProps, aE as UNSAFE_withErrorBoundaryProps, aC as UNSAFE_withHydrateFallbackProps, ac as URLSearchParamsInit, T as createBrowserRouter, U as createHashRouter, p as createMemoryRouter, q as createRoutesFromChildren, r as createRoutesFromElements, ae as createSearchParams, ah as createStaticHandler, ai as createStaticRouter, s as renderMatches, Y as unstable_HistoryRouter, a7 as unstable_usePrompt, a6 as useBeforeUnload, a4 as useFetcher, a5 as useFetchers, a3 as useFormAction, a0 as useLinkClickHandler, a1 as useSearchParams, a2 as useSubmit, a8 as useViewTransitionState } from './index-react-server-client-BQ6FxdA_.js';
5
5
  import * as React from 'react';
6
6
  import React__default, { ReactElement } from 'react';
7
7
  import { ParseOptions, SerializeOptions } from 'cookie';
@@ -215,6 +215,44 @@ interface NavigateFunction {
215
215
  * middle of a page, and you don't want it to scroll to the top when a tab is
216
216
  * clicked.
217
217
  *
218
+ * ### Return Type Augmentation
219
+ *
220
+ * Internally, `useNavigate` uses a separate implementation when you are in
221
+ * Declarative mode versus Data/Framework mode - the primary difference being
222
+ * that the latter is able to return a stable reference that does not change
223
+ * identity across navigations. The implementation in Data/Framework mode also
224
+ * returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
225
+ * that resolves when the navigation is completed. This means the return type of
226
+ * `useNavigate` is `void | Promise<void>`. This is accurate, but can lead to
227
+ * some red squigglies based on the union in the return value:
228
+ *
229
+ * - If you're using `typescript-eslint`, you may see errors from
230
+ * [`@typescript-eslint/no-floating-promises`](https://typescript-eslint.io/rules/no-floating-promises)
231
+ * - In Framework/Data mode, `React.use(navigate())` will show a false-positive
232
+ * `Argument of type 'void | Promise<void>' is not assignable to parameter of
233
+ * type 'Usable<void>'` error
234
+ *
235
+ * The easiest way to work around these issues is to augment the type based on the
236
+ * router you're using:
237
+ *
238
+ * ```ts
239
+ * // If using <BrowserRouter>
240
+ * declare module "react-router" {
241
+ * interface NavigateFunction {
242
+ * (to: To, options?: NavigateOptions): void;
243
+ * (delta: number): void;
244
+ * }
245
+ * }
246
+ *
247
+ * // If using <RouterProvider> or Framework mode
248
+ * declare module "react-router" {
249
+ * interface NavigateFunction {
250
+ * (to: To, options?: NavigateOptions): Promise<void>;
251
+ * (delta: number): Promise<void>;
252
+ * }
253
+ * }
254
+ * ```
255
+ *
218
256
  * @public
219
257
  * @category Hooks
220
258
  * @returns A navigate function for programmatic navigation