react-router 7.13.1 → 7.13.2

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 (76) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/{production/browser-DzsJABDQ.d.mts → development/browser-Bfn3xw9E.d.ts} +2 -1
  3. package/dist/development/{browser-DzsJABDQ.d.mts → browser-Di6-vSl-.d.mts} +2 -1
  4. package/dist/development/{chunk-XOLAXE2Z.js → chunk-GO74ODU3.js} +190 -111
  5. package/dist/{production/chunk-B5UMK6O7.js → development/chunk-HPFFRPKK.js} +100 -99
  6. package/dist/development/{chunk-KSEWV2VO.js → chunk-LLP6DRWX.js} +7 -7
  7. package/dist/{production/chunk-TXB4YXR2.mjs → development/chunk-UALY5CBT.mjs} +83 -49
  8. package/dist/development/{chunk-LFPYN7LY.mjs → chunk-UVKPFVEO.mjs} +124 -44
  9. package/dist/development/context-phCt_zmH.d.mts +1713 -0
  10. package/dist/development/dom-export.d.mts +3 -2
  11. package/dist/development/dom-export.d.ts +3 -2
  12. package/dist/development/dom-export.js +45 -29
  13. package/dist/development/dom-export.mjs +21 -5
  14. package/dist/development/{index-react-server-client-C4tCIird.d.ts → index-react-server-client-BcrVT7Dd.d.mts} +4 -2
  15. package/dist/{production/index-react-server-client-EzWJGpN_.d.mts → development/index-react-server-client-CCwMoQIT.d.ts} +1067 -10
  16. package/dist/development/index-react-server-client.d.mts +3 -2
  17. package/dist/development/index-react-server-client.d.ts +3 -2
  18. package/dist/development/index-react-server-client.js +4 -4
  19. package/dist/development/index-react-server-client.mjs +2 -2
  20. package/dist/development/index-react-server.d.mts +293 -246
  21. package/dist/development/index-react-server.d.ts +293 -246
  22. package/dist/development/index-react-server.js +121 -43
  23. package/dist/development/index-react-server.mjs +121 -43
  24. package/dist/development/index.d.mts +15 -13
  25. package/dist/development/index.d.ts +15 -13
  26. package/dist/development/index.js +176 -142
  27. package/dist/development/index.mjs +3 -3
  28. package/dist/development/instrumentation-BYr6ff5D.d.ts +657 -0
  29. package/dist/development/lib/types/internal.d.mts +2 -2
  30. package/dist/development/lib/types/internal.d.ts +2 -2
  31. package/dist/development/lib/types/internal.js +1 -1
  32. package/dist/development/lib/types/internal.mjs +1 -1
  33. package/dist/development/{register-CBoanF80.d.ts → register-CTxsJBKQ.d.mts} +1 -1
  34. package/dist/development/{register-cRYJ3CjG.d.mts → register-CkcGwv27.d.ts} +1 -1
  35. package/dist/development/routeModules-BRrCYrSL.d.mts +1693 -0
  36. package/dist/development/routeModules-CA7kSxJJ.d.ts +1693 -0
  37. package/dist/production/{browser-sPQ7eaK4.d.ts → browser-Bfn3xw9E.d.ts} +2 -1
  38. package/dist/{development/browser-sPQ7eaK4.d.ts → production/browser-Di6-vSl-.d.mts} +2 -1
  39. package/dist/production/{chunk-RJCJ3EYF.mjs → chunk-2BDJPJTA.mjs} +124 -44
  40. package/dist/production/{chunk-ZJMCM6KT.js → chunk-CAFVLUDY.js} +7 -7
  41. package/dist/production/{chunk-772H4TVR.js → chunk-LKUVSIBA.js} +190 -111
  42. package/dist/{development/chunk-JPUPSTYD.mjs → production/chunk-PY35PE22.mjs} +83 -49
  43. package/dist/{development/chunk-2YMDXNOJ.js → production/chunk-XAAX7KIK.js} +100 -99
  44. package/dist/production/context-phCt_zmH.d.mts +1713 -0
  45. package/dist/production/dom-export.d.mts +3 -2
  46. package/dist/production/dom-export.d.ts +3 -2
  47. package/dist/production/dom-export.js +45 -29
  48. package/dist/production/dom-export.mjs +21 -5
  49. package/dist/{development/index-react-server-client-EzWJGpN_.d.mts → production/index-react-server-client-BcrVT7Dd.d.mts} +4 -2
  50. package/dist/production/{index-react-server-client-C4tCIird.d.ts → index-react-server-client-CCwMoQIT.d.ts} +1067 -10
  51. package/dist/production/index-react-server-client.d.mts +3 -2
  52. package/dist/production/index-react-server-client.d.ts +3 -2
  53. package/dist/production/index-react-server-client.js +4 -4
  54. package/dist/production/index-react-server-client.mjs +2 -2
  55. package/dist/production/index-react-server.d.mts +293 -246
  56. package/dist/production/index-react-server.d.ts +293 -246
  57. package/dist/production/index-react-server.js +121 -43
  58. package/dist/production/index-react-server.mjs +121 -43
  59. package/dist/production/index.d.mts +15 -13
  60. package/dist/production/index.d.ts +15 -13
  61. package/dist/production/index.js +176 -142
  62. package/dist/production/index.mjs +3 -3
  63. package/dist/production/instrumentation-BYr6ff5D.d.ts +657 -0
  64. package/dist/production/lib/types/internal.d.mts +2 -2
  65. package/dist/production/lib/types/internal.d.ts +2 -2
  66. package/dist/production/lib/types/internal.js +1 -1
  67. package/dist/production/lib/types/internal.mjs +1 -1
  68. package/dist/production/{register-CBoanF80.d.ts → register-CTxsJBKQ.d.mts} +1 -1
  69. package/dist/production/{register-cRYJ3CjG.d.mts → register-CkcGwv27.d.ts} +1 -1
  70. package/dist/production/routeModules-BRrCYrSL.d.mts +1693 -0
  71. package/dist/production/routeModules-CA7kSxJJ.d.ts +1693 -0
  72. package/package.json +1 -1
  73. package/dist/development/instrumentation--6Pioq_G.d.ts +0 -3344
  74. package/dist/development/router-cLsU7kHk.d.mts +0 -3344
  75. package/dist/production/instrumentation--6Pioq_G.d.ts +0 -3344
  76. package/dist/production/router-cLsU7kHk.d.mts +0 -3344
@@ -356,6 +356,15 @@ type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextPro
356
356
  interface DataFunctionArgs<Context> {
357
357
  /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
358
358
  request: Request;
359
+ /**
360
+ * A URL instance representing the application location being navigated to or fetched.
361
+ * Without `future.unstable_passThroughRequests` enabled, this matches `request.url`.
362
+ * With `future.unstable_passThroughRequests` enabled, this is a normalized
363
+ * URL with React-Router-specific implementation details removed (`.data`
364
+ * suffixes, `index`/`_routes` search params).
365
+ * The URL includes the origin from the request for convenience.
366
+ */
367
+ unstable_url: URL;
359
368
  /**
360
369
  * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
361
370
  * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
@@ -433,11 +442,11 @@ interface ShouldRevalidateFunctionArgs {
433
442
  /** This is the url the navigation started from. You can compare it with `nextUrl` to decide if you need to revalidate this route's data. */
434
443
  currentUrl: URL;
435
444
  /** These are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the URL that can be compared to the `nextParams` to decide if you need to reload or not. Perhaps you're using only a partial piece of the param for data loading, you don't need to revalidate if a superfluous part of the param changed. */
436
- currentParams: AgnosticDataRouteMatch["params"];
445
+ currentParams: DataRouteMatch["params"];
437
446
  /** In the case of navigation, this the URL the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentUrl. */
438
447
  nextUrl: URL;
439
448
  /** In the case of navigation, these are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the next location the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentParams. */
440
- nextParams: AgnosticDataRouteMatch["params"];
449
+ nextParams: DataRouteMatch["params"];
441
450
  /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
442
451
  formMethod?: Submission["formMethod"];
443
452
  /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
@@ -492,7 +501,7 @@ interface ShouldRevalidateFunctionArgs {
492
501
  interface ShouldRevalidateFunction {
493
502
  (args: ShouldRevalidateFunctionArgs): boolean;
494
503
  }
495
- interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
504
+ interface DataStrategyMatch extends RouteMatch<string, DataRouteObject> {
496
505
  /**
497
506
  * @private
498
507
  */
@@ -582,20 +591,19 @@ interface DataStrategyResult {
582
591
  interface DataStrategyFunction<Context = DefaultContext> {
583
592
  (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
584
593
  }
585
- type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
594
+ type PatchRoutesOnNavigationFunctionArgs = {
586
595
  signal: AbortSignal;
587
596
  path: string;
588
- matches: M[];
597
+ matches: RouteMatch[];
589
598
  fetcherKey: string | undefined;
590
- patch: (routeId: string | null, children: O[]) => void;
599
+ patch: (routeId: string | null, children: RouteObject[]) => void;
591
600
  };
592
- type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
601
+ type PatchRoutesOnNavigationFunction = (opts: PatchRoutesOnNavigationFunctionArgs) => MaybePromise<void>;
593
602
  /**
594
- * Function provided by the framework-aware layers to set any framework-specific
595
- * properties from framework-agnostic properties
603
+ * Function provided to set route-specific properties from route objects
596
604
  */
597
605
  interface MapRoutePropertiesFunction {
598
- (route: AgnosticDataRouteObject): {
606
+ (route: DataRouteObject): {
599
607
  hasErrorBoundary: boolean;
600
608
  } & Record<string, any>;
601
609
  }
@@ -615,62 +623,139 @@ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middlewa
615
623
  * lazy object to load route properties, which can add non-matching
616
624
  * related properties to a route
617
625
  */
618
- type LazyRouteObject<R extends AgnosticRouteObject> = {
626
+ type LazyRouteObject<R extends RouteObject> = {
619
627
  [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
620
628
  };
621
629
  /**
622
630
  * lazy() function to load a route definition, which can add non-matching
623
631
  * related properties to a route
624
632
  */
625
- interface LazyRouteFunction<R extends AgnosticRouteObject> {
633
+ interface LazyRouteFunction<R extends RouteObject> {
626
634
  (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
627
635
  }
628
- type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
636
+ type LazyRouteDefinition<R extends RouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
629
637
  /**
630
638
  * Base RouteObject with common props shared by all types of routes
639
+ * @internal
631
640
  */
632
- type AgnosticBaseRouteObject = {
641
+ type BaseRouteObject = {
642
+ /**
643
+ * Whether the path should be case-sensitive. Defaults to `false`.
644
+ */
633
645
  caseSensitive?: boolean;
646
+ /**
647
+ * The path pattern to match. If unspecified or empty, then this becomes a
648
+ * layout route.
649
+ */
634
650
  path?: string;
651
+ /**
652
+ * The unique identifier for this route (for use with {@link DataRouter}s)
653
+ */
635
654
  id?: string;
655
+ /**
656
+ * The route middleware.
657
+ * See [`middleware`](../../start/data/route-object#middleware).
658
+ */
636
659
  middleware?: MiddlewareFunction[];
660
+ /**
661
+ * The route loader.
662
+ * See [`loader`](../../start/data/route-object#loader).
663
+ */
637
664
  loader?: LoaderFunction | boolean;
665
+ /**
666
+ * The route action.
667
+ * See [`action`](../../start/data/route-object#action).
668
+ */
638
669
  action?: ActionFunction | boolean;
639
670
  hasErrorBoundary?: boolean;
671
+ /**
672
+ * The route shouldRevalidate function.
673
+ * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
674
+ */
640
675
  shouldRevalidate?: ShouldRevalidateFunction;
676
+ /**
677
+ * The route handle.
678
+ */
641
679
  handle?: any;
642
- lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
680
+ /**
681
+ * A function that returns a promise that resolves to the route object.
682
+ * Used for code-splitting routes.
683
+ * See [`lazy`](../../start/data/route-object#lazy).
684
+ */
685
+ lazy?: LazyRouteDefinition<BaseRouteObject>;
686
+ /**
687
+ * The React Component to render when this route matches.
688
+ * Mutually exclusive with `element`.
689
+ */
690
+ Component?: React.ComponentType | null;
691
+ /**
692
+ * The React element to render when this Route matches.
693
+ * Mutually exclusive with `Component`.
694
+ */
695
+ element?: React.ReactNode | null;
696
+ /**
697
+ * The React Component to render at this route if an error occurs.
698
+ * Mutually exclusive with `errorElement`.
699
+ */
700
+ ErrorBoundary?: React.ComponentType | null;
701
+ /**
702
+ * The React element to render at this route if an error occurs.
703
+ * Mutually exclusive with `ErrorBoundary`.
704
+ */
705
+ errorElement?: React.ReactNode | null;
706
+ /**
707
+ * The React Component to render while this router is loading data.
708
+ * Mutually exclusive with `hydrateFallbackElement`.
709
+ */
710
+ HydrateFallback?: React.ComponentType | null;
711
+ /**
712
+ * The React element to render while this router is loading data.
713
+ * Mutually exclusive with `HydrateFallback`.
714
+ */
715
+ hydrateFallbackElement?: React.ReactNode | null;
643
716
  };
644
717
  /**
645
718
  * Index routes must not have children
646
719
  */
647
- type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
720
+ type IndexRouteObject = BaseRouteObject & {
721
+ /**
722
+ * Child Route objects - not valid on index routes.
723
+ */
648
724
  children?: undefined;
725
+ /**
726
+ * Whether this is an index route.
727
+ */
649
728
  index: true;
650
729
  };
651
730
  /**
652
- * Non-index routes may have children, but cannot have index
731
+ * Non-index routes may have children, but cannot have `index` set to `true`.
653
732
  */
654
- type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
655
- children?: AgnosticRouteObject[];
733
+ type NonIndexRouteObject = BaseRouteObject & {
734
+ /**
735
+ * Child Route objects.
736
+ */
737
+ children?: RouteObject[];
738
+ /**
739
+ * Whether this is an index route - must be `false` or undefined on non-index routes.
740
+ */
656
741
  index?: false;
657
742
  };
658
743
  /**
659
744
  * A route object represents a logical route, with (optionally) its child
660
745
  * routes organized in a tree-like structure.
661
746
  */
662
- type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
663
- type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
747
+ type RouteObject = IndexRouteObject | NonIndexRouteObject;
748
+ type DataIndexRouteObject = IndexRouteObject & {
664
749
  id: string;
665
750
  };
666
- type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
667
- children?: AgnosticDataRouteObject[];
751
+ type DataNonIndexRouteObject = NonIndexRouteObject & {
752
+ children?: DataRouteObject[];
668
753
  id: string;
669
754
  };
670
755
  /**
671
756
  * A data route object, which is just a RouteObject with a required unique ID
672
757
  */
673
- type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
758
+ type DataRouteObject = DataIndexRouteObject | DataNonIndexRouteObject;
674
759
  /**
675
760
  * The parameters that were parsed from the URL path.
676
761
  */
@@ -680,7 +765,7 @@ type Params<Key extends string = string> = {
680
765
  /**
681
766
  * A RouteMatch contains info about how a route matched a URL.
682
767
  */
683
- interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
768
+ interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> {
684
769
  /**
685
770
  * The names and values of dynamic parameters in the URL.
686
771
  */
@@ -698,7 +783,7 @@ interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType e
698
783
  */
699
784
  route: RouteObjectType;
700
785
  }
701
- interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
786
+ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
702
787
  }
703
788
  /**
704
789
  * Matches the given routes to a location and returns the match data.
@@ -726,14 +811,14 @@ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticData
726
811
  * Defaults to `/`.
727
812
  * @returns An array of matched routes, or `null` if no matches were found.
728
813
  */
729
- declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
814
+ declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
730
815
  interface UIMatch<Data = unknown, Handle = unknown> {
731
816
  id: string;
732
817
  pathname: string;
733
818
  /**
734
819
  * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
735
820
  */
736
- params: AgnosticRouteMatch["params"];
821
+ params: RouteMatch["params"];
737
822
  /**
738
823
  * The return value from the matched route's loader or clientLoader. This might
739
824
  * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
@@ -1034,7 +1119,7 @@ interface Router {
1034
1119
  *
1035
1120
  * Return the routes for this router instance
1036
1121
  */
1037
- get routes(): AgnosticDataRouteObject[];
1122
+ get routes(): DataRouteObject[];
1038
1123
  /**
1039
1124
  * @private
1040
1125
  * PRIVATE - DO NOT USE
@@ -1184,7 +1269,7 @@ interface Router {
1184
1269
  * existing routes. Intended for RSC-usage
1185
1270
  * only.
1186
1271
  */
1187
- patchRoutes(routeId: string | null, children: AgnosticRouteObject[], unstable_allowElementMutations?: boolean): void;
1272
+ patchRoutes(routeId: string | null, children: RouteObject[], unstable_allowElementMutations?: boolean): void;
1188
1273
  /**
1189
1274
  * @private
1190
1275
  * PRIVATE - DO NOT USE
@@ -1192,7 +1277,7 @@ interface Router {
1192
1277
  * HMR needs to pass in-flight route updates to React Router
1193
1278
  * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
1194
1279
  */
1195
- _internalSetRoutes(routes: AgnosticRouteObject[]): void;
1280
+ _internalSetRoutes(routes: RouteObject[]): void;
1196
1281
  /**
1197
1282
  * @private
1198
1283
  * PRIVATE - DO NOT USE
@@ -1224,7 +1309,7 @@ interface RouterState {
1224
1309
  /**
1225
1310
  * The current set of route matches
1226
1311
  */
1227
- matches: AgnosticDataRouteMatch[];
1312
+ matches: DataRouteMatch[];
1228
1313
  /**
1229
1314
  * Tracks whether we've completed our initial data load
1230
1315
  */
@@ -1282,12 +1367,13 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
1282
1367
  * Future flags to toggle new feature behavior
1283
1368
  */
1284
1369
  interface FutureConfig {
1370
+ unstable_passThroughRequests: boolean;
1285
1371
  }
1286
1372
  /**
1287
1373
  * Initialization options for createRouter
1288
1374
  */
1289
1375
  interface RouterInit {
1290
- routes: AgnosticRouteObject[];
1376
+ routes: RouteObject[];
1291
1377
  history: History;
1292
1378
  basename?: string;
1293
1379
  getContext?: () => MaybePromise<RouterContextProvider>;
@@ -1298,7 +1384,7 @@ interface RouterInit {
1298
1384
  hydrationData?: HydrationState;
1299
1385
  window?: Window;
1300
1386
  dataStrategy?: DataStrategyFunction;
1301
- patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
1387
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
1302
1388
  }
1303
1389
  /**
1304
1390
  * State returned from a server-side query() call
@@ -1319,22 +1405,24 @@ interface StaticHandlerContext {
1319
1405
  * A StaticHandler instance manages a singular SSR navigation/fetch event
1320
1406
  */
1321
1407
  interface StaticHandler {
1322
- dataRoutes: AgnosticDataRouteObject[];
1408
+ dataRoutes: DataRouteObject[];
1323
1409
  query(request: Request, opts?: {
1324
1410
  requestContext?: unknown;
1325
- filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
1411
+ filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
1326
1412
  skipLoaderErrorBubbling?: boolean;
1327
1413
  skipRevalidation?: boolean;
1328
1414
  dataStrategy?: DataStrategyFunction<unknown>;
1329
1415
  generateMiddlewareResponse?: (query: (r: Request, args?: {
1330
- filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
1416
+ filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
1331
1417
  }) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
1418
+ unstable_normalizePath?: (request: Request) => Path;
1332
1419
  }): Promise<StaticHandlerContext | Response>;
1333
1420
  queryRoute(request: Request, opts?: {
1334
1421
  routeId?: string;
1335
1422
  requestContext?: unknown;
1336
1423
  dataStrategy?: DataStrategyFunction<unknown>;
1337
1424
  generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1425
+ unstable_normalizePath?: (request: Request) => Path;
1338
1426
  }): Promise<any>;
1339
1427
  }
1340
1428
  type ViewTransitionOpts = {
@@ -1562,216 +1650,9 @@ interface CreateStaticHandlerOptions {
1562
1650
  basename?: string;
1563
1651
  mapRouteProperties?: MapRoutePropertiesFunction;
1564
1652
  unstable_instrumentations?: Pick<unstable_ServerInstrumentation, "route">[];
1565
- future?: {};
1566
- }
1567
- declare function createStaticHandler(routes: AgnosticRouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
1568
-
1569
- interface AwaitResolveRenderFunction<Resolve = any> {
1570
- (data: Awaited<Resolve>): React.ReactNode;
1571
- }
1572
- /**
1573
- * @category Types
1574
- */
1575
- interface AwaitProps<Resolve> {
1576
- /**
1577
- * When using a function, the resolved value is provided as the parameter.
1578
- *
1579
- * ```tsx [2]
1580
- * <Await resolve={reviewsPromise}>
1581
- * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
1582
- * </Await>
1583
- * ```
1584
- *
1585
- * When using React elements, {@link useAsyncValue} will provide the
1586
- * resolved value:
1587
- *
1588
- * ```tsx [2]
1589
- * <Await resolve={reviewsPromise}>
1590
- * <Reviews />
1591
- * </Await>
1592
- *
1593
- * function Reviews() {
1594
- * const resolvedReviews = useAsyncValue();
1595
- * return <div>...</div>;
1596
- * }
1597
- * ```
1598
- */
1599
- children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
1600
- /**
1601
- * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1602
- * rejects.
1603
- *
1604
- * ```tsx
1605
- * <Await
1606
- * errorElement={<div>Oops</div>}
1607
- * resolve={reviewsPromise}
1608
- * >
1609
- * <Reviews />
1610
- * </Await>
1611
- * ```
1612
- *
1613
- * To provide a more contextual error, you can use the {@link useAsyncError} in a
1614
- * child component
1615
- *
1616
- * ```tsx
1617
- * <Await
1618
- * errorElement={<ReviewsError />}
1619
- * resolve={reviewsPromise}
1620
- * >
1621
- * <Reviews />
1622
- * </Await>
1623
- *
1624
- * function ReviewsError() {
1625
- * const error = useAsyncError();
1626
- * return <div>Error loading reviews: {error.message}</div>;
1627
- * }
1628
- * ```
1629
- *
1630
- * If you do not provide an `errorElement`, the rejected value will bubble up
1631
- * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
1632
- * and be accessible via the {@link useRouteError} hook.
1633
- */
1634
- errorElement?: React.ReactNode;
1635
- /**
1636
- * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1637
- * returned from a [`loader`](../../start/framework/route-module#loader) to be
1638
- * resolved and rendered.
1639
- *
1640
- * ```tsx
1641
- * import { Await, useLoaderData } from "react-router";
1642
- *
1643
- * export async function loader() {
1644
- * let reviews = getReviews(); // not awaited
1645
- * let book = await getBook();
1646
- * return {
1647
- * book,
1648
- * reviews, // this is a promise
1649
- * };
1650
- * }
1651
- *
1652
- * export default function Book() {
1653
- * const {
1654
- * book,
1655
- * reviews, // this is the same promise
1656
- * } = useLoaderData();
1657
- *
1658
- * return (
1659
- * <div>
1660
- * <h1>{book.title}</h1>
1661
- * <p>{book.description}</p>
1662
- * <React.Suspense fallback={<ReviewsSkeleton />}>
1663
- * <Await
1664
- * // and is the promise we pass to Await
1665
- * resolve={reviews}
1666
- * >
1667
- * <Reviews />
1668
- * </Await>
1669
- * </React.Suspense>
1670
- * </div>
1671
- * );
1672
- * }
1673
- * ```
1674
- */
1675
- resolve: Resolve;
1676
- }
1677
- /**
1678
- * Used to render promise values with automatic error handling.
1679
- *
1680
- * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
1681
- *
1682
- * @example
1683
- * import { Await, useLoaderData } from "react-router";
1684
- *
1685
- * export async function loader() {
1686
- * // not awaited
1687
- * const reviews = getReviews();
1688
- * // awaited (blocks the transition)
1689
- * const book = await fetch("/api/book").then((res) => res.json());
1690
- * return { book, reviews };
1691
- * }
1692
- *
1693
- * function Book() {
1694
- * const { book, reviews } = useLoaderData();
1695
- * return (
1696
- * <div>
1697
- * <h1>{book.title}</h1>
1698
- * <p>{book.description}</p>
1699
- * <React.Suspense fallback={<ReviewsSkeleton />}>
1700
- * <Await
1701
- * resolve={reviews}
1702
- * errorElement={
1703
- * <div>Could not load reviews 😬</div>
1704
- * }
1705
- * children={(resolvedReviews) => (
1706
- * <Reviews items={resolvedReviews} />
1707
- * )}
1708
- * />
1709
- * </React.Suspense>
1710
- * </div>
1711
- * );
1712
- * }
1713
- *
1714
- * @public
1715
- * @category Components
1716
- * @mode framework
1717
- * @mode data
1718
- * @param props Props
1719
- * @param {AwaitProps.children} props.children n/a
1720
- * @param {AwaitProps.errorElement} props.errorElement n/a
1721
- * @param {AwaitProps.resolve} props.resolve n/a
1722
- * @returns React element for the rendered awaited value
1723
- */
1724
- declare function Await$1<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
1725
-
1726
- interface IndexRouteObject {
1727
- caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
1728
- path?: AgnosticIndexRouteObject["path"];
1729
- id?: AgnosticIndexRouteObject["id"];
1730
- middleware?: AgnosticIndexRouteObject["middleware"];
1731
- loader?: AgnosticIndexRouteObject["loader"];
1732
- action?: AgnosticIndexRouteObject["action"];
1733
- hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
1734
- shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
1735
- handle?: AgnosticIndexRouteObject["handle"];
1736
- index: true;
1737
- children?: undefined;
1738
- element?: React.ReactNode | null;
1739
- hydrateFallbackElement?: React.ReactNode | null;
1740
- errorElement?: React.ReactNode | null;
1741
- Component?: React.ComponentType | null;
1742
- HydrateFallback?: React.ComponentType | null;
1743
- ErrorBoundary?: React.ComponentType | null;
1744
- lazy?: LazyRouteDefinition<RouteObject>;
1745
- }
1746
- interface NonIndexRouteObject {
1747
- caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
1748
- path?: AgnosticNonIndexRouteObject["path"];
1749
- id?: AgnosticNonIndexRouteObject["id"];
1750
- middleware?: AgnosticNonIndexRouteObject["middleware"];
1751
- loader?: AgnosticNonIndexRouteObject["loader"];
1752
- action?: AgnosticNonIndexRouteObject["action"];
1753
- hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
1754
- shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
1755
- handle?: AgnosticNonIndexRouteObject["handle"];
1756
- index?: false;
1757
- children?: RouteObject[];
1758
- element?: React.ReactNode | null;
1759
- hydrateFallbackElement?: React.ReactNode | null;
1760
- errorElement?: React.ReactNode | null;
1761
- Component?: React.ComponentType | null;
1762
- HydrateFallback?: React.ComponentType | null;
1763
- ErrorBoundary?: React.ComponentType | null;
1764
- lazy?: LazyRouteDefinition<RouteObject>;
1765
- }
1766
- type RouteObject = IndexRouteObject | NonIndexRouteObject;
1767
- type DataRouteObject = RouteObject & {
1768
- children?: DataRouteObject[];
1769
- id: string;
1770
- };
1771
- interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
1772
- }
1773
- interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
1653
+ future?: Partial<FutureConfig>;
1774
1654
  }
1655
+ declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
1775
1656
 
1776
1657
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
1777
1658
  type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
@@ -1917,6 +1798,15 @@ type ClientDataFunctionArgs<Params> = {
1917
1798
  * @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
1918
1799
  **/
1919
1800
  request: Request;
1801
+ /**
1802
+ * A URL instance representing the application location being navigated to or fetched.
1803
+ * Without `future.unstable_passThroughRequests` enabled, this matches `request.url`.
1804
+ * With `future.unstable_passThroughRequests` enabled, this is a normalized
1805
+ * URL with React-Router-specific implementation details removed (`.data`
1806
+ * pathnames, `index`/`_routes` search params).
1807
+ * The URL includes the origin from the request for convenience.
1808
+ */
1809
+ unstable_url: URL;
1920
1810
  /**
1921
1811
  * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
1922
1812
  * @example
@@ -2107,6 +1997,163 @@ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
2107
1997
  */
2108
1998
  type RouteHandle = unknown;
2109
1999
 
2000
+ interface AwaitResolveRenderFunction<Resolve = any> {
2001
+ (data: Awaited<Resolve>): React.ReactNode;
2002
+ }
2003
+ /**
2004
+ * @category Types
2005
+ */
2006
+ interface AwaitProps<Resolve> {
2007
+ /**
2008
+ * When using a function, the resolved value is provided as the parameter.
2009
+ *
2010
+ * ```tsx [2]
2011
+ * <Await resolve={reviewsPromise}>
2012
+ * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
2013
+ * </Await>
2014
+ * ```
2015
+ *
2016
+ * When using React elements, {@link useAsyncValue} will provide the
2017
+ * resolved value:
2018
+ *
2019
+ * ```tsx [2]
2020
+ * <Await resolve={reviewsPromise}>
2021
+ * <Reviews />
2022
+ * </Await>
2023
+ *
2024
+ * function Reviews() {
2025
+ * const resolvedReviews = useAsyncValue();
2026
+ * return <div>...</div>;
2027
+ * }
2028
+ * ```
2029
+ */
2030
+ children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
2031
+ /**
2032
+ * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
2033
+ * rejects.
2034
+ *
2035
+ * ```tsx
2036
+ * <Await
2037
+ * errorElement={<div>Oops</div>}
2038
+ * resolve={reviewsPromise}
2039
+ * >
2040
+ * <Reviews />
2041
+ * </Await>
2042
+ * ```
2043
+ *
2044
+ * To provide a more contextual error, you can use the {@link useAsyncError} in a
2045
+ * child component
2046
+ *
2047
+ * ```tsx
2048
+ * <Await
2049
+ * errorElement={<ReviewsError />}
2050
+ * resolve={reviewsPromise}
2051
+ * >
2052
+ * <Reviews />
2053
+ * </Await>
2054
+ *
2055
+ * function ReviewsError() {
2056
+ * const error = useAsyncError();
2057
+ * return <div>Error loading reviews: {error.message}</div>;
2058
+ * }
2059
+ * ```
2060
+ *
2061
+ * If you do not provide an `errorElement`, the rejected value will bubble up
2062
+ * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
2063
+ * and be accessible via the {@link useRouteError} hook.
2064
+ */
2065
+ errorElement?: React.ReactNode;
2066
+ /**
2067
+ * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
2068
+ * returned from a [`loader`](../../start/framework/route-module#loader) to be
2069
+ * resolved and rendered.
2070
+ *
2071
+ * ```tsx
2072
+ * import { Await, useLoaderData } from "react-router";
2073
+ *
2074
+ * export async function loader() {
2075
+ * let reviews = getReviews(); // not awaited
2076
+ * let book = await getBook();
2077
+ * return {
2078
+ * book,
2079
+ * reviews, // this is a promise
2080
+ * };
2081
+ * }
2082
+ *
2083
+ * export default function Book() {
2084
+ * const {
2085
+ * book,
2086
+ * reviews, // this is the same promise
2087
+ * } = useLoaderData();
2088
+ *
2089
+ * return (
2090
+ * <div>
2091
+ * <h1>{book.title}</h1>
2092
+ * <p>{book.description}</p>
2093
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
2094
+ * <Await
2095
+ * // and is the promise we pass to Await
2096
+ * resolve={reviews}
2097
+ * >
2098
+ * <Reviews />
2099
+ * </Await>
2100
+ * </React.Suspense>
2101
+ * </div>
2102
+ * );
2103
+ * }
2104
+ * ```
2105
+ */
2106
+ resolve: Resolve;
2107
+ }
2108
+ /**
2109
+ * Used to render promise values with automatic error handling.
2110
+ *
2111
+ * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
2112
+ *
2113
+ * @example
2114
+ * import { Await, useLoaderData } from "react-router";
2115
+ *
2116
+ * export async function loader() {
2117
+ * // not awaited
2118
+ * const reviews = getReviews();
2119
+ * // awaited (blocks the transition)
2120
+ * const book = await fetch("/api/book").then((res) => res.json());
2121
+ * return { book, reviews };
2122
+ * }
2123
+ *
2124
+ * function Book() {
2125
+ * const { book, reviews } = useLoaderData();
2126
+ * return (
2127
+ * <div>
2128
+ * <h1>{book.title}</h1>
2129
+ * <p>{book.description}</p>
2130
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
2131
+ * <Await
2132
+ * resolve={reviews}
2133
+ * errorElement={
2134
+ * <div>Could not load reviews 😬</div>
2135
+ * }
2136
+ * children={(resolvedReviews) => (
2137
+ * <Reviews items={resolvedReviews} />
2138
+ * )}
2139
+ * />
2140
+ * </React.Suspense>
2141
+ * </div>
2142
+ * );
2143
+ * }
2144
+ *
2145
+ * @public
2146
+ * @category Components
2147
+ * @mode framework
2148
+ * @mode data
2149
+ * @param props Props
2150
+ * @param {AwaitProps.children} props.children n/a
2151
+ * @param {AwaitProps.errorElement} props.errorElement n/a
2152
+ * @param {AwaitProps.resolve} props.resolve n/a
2153
+ * @returns React element for the rendered awaited value
2154
+ */
2155
+ declare function Await$1<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
2156
+
2110
2157
  declare function getRequest(): Request;
2111
2158
  declare const redirect: typeof redirect$1;
2112
2159
  declare const redirectDocument: typeof redirectDocument$1;