react-router 7.8.2 → 7.9.0-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 (60) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/development/{chunk-5UALIXAM.mjs → chunk-AVXIT45F.mjs} +94 -70
  3. package/dist/development/{chunk-PVWAREVJ.mjs → chunk-QZH3B547.mjs} +47 -50
  4. package/dist/development/{chunk-ZO66TDGB.js → chunk-RGB6BZUL.js} +41 -44
  5. package/dist/development/{chunk-CSDGKXLR.js → chunk-XYB2GISA.js} +135 -135
  6. package/dist/{production/context-jKip1TFB.d.mts → development/context-BH6Jwdoy.d.mts} +39 -32
  7. package/dist/development/dom-export.d.mts +3 -3
  8. package/dist/development/dom-export.d.ts +2 -2
  9. package/dist/development/dom-export.js +14 -14
  10. package/dist/development/dom-export.mjs +14 -14
  11. package/dist/development/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
  12. package/dist/{production/index-react-server-client-BKpa2trA.d.ts → development/index-react-server-client-CMC2eQAY.d.ts} +12 -12
  13. package/dist/development/index-react-server-client.d.mts +3 -3
  14. package/dist/development/index-react-server-client.d.ts +2 -2
  15. package/dist/development/index-react-server-client.js +4 -4
  16. package/dist/development/index-react-server-client.mjs +4 -4
  17. package/dist/development/index-react-server.d.mts +229 -37
  18. package/dist/development/index-react-server.d.ts +229 -37
  19. package/dist/development/index-react-server.js +89 -39
  20. package/dist/development/index-react-server.mjs +88 -36
  21. package/dist/development/index.d.mts +31 -24
  22. package/dist/development/index.d.ts +29 -22
  23. package/dist/development/index.js +184 -158
  24. package/dist/development/index.mjs +9 -7
  25. package/dist/development/lib/types/internal.d.mts +6 -6
  26. package/dist/development/lib/types/internal.d.ts +5 -5
  27. package/dist/development/lib/types/internal.js +1 -1
  28. package/dist/development/lib/types/internal.mjs +1 -1
  29. package/dist/development/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
  30. package/dist/development/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
  31. package/dist/production/{chunk-Z56HUDN5.js → chunk-A6EU7LHU.js} +41 -44
  32. package/dist/production/{chunk-REDRD2MB.mjs → chunk-BQLQLXP4.mjs} +47 -50
  33. package/dist/production/{chunk-JNT5PWCQ.js → chunk-IR3XRH6J.js} +135 -135
  34. package/dist/production/{chunk-KWHRV2I7.mjs → chunk-WMHWIEJV.mjs} +94 -70
  35. package/dist/{development/context-jKip1TFB.d.mts → production/context-BH6Jwdoy.d.mts} +39 -32
  36. package/dist/production/dom-export.d.mts +3 -3
  37. package/dist/production/dom-export.d.ts +2 -2
  38. package/dist/production/dom-export.js +14 -14
  39. package/dist/production/dom-export.mjs +14 -14
  40. package/dist/production/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
  41. package/dist/{development/index-react-server-client-BKpa2trA.d.ts → production/index-react-server-client-CMC2eQAY.d.ts} +12 -12
  42. package/dist/production/index-react-server-client.d.mts +3 -3
  43. package/dist/production/index-react-server-client.d.ts +2 -2
  44. package/dist/production/index-react-server-client.js +4 -4
  45. package/dist/production/index-react-server-client.mjs +4 -4
  46. package/dist/production/index-react-server.d.mts +229 -37
  47. package/dist/production/index-react-server.d.ts +229 -37
  48. package/dist/production/index-react-server.js +89 -39
  49. package/dist/production/index-react-server.mjs +88 -36
  50. package/dist/production/index.d.mts +31 -24
  51. package/dist/production/index.d.ts +29 -22
  52. package/dist/production/index.js +184 -158
  53. package/dist/production/index.mjs +9 -7
  54. package/dist/production/lib/types/internal.d.mts +6 -6
  55. package/dist/production/lib/types/internal.d.ts +5 -5
  56. package/dist/production/lib/types/internal.js +1 -1
  57. package/dist/production/lib/types/internal.mjs +1 -1
  58. package/dist/production/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
  59. package/dist/production/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
  60. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
- export { aW as Await, aX as MemoryRouter, aY as Navigate, aZ as Outlet, a_ as Route, a$ as Router, b0 as RouterProvider, b1 as Routes, br as UNSAFE_WithComponentProps, bv as UNSAFE_WithErrorBoundaryProps, bt as UNSAFE_WithHydrateFallbackProps } from './routeModules-rOzWJJ9x.js';
2
- export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-BKpa2trA.js';
1
+ export { aY as MemoryRouter, aZ as Navigate, a_ as Outlet, a$ as Route, b0 as Router, b1 as RouterProvider, b2 as Routes, aJ as UNSAFE_AwaitContextProvider, bs as UNSAFE_WithComponentProps, bw as UNSAFE_WithErrorBoundaryProps, bu as UNSAFE_WithHydrateFallbackProps } from './routeModules-DSKAn01V.js';
2
+ export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-CMC2eQAY.js';
3
3
  import 'react';
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
2
- * react-router v7.8.2
2
+ * react-router v7.9.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -29,12 +29,12 @@
29
29
 
30
30
 
31
31
 
32
+ var _chunkXYB2GISAjs = require('./chunk-XYB2GISA.js');
32
33
 
33
- var _chunkCSDGKXLRjs = require('./chunk-CSDGKXLR.js');
34
34
 
35
35
 
36
36
 
37
- var _chunkZO66TDGBjs = require('./chunk-ZO66TDGB.js');
37
+ var _chunkRGB6BZULjs = require('./chunk-RGB6BZUL.js');
38
38
 
39
39
 
40
40
 
@@ -58,4 +58,4 @@ var _chunkZO66TDGBjs = require('./chunk-ZO66TDGB.js');
58
58
 
59
59
 
60
60
 
61
- exports.Await = _chunkCSDGKXLRjs.Await; exports.BrowserRouter = _chunkCSDGKXLRjs.BrowserRouter; exports.Form = _chunkCSDGKXLRjs.Form; exports.HashRouter = _chunkCSDGKXLRjs.HashRouter; exports.Link = _chunkCSDGKXLRjs.Link; exports.Links = _chunkZO66TDGBjs.Links; exports.MemoryRouter = _chunkCSDGKXLRjs.MemoryRouter; exports.Meta = _chunkZO66TDGBjs.Meta; exports.NavLink = _chunkCSDGKXLRjs.NavLink; exports.Navigate = _chunkCSDGKXLRjs.Navigate; exports.Outlet = _chunkCSDGKXLRjs.Outlet; exports.Route = _chunkCSDGKXLRjs.Route; exports.Router = _chunkCSDGKXLRjs.Router; exports.RouterProvider = _chunkCSDGKXLRjs.RouterProvider; exports.Routes = _chunkCSDGKXLRjs.Routes; exports.ScrollRestoration = _chunkCSDGKXLRjs.ScrollRestoration; exports.StaticRouter = _chunkCSDGKXLRjs.StaticRouter; exports.StaticRouterProvider = _chunkCSDGKXLRjs.StaticRouterProvider; exports.UNSAFE_WithComponentProps = _chunkCSDGKXLRjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkCSDGKXLRjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkCSDGKXLRjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkCSDGKXLRjs.HistoryRouter;
61
+ exports.BrowserRouter = _chunkXYB2GISAjs.BrowserRouter; exports.Form = _chunkXYB2GISAjs.Form; exports.HashRouter = _chunkXYB2GISAjs.HashRouter; exports.Link = _chunkXYB2GISAjs.Link; exports.Links = _chunkRGB6BZULjs.Links; exports.MemoryRouter = _chunkXYB2GISAjs.MemoryRouter; exports.Meta = _chunkRGB6BZULjs.Meta; exports.NavLink = _chunkXYB2GISAjs.NavLink; exports.Navigate = _chunkXYB2GISAjs.Navigate; exports.Outlet = _chunkXYB2GISAjs.Outlet; exports.Route = _chunkXYB2GISAjs.Route; exports.Router = _chunkXYB2GISAjs.Router; exports.RouterProvider = _chunkXYB2GISAjs.RouterProvider; exports.Routes = _chunkXYB2GISAjs.Routes; exports.ScrollRestoration = _chunkXYB2GISAjs.ScrollRestoration; exports.StaticRouter = _chunkXYB2GISAjs.StaticRouter; exports.StaticRouterProvider = _chunkXYB2GISAjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkRGB6BZULjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkXYB2GISAjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkXYB2GISAjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkXYB2GISAjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkXYB2GISAjs.HistoryRouter;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.2
2
+ * react-router v7.9.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -10,7 +10,7 @@
10
10
  */
11
11
  "use client";
12
12
  import {
13
- Await,
13
+ AwaitContextProvider,
14
14
  BrowserRouter,
15
15
  Form,
16
16
  HashRouter,
@@ -32,9 +32,8 @@ import {
32
32
  WithComponentProps,
33
33
  WithErrorBoundaryProps,
34
34
  WithHydrateFallbackProps
35
- } from "./chunk-PVWAREVJ.mjs";
35
+ } from "./chunk-QZH3B547.mjs";
36
36
  export {
37
- Await,
38
37
  BrowserRouter,
39
38
  Form,
40
39
  HashRouter,
@@ -52,6 +51,7 @@ export {
52
51
  ScrollRestoration,
53
52
  StaticRouter,
54
53
  StaticRouterProvider,
54
+ AwaitContextProvider as UNSAFE_AwaitContextProvider,
55
55
  WithComponentProps as UNSAFE_WithComponentProps,
56
56
  WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps,
57
57
  WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps,
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export { Await, BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from 'react-router/internal/react-server-client';
2
+ export { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from 'react-router/internal/react-server-client';
3
3
  import { ParseOptions, SerializeOptions } from 'cookie';
4
4
  export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
5
5
 
@@ -169,7 +169,7 @@ interface History {
169
169
  interface Future {
170
170
  }
171
171
  type MiddlewareEnabled = Future extends {
172
- unstable_middleware: infer T extends boolean;
172
+ middleware: infer T extends boolean;
173
173
  } ? T : false;
174
174
 
175
175
  type MaybePromise<T> = T | Promise<T>;
@@ -229,14 +229,14 @@ type Submission = {
229
229
  };
230
230
  /**
231
231
  * A context instance used as the key for the `get`/`set` methods of a
232
- * {@link unstable_RouterContextProvider}. Accepts an optional default
232
+ * {@link RouterContextProvider}. Accepts an optional default
233
233
  * value to be returned if no value has been set.
234
234
  */
235
- interface unstable_RouterContext<T = unknown> {
235
+ interface RouterContext<T = unknown> {
236
236
  defaultValue?: T;
237
237
  }
238
238
  /**
239
- * Creates a type-safe {@link unstable_RouterContext} object that can be used to
239
+ * Creates a type-safe {@link RouterContext} object that can be used to
240
240
  * store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
241
241
  * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
242
242
  * Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
@@ -247,11 +247,11 @@ interface unstable_RouterContext<T = unknown> {
247
247
  * when no value has been set will throw an error.
248
248
  *
249
249
  * ```tsx filename=app/context.ts
250
- * import { unstable_createContext } from "react-router";
250
+ * import { createContext } from "react-router";
251
251
  *
252
252
  * // Create a context for user data
253
253
  * export const userContext =
254
- * unstable_createContext<User | null>(null);
254
+ * createContext<User | null>(null);
255
255
  * ```
256
256
  *
257
257
  * ```tsx filename=app/middleware/auth.ts
@@ -289,23 +289,23 @@ interface unstable_RouterContext<T = unknown> {
289
289
  * @mode data
290
290
  * @param defaultValue An optional default value for the context. This value
291
291
  * will be returned if no value has been set for this context.
292
- * @returns A {@link unstable_RouterContext} object that can be used with
292
+ * @returns A {@link RouterContext} object that can be used with
293
293
  * `context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
294
294
  * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
295
295
  */
296
- declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterContext<T>;
296
+ declare function createContext<T>(defaultValue?: T): RouterContext<T>;
297
297
  /**
298
298
  * Provides methods for writing/reading values in application context in a
299
299
  * type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
300
300
  *
301
301
  * @example
302
302
  * import {
303
- * unstable_createContext,
304
- * unstable_RouterContextProvider
303
+ * createContext,
304
+ * RouterContextProvider
305
305
  * } from "react-router";
306
306
  *
307
- * const userContext = unstable_createContext<User | null>(null);
308
- * const contextProvider = new unstable_RouterContextProvider();
307
+ * const userContext = createContext<User | null>(null);
308
+ * const contextProvider = new RouterContextProvider();
309
309
  * contextProvider.set(userContext, getUser());
310
310
  * // ^ Type-safe
311
311
  * const user = contextProvider.get(userContext);
@@ -316,13 +316,13 @@ declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterCon
316
316
  * @mode framework
317
317
  * @mode data
318
318
  */
319
- declare class unstable_RouterContextProvider {
319
+ declare class RouterContextProvider {
320
320
  #private;
321
321
  /**
322
- * Create a new `unstable_RouterContextProvider` instance
322
+ * Create a new `RouterContextProvider` instance
323
323
  * @param init An optional initial context map to populate the provider with
324
324
  */
325
- constructor(init?: Map<unstable_RouterContext, unknown>);
325
+ constructor(init?: Map<RouterContext, unknown>);
326
326
  /**
327
327
  * Access a value from the context. If no value has been set for the context,
328
328
  * it will return the context's `defaultValue` if provided, or throw an error
@@ -331,7 +331,7 @@ declare class unstable_RouterContextProvider {
331
331
  * @returns The value for the context, or the context's `defaultValue` if no
332
332
  * value was set
333
333
  */
334
- get<T>(context: unstable_RouterContext<T>): T;
334
+ get<T>(context: RouterContext<T>): T;
335
335
  /**
336
336
  * Set a value for the context. If the context already has a value set, this
337
337
  * will overwrite it.
@@ -340,9 +340,9 @@ declare class unstable_RouterContextProvider {
340
340
  * @param value The value to set for the context
341
341
  * @returns {void}
342
342
  */
343
- set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
343
+ set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
344
344
  }
345
- type DefaultContext = MiddlewareEnabled extends true ? Readonly<unstable_RouterContextProvider> : any;
345
+ type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : any;
346
346
  /**
347
347
  * @private
348
348
  * Arguments passed to route loader/action functions. Same for now but we keep
@@ -377,7 +377,7 @@ interface DataFunctionArgs<Context> {
377
377
  * Route middleware `next` function to call downstream handlers and then complete
378
378
  * middlewares from the bottom-up
379
379
  */
380
- interface unstable_MiddlewareNextFunction<Result = unknown> {
380
+ interface MiddlewareNextFunction<Result = unknown> {
381
381
  (): Promise<Result>;
382
382
  }
383
383
  /**
@@ -386,7 +386,7 @@ interface unstable_MiddlewareNextFunction<Result = unknown> {
386
386
  * a `next` function as the second parameter which will call downstream handlers
387
387
  * and then complete middlewares from the bottom-up
388
388
  */
389
- type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<unstable_RouterContextProvider>>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
389
+ type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<RouterContextProvider>>, next: MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
390
390
  /**
391
391
  * Arguments passed to loader functions
392
392
  */
@@ -541,7 +541,7 @@ interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctio
541
541
  * Matches for this route extended with Data strategy APIs
542
542
  */
543
543
  matches: DataStrategyMatch[];
544
- unstable_runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
544
+ runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
545
545
  /**
546
546
  * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
547
547
  * for navigational executions
@@ -586,7 +586,7 @@ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" |
586
586
  * onto the route. Either they're meaningful to the router, or they'll get
587
587
  * ignored.
588
588
  */
589
- type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "unstable_middleware";
589
+ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middleware";
590
590
  /**
591
591
  * lazy object to load route properties, which can add non-matching
592
592
  * related properties to a route
@@ -609,7 +609,7 @@ type AgnosticBaseRouteObject = {
609
609
  caseSensitive?: boolean;
610
610
  path?: string;
611
611
  id?: string;
612
- unstable_middleware?: unstable_MiddlewareFunction[];
612
+ middleware?: MiddlewareFunction[];
613
613
  loader?: LoaderFunction | boolean;
614
614
  action?: ActionFunction | boolean;
615
615
  hasErrorBoundary?: boolean;
@@ -1160,7 +1160,7 @@ interface RouterInit {
1160
1160
  routes: AgnosticRouteObject[];
1161
1161
  history: History;
1162
1162
  basename?: string;
1163
- unstable_getContext?: () => MaybePromise<unstable_RouterContextProvider>;
1163
+ getContext?: () => MaybePromise<RouterContextProvider>;
1164
1164
  mapRouteProperties?: MapRoutePropertiesFunction;
1165
1165
  future?: Partial<FutureConfig>;
1166
1166
  hydrationRouteProperties?: string[];
@@ -1195,7 +1195,7 @@ interface StaticHandler {
1195
1195
  skipLoaderErrorBubbling?: boolean;
1196
1196
  skipRevalidation?: boolean;
1197
1197
  dataStrategy?: DataStrategyFunction<unknown>;
1198
- unstable_generateMiddlewareResponse?: (query: (r: Request, args?: {
1198
+ generateMiddlewareResponse?: (query: (r: Request, args?: {
1199
1199
  filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
1200
1200
  }) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
1201
1201
  }): Promise<StaticHandlerContext | Response>;
@@ -1203,7 +1203,7 @@ interface StaticHandler {
1203
1203
  routeId?: string;
1204
1204
  requestContext?: unknown;
1205
1205
  dataStrategy?: DataStrategyFunction<unknown>;
1206
- unstable_generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1206
+ generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1207
1207
  }): Promise<any>;
1208
1208
  }
1209
1209
  type ViewTransitionOpts = {
@@ -1431,11 +1431,168 @@ interface CreateStaticHandlerOptions {
1431
1431
  }
1432
1432
  declare function createStaticHandler(routes: AgnosticRouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
1433
1433
 
1434
+ interface AwaitResolveRenderFunction<Resolve = any> {
1435
+ (data: Awaited<Resolve>): React.ReactNode;
1436
+ }
1437
+ /**
1438
+ * @category Types
1439
+ */
1440
+ interface AwaitProps<Resolve> {
1441
+ /**
1442
+ * When using a function, the resolved value is provided as the parameter.
1443
+ *
1444
+ * ```tsx [2]
1445
+ * <Await resolve={reviewsPromise}>
1446
+ * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
1447
+ * </Await>
1448
+ * ```
1449
+ *
1450
+ * When using React elements, {@link useAsyncValue} will provide the
1451
+ * resolved value:
1452
+ *
1453
+ * ```tsx [2]
1454
+ * <Await resolve={reviewsPromise}>
1455
+ * <Reviews />
1456
+ * </Await>
1457
+ *
1458
+ * function Reviews() {
1459
+ * const resolvedReviews = useAsyncValue();
1460
+ * return <div>...</div>;
1461
+ * }
1462
+ * ```
1463
+ */
1464
+ children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
1465
+ /**
1466
+ * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1467
+ * rejects.
1468
+ *
1469
+ * ```tsx
1470
+ * <Await
1471
+ * errorElement={<div>Oops</div>}
1472
+ * resolve={reviewsPromise}
1473
+ * >
1474
+ * <Reviews />
1475
+ * </Await>
1476
+ * ```
1477
+ *
1478
+ * To provide a more contextual error, you can use the {@link useAsyncError} in a
1479
+ * child component
1480
+ *
1481
+ * ```tsx
1482
+ * <Await
1483
+ * errorElement={<ReviewsError />}
1484
+ * resolve={reviewsPromise}
1485
+ * >
1486
+ * <Reviews />
1487
+ * </Await>
1488
+ *
1489
+ * function ReviewsError() {
1490
+ * const error = useAsyncError();
1491
+ * return <div>Error loading reviews: {error.message}</div>;
1492
+ * }
1493
+ * ```
1494
+ *
1495
+ * If you do not provide an `errorElement`, the rejected value will bubble up
1496
+ * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
1497
+ * and be accessible via the {@link useRouteError} hook.
1498
+ */
1499
+ errorElement?: React.ReactNode;
1500
+ /**
1501
+ * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1502
+ * returned from a [`loader`](../../start/framework/route-module#loader) to be
1503
+ * resolved and rendered.
1504
+ *
1505
+ * ```tsx
1506
+ * import { Await, useLoaderData } from "react-router";
1507
+ *
1508
+ * export async function loader() {
1509
+ * let reviews = getReviews(); // not awaited
1510
+ * let book = await getBook();
1511
+ * return {
1512
+ * book,
1513
+ * reviews, // this is a promise
1514
+ * };
1515
+ * }
1516
+ *
1517
+ * export default function Book() {
1518
+ * const {
1519
+ * book,
1520
+ * reviews, // this is the same promise
1521
+ * } = useLoaderData();
1522
+ *
1523
+ * return (
1524
+ * <div>
1525
+ * <h1>{book.title}</h1>
1526
+ * <p>{book.description}</p>
1527
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
1528
+ * <Await
1529
+ * // and is the promise we pass to Await
1530
+ * resolve={reviews}
1531
+ * >
1532
+ * <Reviews />
1533
+ * </Await>
1534
+ * </React.Suspense>
1535
+ * </div>
1536
+ * );
1537
+ * }
1538
+ * ```
1539
+ */
1540
+ resolve: Resolve;
1541
+ }
1542
+ /**
1543
+ * Used to render promise values with automatic error handling.
1544
+ *
1545
+ * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
1546
+ *
1547
+ * @example
1548
+ * import { Await, useLoaderData } from "react-router";
1549
+ *
1550
+ * export async function loader() {
1551
+ * // not awaited
1552
+ * const reviews = getReviews();
1553
+ * // awaited (blocks the transition)
1554
+ * const book = await fetch("/api/book").then((res) => res.json());
1555
+ * return { book, reviews };
1556
+ * }
1557
+ *
1558
+ * function Book() {
1559
+ * const { book, reviews } = useLoaderData();
1560
+ * return (
1561
+ * <div>
1562
+ * <h1>{book.title}</h1>
1563
+ * <p>{book.description}</p>
1564
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
1565
+ * <Await
1566
+ * resolve={reviews}
1567
+ * errorElement={
1568
+ * <div>Could not load reviews 😬</div>
1569
+ * }
1570
+ * children={(resolvedReviews) => (
1571
+ * <Reviews items={resolvedReviews} />
1572
+ * )}
1573
+ * />
1574
+ * </React.Suspense>
1575
+ * </div>
1576
+ * );
1577
+ * }
1578
+ *
1579
+ * @public
1580
+ * @category Components
1581
+ * @mode framework
1582
+ * @mode data
1583
+ * @param props Props
1584
+ * @param {AwaitProps.children} props.children n/a
1585
+ * @param {AwaitProps.errorElement} props.errorElement n/a
1586
+ * @param {AwaitProps.resolve} props.resolve n/a
1587
+ * @returns React element for the rendered awaited value
1588
+ */
1589
+ declare function Await$1<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
1590
+
1434
1591
  interface IndexRouteObject {
1435
1592
  caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
1436
1593
  path?: AgnosticIndexRouteObject["path"];
1437
1594
  id?: AgnosticIndexRouteObject["id"];
1438
- unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
1595
+ middleware?: AgnosticIndexRouteObject["middleware"];
1439
1596
  loader?: AgnosticIndexRouteObject["loader"];
1440
1597
  action?: AgnosticIndexRouteObject["action"];
1441
1598
  hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
@@ -1455,7 +1612,7 @@ interface NonIndexRouteObject {
1455
1612
  caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
1456
1613
  path?: AgnosticNonIndexRouteObject["path"];
1457
1614
  id?: AgnosticNonIndexRouteObject["id"];
1458
- unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
1615
+ middleware?: AgnosticNonIndexRouteObject["middleware"];
1459
1616
  loader?: AgnosticNonIndexRouteObject["loader"];
1460
1617
  action?: AgnosticNonIndexRouteObject["action"];
1461
1618
  hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
@@ -1641,14 +1798,14 @@ type ClientDataFunctionArgs<Params> = {
1641
1798
  **/
1642
1799
  params: Params;
1643
1800
  /**
1644
- * When `future.unstable_middleware` is not enabled, this is undefined.
1801
+ * When `future.v8_middleware` is not enabled, this is undefined.
1645
1802
  *
1646
- * When `future.unstable_middleware` is enabled, this is an instance of
1647
- * `unstable_RouterContextProvider` and can be used to access context values
1803
+ * When `future.v8_middleware` is enabled, this is an instance of
1804
+ * `RouterContextProvider` and can be used to access context values
1648
1805
  * from your route middlewares. You may pass in initial context values in your
1649
- * `<HydratedRouter unstable_getContext>` prop
1806
+ * `<HydratedRouter getContext>` prop
1650
1807
  */
1651
- context: Readonly<unstable_RouterContextProvider>;
1808
+ context: Readonly<RouterContextProvider>;
1652
1809
  };
1653
1810
  type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
1654
1811
  ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
@@ -1813,6 +1970,7 @@ type RouteHandle = unknown;
1813
1970
  declare const redirect: typeof redirect$1;
1814
1971
  declare const redirectDocument: typeof redirectDocument$1;
1815
1972
  declare const replace: typeof replace$1;
1973
+ declare const Await: typeof Await$1;
1816
1974
  type RSCRouteConfigEntryBase = {
1817
1975
  action?: ActionFunction;
1818
1976
  clientAction?: ClientActionFunction;
@@ -1971,7 +2129,7 @@ type LoadServerActionFunction = (id: string) => Promise<Function>;
1971
2129
  * errors that occur during the request processing.
1972
2130
  * @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
1973
2131
  * to match against.
1974
- * @param opts.requestContext An instance of {@link unstable_RouterContextProvider}
2132
+ * @param opts.requestContext An instance of {@link RouterContextProvider}
1975
2133
  * that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
1976
2134
  * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
1977
2135
  * @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
@@ -1985,7 +2143,7 @@ declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename,
1985
2143
  decodeReply?: DecodeReplyFunction;
1986
2144
  decodeAction?: DecodeActionFunction;
1987
2145
  decodeFormState?: DecodeFormStateFunction;
1988
- requestContext?: unstable_RouterContextProvider;
2146
+ requestContext?: RouterContextProvider;
1989
2147
  loadServerAction?: LoadServerActionFunction;
1990
2148
  onError?: (error: unknown) => void;
1991
2149
  request: Request;
@@ -1995,6 +2153,40 @@ declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename,
1995
2153
  }) => Response;
1996
2154
  }): Promise<Response>;
1997
2155
 
2156
+ /**
2157
+ * Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
2158
+ * React Router should handle this for you via type generation.
2159
+ *
2160
+ * For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
2161
+ */
2162
+ interface Register {
2163
+ }
2164
+ type AnyParams = Record<string, string | undefined>;
2165
+ type AnyPages = Record<string, {
2166
+ params: AnyParams;
2167
+ }>;
2168
+ type Pages = Register extends {
2169
+ pages: infer Registered extends AnyPages;
2170
+ } ? Registered : AnyPages;
2171
+
2172
+ type Args = {
2173
+ [K in keyof Pages]: ToArgs<Pages[K]["params"]>;
2174
+ };
2175
+ type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [
2176
+ Params
2177
+ ];
2178
+ /**
2179
+ Returns a resolved URL path for the specified route.
2180
+
2181
+ ```tsx
2182
+ const h = href("/:lang?/about", { lang: "en" })
2183
+ // -> `/en/about`
2184
+
2185
+ <Link to={href("/products/:id", { id: "abc123" })} />
2186
+ ```
2187
+ */
2188
+ declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
2189
+
1998
2190
  interface CookieSignatureOptions {
1999
2191
  /**
2000
2192
  * An array of secrets that may be used to sign/unsign the value of a cookie.
@@ -2225,4 +2417,4 @@ interface MemorySessionStorageOptions {
2225
2417
  */
2226
2418
  declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
2227
2419
 
2228
- export { type Cookie, type CookieOptions, type CookieSignatureOptions, type FlashSessionData, type IsCookieFunction, type IsSessionFunction, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect, redirectDocument, replace, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type LoadServerActionFunction as unstable_LoadServerActionFunction, type unstable_MiddlewareFunction, type unstable_MiddlewareNextFunction, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, type unstable_RouterContext, unstable_RouterContextProvider, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
2420
+ export { Await, type Cookie, type CookieOptions, type CookieSignatureOptions, type FlashSessionData, type IsCookieFunction, type IsSessionFunction, type MiddlewareFunction, type MiddlewareNextFunction, type RouterContext, RouterContextProvider, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, createContext, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, href, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect, redirectDocument, replace, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, matchRSCServerRequest as unstable_matchRSCServerRequest };