react-router 7.7.0 → 7.7.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 (68) hide show
  1. package/CHANGELOG.md +11 -23
  2. package/dist/development/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  3. package/dist/development/{chunk-EF7DTUVF.mjs → chunk-C37GKA54.mjs} +83 -80
  4. package/dist/development/{chunk-V6PEDDZI.js → chunk-K7YFBME3.js} +79 -76
  5. package/dist/{production/chunk-GNZILI6H.mjs → development/chunk-KIUJAIYX.mjs} +3 -5
  6. package/dist/{production/chunk-2TYFPE3B.js → development/chunk-R73PQUJU.js} +132 -132
  7. package/dist/development/components-CjQijYga.d.mts +802 -0
  8. package/dist/development/dom-export.d.mts +13 -6
  9. package/dist/development/dom-export.d.ts +10 -3
  10. package/dist/development/dom-export.js +3 -3
  11. package/dist/development/dom-export.mjs +3 -3
  12. package/dist/development/index-react-server-client-Bi_fx8qz.d.ts +3163 -0
  13. package/dist/development/index-react-server-client-KLg-U4nr.d.mts +2366 -0
  14. package/dist/development/index-react-server-client.d.mts +3 -3
  15. package/dist/development/index-react-server-client.d.ts +2 -2
  16. package/dist/development/index-react-server-client.js +4 -4
  17. package/dist/development/index-react-server-client.mjs +2 -2
  18. package/dist/development/index-react-server.d.mts +109 -2
  19. package/dist/development/index-react-server.d.ts +109 -2
  20. package/dist/development/index-react-server.js +28 -20
  21. package/dist/development/index-react-server.mjs +29 -21
  22. package/dist/development/index.d.mts +918 -287
  23. package/dist/development/index.d.ts +1010 -283
  24. package/dist/development/index.js +98 -100
  25. package/dist/development/index.mjs +3 -3
  26. package/dist/development/lib/types/internal.d.mts +1 -1
  27. package/dist/development/lib/types/internal.d.ts +1 -1
  28. package/dist/development/lib/types/internal.js +1 -1
  29. package/dist/development/lib/types/internal.mjs +1 -1
  30. package/dist/{production/route-data-DjzmHYNR.d.mts → development/route-data-CqEmXQub.d.mts} +48 -2
  31. package/dist/{production/routeModules-g5PTiDfO.d.ts → development/routeModules-BR2FO0ix.d.ts} +48 -2
  32. package/dist/production/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  33. package/dist/{development/chunk-4ADB4KIO.js → production/chunk-4DGLNKXF.js} +132 -132
  34. package/dist/production/{chunk-5KHO4FML.js → chunk-7OQROU2D.js} +79 -76
  35. package/dist/production/{chunk-WPPIQDYG.mjs → chunk-IZ57JD2V.mjs} +83 -80
  36. package/dist/{development/chunk-T3VM44WY.mjs → production/chunk-K3SBCRK4.mjs} +3 -5
  37. package/dist/production/components-CjQijYga.d.mts +802 -0
  38. package/dist/production/dom-export.d.mts +13 -6
  39. package/dist/production/dom-export.d.ts +10 -3
  40. package/dist/production/dom-export.js +3 -3
  41. package/dist/production/dom-export.mjs +3 -3
  42. package/dist/production/index-react-server-client-Bi_fx8qz.d.ts +3163 -0
  43. package/dist/production/index-react-server-client-KLg-U4nr.d.mts +2366 -0
  44. package/dist/production/index-react-server-client.d.mts +3 -3
  45. package/dist/production/index-react-server-client.d.ts +2 -2
  46. package/dist/production/index-react-server-client.js +4 -4
  47. package/dist/production/index-react-server-client.mjs +2 -2
  48. package/dist/production/index-react-server.d.mts +109 -2
  49. package/dist/production/index-react-server.d.ts +109 -2
  50. package/dist/production/index-react-server.js +28 -20
  51. package/dist/production/index-react-server.mjs +29 -21
  52. package/dist/production/index.d.mts +918 -287
  53. package/dist/production/index.d.ts +1010 -283
  54. package/dist/production/index.js +98 -100
  55. package/dist/production/index.mjs +3 -3
  56. package/dist/production/lib/types/internal.d.mts +1 -1
  57. package/dist/production/lib/types/internal.d.ts +1 -1
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/{development/route-data-DjzmHYNR.d.mts → production/route-data-CqEmXQub.d.mts} +48 -2
  61. package/dist/{development/routeModules-g5PTiDfO.d.ts → production/routeModules-BR2FO0ix.d.ts} +48 -2
  62. package/package.json +1 -1
  63. package/dist/development/components-DzqPLVI1.d.mts +0 -464
  64. package/dist/development/index-react-server-client-CUidsuu_.d.mts +0 -1360
  65. package/dist/development/index-react-server-client-kY8DvDF3.d.ts +0 -1819
  66. package/dist/production/components-DzqPLVI1.d.mts +0 -464
  67. package/dist/production/index-react-server-client-CUidsuu_.d.mts +0 -1360
  68. package/dist/production/index-react-server-client-kY8DvDF3.d.ts +0 -1819
@@ -0,0 +1,802 @@
1
+ import { R as Router$1, I as InitialEntry, T as To, a as RelativeRoutingType, N as NonIndexRouteObject, L as LazyRouteFunction, b as IndexRouteObject, c as Location, A as Action, d as Navigator, e as RouterInit, F as FutureConfig, H as HydrationState, D as DataStrategyFunction, P as PatchRoutesOnNavigationFunction, f as RouteObject, g as RouteMatch, h as Params, U as UIMatch } from './route-data-CqEmXQub.mjs';
2
+ import * as React from 'react';
3
+
4
+ declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
5
+ hasErrorBoundary: boolean;
6
+ };
7
+ declare const hydrationRouteProperties: (keyof RouteObject)[];
8
+ /**
9
+ * @category Data Routers
10
+ */
11
+ interface MemoryRouterOpts {
12
+ /**
13
+ * Basename path for the application.
14
+ */
15
+ basename?: string;
16
+ /**
17
+ * Function to provide the initial context values for all client side
18
+ * navigations/fetches
19
+ */
20
+ unstable_getContext?: RouterInit["unstable_getContext"];
21
+ /**
22
+ * Future flags to enable for the router.
23
+ */
24
+ future?: Partial<FutureConfig>;
25
+ /**
26
+ * Hydration data to initialize the router with if you have already performed
27
+ * data loading on the server.
28
+ */
29
+ hydrationData?: HydrationState;
30
+ /**
31
+ * Initial entries in the in-memory history stack
32
+ */
33
+ initialEntries?: InitialEntry[];
34
+ /**
35
+ * Index of {@link initialEntries} the application should initialize to
36
+ */
37
+ initialIndex?: number;
38
+ /**
39
+ * Override the default data strategy of loading in parallel.
40
+ * Only intended for advanced usage.
41
+ */
42
+ dataStrategy?: DataStrategyFunction;
43
+ /**
44
+ * Lazily define portions of the route tree on navigations.
45
+ */
46
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
47
+ }
48
+ /**
49
+ * Create a new {@link DataRouter} that manages the application path using an
50
+ * in-memory [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
51
+ * stack. Useful for non-browser environments without a DOM API.
52
+ *
53
+ * @public
54
+ * @category Data Routers
55
+ * @mode data
56
+ * @param routes Application routes
57
+ * @param opts Options
58
+ * @param {MemoryRouterOpts.basename} opts.basename n/a
59
+ * @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
60
+ * @param {MemoryRouterOpts.future} opts.future n/a
61
+ * @param {MemoryRouterOpts.unstable_getContext} opts.unstable_getContext n/a
62
+ * @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
63
+ * @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
64
+ * @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
65
+ * @param {MemoryRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
66
+ * @returns An initialized {@link DataRouter} to pass to {@link RouterProvider | `<RouterProvider>`}
67
+ */
68
+ declare function createMemoryRouter(routes: RouteObject[], opts?: MemoryRouterOpts): Router$1;
69
+ /**
70
+ * @category Types
71
+ */
72
+ interface RouterProviderProps {
73
+ /**
74
+ * The {@link DataRouter} instance to use for navigation and data fetching.
75
+ */
76
+ router: Router$1;
77
+ /**
78
+ * The [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
79
+ * implementation to use for flushing updates.
80
+ *
81
+ * You usually don't have to worry about this:
82
+ * - The `RouterProvider` exported from `react-router/dom` handles this internally for you
83
+ * - If you are rendering in a non-DOM environment, you can import
84
+ * `RouterProvider` from `react-router` and ignore this prop
85
+ */
86
+ flushSync?: (fn: () => unknown) => undefined;
87
+ }
88
+ /**
89
+ * Render the UI for the given {@link DataRouter}. This component should
90
+ * typically be at the top of an app's element tree.
91
+ *
92
+ * @example
93
+ * import { createBrowserRouter } from "react-router";
94
+ * import { RouterProvider } from "react-router/dom";
95
+ * import { createRoot } from "react-dom/client";
96
+ *
97
+ * const router = createBrowserRouter(routes);
98
+ * createRoot(document.getElementById("root")).render(
99
+ * <RouterProvider router={router} />
100
+ * );
101
+ *
102
+ * @public
103
+ * @category Data Routers
104
+ * @mode data
105
+ * @param props Props
106
+ * @param {RouterProviderProps.flushSync} props.flushSync n/a
107
+ * @param {RouterProviderProps.router} props.router n/a
108
+ * @returns React element for the rendered router
109
+ */
110
+ declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
111
+ /**
112
+ * @category Types
113
+ */
114
+ interface MemoryRouterProps {
115
+ /**
116
+ * Application basename
117
+ */
118
+ basename?: string;
119
+ /**
120
+ * Nested {@link Route} elements describing the route tree
121
+ */
122
+ children?: React.ReactNode;
123
+ /**
124
+ * Initial entries in the in-memory history stack
125
+ */
126
+ initialEntries?: InitialEntry[];
127
+ /**
128
+ * Index of {@link initialEntries} the application should initialize to
129
+ */
130
+ initialIndex?: number;
131
+ }
132
+ /**
133
+ * A declarative {@link Router | `<Router>`} that stores all entries in memory.
134
+ *
135
+ * @public
136
+ * @category Declarative Routers
137
+ * @mode declarative
138
+ * @param props Props
139
+ * @param {MemoryRouterProps.basename} props.basename n/a
140
+ * @param {MemoryRouterProps.children} props.children n/a
141
+ * @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
142
+ * @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
143
+ * @returns A declarative in memory router for client side routing.
144
+ */
145
+ declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
146
+ /**
147
+ * @category Types
148
+ */
149
+ interface NavigateProps {
150
+ /**
151
+ * The path to navigate to. This can be a string or a {@link Path} object
152
+ */
153
+ to: To;
154
+ /**
155
+ * Whether to replace the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
156
+ * stack
157
+ */
158
+ replace?: boolean;
159
+ /**
160
+ * State to pass to the new {@link Location} to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
161
+ */
162
+ state?: any;
163
+ /**
164
+ * How to interpret relative routing in the {@link to} prop.
165
+ * See {@link RelativeRoutingType}.
166
+ */
167
+ relative?: RelativeRoutingType;
168
+ }
169
+ /**
170
+ * A component-based version of {@link useNavigate} to use in a
171
+ * [`React.Component` class](https://react.dev/reference/react/Component) where
172
+ * hooks cannot be used.
173
+ *
174
+ * It's recommended to avoid using this component in favor of {@link useNavigate}.
175
+ *
176
+ * @example
177
+ * <Navigate to="/tasks" />
178
+ *
179
+ * @public
180
+ * @category Components
181
+ * @param props Props
182
+ * @param {NavigateProps.relative} props.relative n/a
183
+ * @param {NavigateProps.replace} props.replace n/a
184
+ * @param {NavigateProps.state} props.state n/a
185
+ * @param {NavigateProps.to} props.to n/a
186
+ * @returns {void}
187
+ *
188
+ */
189
+ declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
190
+ /**
191
+ * @category Types
192
+ */
193
+ interface OutletProps {
194
+ /**
195
+ * Provides a context value to the element tree below the outlet. Use when
196
+ * the parent route needs to provide values to child routes.
197
+ *
198
+ * ```tsx
199
+ * <Outlet context={myContextValue} />
200
+ * ```
201
+ *
202
+ * Access the context with {@link useOutletContext}.
203
+ */
204
+ context?: unknown;
205
+ }
206
+ /**
207
+ * Renders the matching child route of a parent route or nothing if no child
208
+ * route matches.
209
+ *
210
+ * @example
211
+ * import { Outlet } from "react-router";
212
+ *
213
+ * export default function SomeParent() {
214
+ * return (
215
+ * <div>
216
+ * <h1>Parent Content</h1>
217
+ * <Outlet />
218
+ * </div>
219
+ * );
220
+ * }
221
+ *
222
+ * @public
223
+ * @category Components
224
+ * @param props Props
225
+ * @param {OutletProps.context} props.context n/a
226
+ * @returns React element for the rendered outlet or `null` if no child route matches.
227
+ */
228
+ declare function Outlet(props: OutletProps): React.ReactElement | null;
229
+ /**
230
+ * @category Types
231
+ */
232
+ interface PathRouteProps {
233
+ /**
234
+ * Whether the path should be case-sensitive. Defaults to `false`.
235
+ */
236
+ caseSensitive?: NonIndexRouteObject["caseSensitive"];
237
+ /**
238
+ * The path pattern to match. If unspecified or empty, then this becomes a
239
+ * layout route.
240
+ */
241
+ path?: NonIndexRouteObject["path"];
242
+ /**
243
+ * The unique identifier for this route (for use with {@link DataRouter}s)
244
+ */
245
+ id?: NonIndexRouteObject["id"];
246
+ /**
247
+ * A function that returns a promise that resolves to the route object.
248
+ * Used for code-splitting routes.
249
+ * See [`lazy`](../../start/data/route-object#lazy).
250
+ */
251
+ lazy?: LazyRouteFunction<NonIndexRouteObject>;
252
+ /**
253
+ * The route loader.
254
+ * See [`loader`](../../start/data/route-object#loader).
255
+ */
256
+ loader?: NonIndexRouteObject["loader"];
257
+ /**
258
+ * The route action.
259
+ * See [`action`](../../start/data/route-object#action).
260
+ */
261
+ action?: NonIndexRouteObject["action"];
262
+ hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
263
+ /**
264
+ * The route shouldRevalidate function.
265
+ * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
266
+ */
267
+ shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
268
+ /**
269
+ * The route handle.
270
+ */
271
+ handle?: NonIndexRouteObject["handle"];
272
+ /**
273
+ * Whether this is an index route.
274
+ */
275
+ index?: false;
276
+ /**
277
+ * Child Route components
278
+ */
279
+ children?: React.ReactNode;
280
+ /**
281
+ * The React element to render when this Route matches.
282
+ * Mutually exclusive with {@link Component}.
283
+ */
284
+ element?: React.ReactNode | null;
285
+ /**
286
+ * The React element to render while this router is loading data.
287
+ * Mutually exclusive with {@link HydrateFallback}.
288
+ */
289
+ hydrateFallbackElement?: React.ReactNode | null;
290
+ /**
291
+ * The React element to render at this route if an error occurs.
292
+ * Mutually exclusive with {@link ErrorBoundary}.
293
+ */
294
+ errorElement?: React.ReactNode | null;
295
+ /**
296
+ * The React Component to render when this route matches.
297
+ * Mutually exclusive with {@link element}.
298
+ */
299
+ Component?: React.ComponentType | null;
300
+ /**
301
+ * The React Component to render while this router is loading data.
302
+ * Mutually exclusive with {@link hydrateFallbackElement}.
303
+ */
304
+ HydrateFallback?: React.ComponentType | null;
305
+ /**
306
+ * The React Component to render at this route if an error occurs.
307
+ * Mutually exclusive with {@link errorElement}.
308
+ */
309
+ ErrorBoundary?: React.ComponentType | null;
310
+ }
311
+ /**
312
+ * @category Types
313
+ */
314
+ interface LayoutRouteProps extends PathRouteProps {
315
+ }
316
+ /**
317
+ * @category Types
318
+ */
319
+ interface IndexRouteProps {
320
+ /**
321
+ * Whether the path should be case-sensitive. Defaults to `false`.
322
+ */
323
+ caseSensitive?: IndexRouteObject["caseSensitive"];
324
+ /**
325
+ * The path pattern to match. If unspecified or empty, then this becomes a
326
+ * layout route.
327
+ */
328
+ path?: IndexRouteObject["path"];
329
+ /**
330
+ * The unique identifier for this route (for use with {@link DataRouter}s)
331
+ */
332
+ id?: IndexRouteObject["id"];
333
+ /**
334
+ * A function that returns a promise that resolves to the route object.
335
+ * Used for code-splitting routes.
336
+ * See [`lazy`](../../start/data/route-object#lazy).
337
+ */
338
+ lazy?: LazyRouteFunction<IndexRouteObject>;
339
+ /**
340
+ * The route loader.
341
+ * See [`loader`](../../start/data/route-object#loader).
342
+ */
343
+ loader?: IndexRouteObject["loader"];
344
+ /**
345
+ * The route action.
346
+ * See [`action`](../../start/data/route-object#action).
347
+ */
348
+ action?: IndexRouteObject["action"];
349
+ hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
350
+ /**
351
+ * The route shouldRevalidate function.
352
+ * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
353
+ */
354
+ shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
355
+ /**
356
+ * The route handle.
357
+ */
358
+ handle?: IndexRouteObject["handle"];
359
+ /**
360
+ * Whether this is an index route.
361
+ */
362
+ index: true;
363
+ /**
364
+ * Child Route components
365
+ */
366
+ children?: undefined;
367
+ /**
368
+ * The React element to render when this Route matches.
369
+ * Mutually exclusive with {@link Component}.
370
+ */
371
+ element?: React.ReactNode | null;
372
+ /**
373
+ * The React element to render while this router is loading data.
374
+ * Mutually exclusive with {@link HydrateFallback}.
375
+ */
376
+ hydrateFallbackElement?: React.ReactNode | null;
377
+ /**
378
+ * The React element to render at this route if an error occurs.
379
+ * Mutually exclusive with {@link ErrorBoundary}.
380
+ */
381
+ errorElement?: React.ReactNode | null;
382
+ /**
383
+ * The React Component to render when this route matches.
384
+ * Mutually exclusive with {@link element}.
385
+ */
386
+ Component?: React.ComponentType | null;
387
+ /**
388
+ * The React Component to render while this router is loading data.
389
+ * Mutually exclusive with {@link hydrateFallbackElement}.
390
+ */
391
+ HydrateFallback?: React.ComponentType | null;
392
+ /**
393
+ * The React Component to render at this route if an error occurs.
394
+ * Mutually exclusive with {@link errorElement}.
395
+ */
396
+ ErrorBoundary?: React.ComponentType | null;
397
+ }
398
+ type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
399
+ /**
400
+ * Configures an element to render when a pattern matches the current location.
401
+ * It must be rendered within a {@link Routes} element. Note that these routes
402
+ * do not participate in data loading, actions, code splitting, or any other
403
+ * route module features.
404
+ *
405
+ * @example
406
+ * // Usually used in a declarative router
407
+ * function App() {
408
+ * return (
409
+ * <BrowserRouter>
410
+ * <Routes>
411
+ * <Route index element={<StepOne />} />
412
+ * <Route path="step-2" element={<StepTwo />} />
413
+ * <Route path="step-3" element={<StepThree />} />
414
+ * </Routes>
415
+ * </BrowserRouter>
416
+ * );
417
+ * }
418
+ *
419
+ * // But can be used with a data router as well if you prefer the JSX notation
420
+ * const routes = createRoutesFromElements(
421
+ * <>
422
+ * <Route index loader={step1Loader} Component={StepOne} />
423
+ * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
424
+ * <Route path="step-3" loader={step3Loader} Component={StepThree} />
425
+ * </>
426
+ * );
427
+ *
428
+ * const router = createBrowserRouter(routes);
429
+ *
430
+ * function App() {
431
+ * return <RouterProvider router={router} />;
432
+ * }
433
+ *
434
+ * @public
435
+ * @category Components
436
+ * @param props Props
437
+ * @param {PathRouteProps.action} props.action n/a
438
+ * @param {PathRouteProps.caseSensitive} props.caseSensitive n/a
439
+ * @param {PathRouteProps.Component} props.Component n/a
440
+ * @param {PathRouteProps.children} props.children n/a
441
+ * @param {PathRouteProps.element} props.element n/a
442
+ * @param {PathRouteProps.ErrorBoundary} props.ErrorBoundary n/a
443
+ * @param {PathRouteProps.errorElement} props.errorElement n/a
444
+ * @param {PathRouteProps.handle} props.handle n/a
445
+ * @param {PathRouteProps.HydrateFallback} props.HydrateFallback n/a
446
+ * @param {PathRouteProps.hydrateFallbackElement} props.hydrateFallbackElement n/a
447
+ * @param {PathRouteProps.id} props.id n/a
448
+ * @param {PathRouteProps.index} props.index n/a
449
+ * @param {PathRouteProps.lazy} props.lazy n/a
450
+ * @param {PathRouteProps.loader} props.loader n/a
451
+ * @param {PathRouteProps.path} props.path n/a
452
+ * @param {PathRouteProps.shouldRevalidate} props.shouldRevalidate n/a
453
+ * @returns {void}
454
+ */
455
+ declare function Route(props: RouteProps): React.ReactElement | null;
456
+ /**
457
+ * @category Types
458
+ */
459
+ interface RouterProps {
460
+ /**
461
+ * The base path for the application. This is prepended to all locations
462
+ */
463
+ basename?: string;
464
+ /**
465
+ * Nested {@link Route} elements describing the route tree
466
+ */
467
+ children?: React.ReactNode;
468
+ /**
469
+ * The location to match against. Defaults to the current location.
470
+ * This can be a string or a {@link Location} object.
471
+ */
472
+ location: Partial<Location> | string;
473
+ /**
474
+ * The type of navigation that triggered this location change.
475
+ * Defaults to {@link NavigationType.Pop}.
476
+ */
477
+ navigationType?: Action;
478
+ /**
479
+ * The navigator to use for navigation. This is usually a history object
480
+ * or a custom navigator that implements the {@link Navigator} interface.
481
+ */
482
+ navigator: Navigator;
483
+ /**
484
+ * Whether this router is static or not (used for SSR). If `true`, the router
485
+ * will not be reactive to location changes.
486
+ */
487
+ static?: boolean;
488
+ }
489
+ /**
490
+ * Provides location context for the rest of the app.
491
+ *
492
+ * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
493
+ * router that is more specific to your environment such as a {@link BrowserRouter}
494
+ * in web browsers or a {@link ServerRouter} for server rendering.
495
+ *
496
+ * @public
497
+ * @category Declarative Routers
498
+ * @mode declarative
499
+ * @param props Props
500
+ * @param {RouterProps.basename} props.basename n/a
501
+ * @param {RouterProps.children} props.children n/a
502
+ * @param {RouterProps.location} props.location n/a
503
+ * @param {RouterProps.navigationType} props.navigationType n/a
504
+ * @param {RouterProps.navigator} props.navigator n/a
505
+ * @param {RouterProps.static} props.static n/a
506
+ * @returns React element for the rendered router or `null` if the location does
507
+ * not match the {@link props.basename}
508
+ */
509
+ declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
510
+ /**
511
+ * @category Types
512
+ */
513
+ interface RoutesProps {
514
+ /**
515
+ * Nested {@link Route} elements
516
+ */
517
+ children?: React.ReactNode;
518
+ /**
519
+ * The {@link Location} to match against. Defaults to the current location.
520
+ */
521
+ location?: Partial<Location> | string;
522
+ }
523
+ /**
524
+ * Renders a branch of {@link Route | `<Route>`s} that best matches the current
525
+ * location. Note that these routes do not participate in [data loading](../../start/framework/route-module#loader),
526
+ * [`action`](../../start/framework/route-module#action), code splitting, or
527
+ * any other [route module](../../start/framework/route-module) features.
528
+ *
529
+ * @example
530
+ * import { Route, Routes } from "react-router";
531
+ *
532
+ * <Routes>
533
+ * <Route index element={<StepOne />} />
534
+ * <Route path="step-2" element={<StepTwo />} />
535
+ * <Route path="step-3" element={<StepThree />}>
536
+ * </Routes>
537
+ *
538
+ * @public
539
+ * @category Components
540
+ * @param props Props
541
+ * @param {RoutesProps.children} props.children n/a
542
+ * @param {RoutesProps.location} props.location n/a
543
+ * @returns React element for the rendered routes or `null` if no route matches
544
+ */
545
+ declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
546
+ interface AwaitResolveRenderFunction<Resolve = any> {
547
+ (data: Awaited<Resolve>): React.ReactNode;
548
+ }
549
+ /**
550
+ * @category Types
551
+ */
552
+ interface AwaitProps<Resolve> {
553
+ /**
554
+ * When using a function, the resolved value is provided as the parameter.
555
+ *
556
+ * ```tsx [2]
557
+ * <Await resolve={reviewsPromise}>
558
+ * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
559
+ * </Await>
560
+ * ```
561
+ *
562
+ * When using React elements, {@link useAsyncValue} will provide the
563
+ * resolved value:
564
+ *
565
+ * ```tsx [2]
566
+ * <Await resolve={reviewsPromise}>
567
+ * <Reviews />
568
+ * </Await>
569
+ *
570
+ * function Reviews() {
571
+ * const resolvedReviews = useAsyncValue();
572
+ * return <div>...</div>;
573
+ * }
574
+ * ```
575
+ */
576
+ children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
577
+ /**
578
+ * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
579
+ * rejects.
580
+ *
581
+ * ```tsx
582
+ * <Await
583
+ * errorElement={<div>Oops</div>}
584
+ * resolve={reviewsPromise}
585
+ * >
586
+ * <Reviews />
587
+ * </Await>
588
+ * ```
589
+ *
590
+ * To provide a more contextual error, you can use the {@link useAsyncError} in a
591
+ * child component
592
+ *
593
+ * ```tsx
594
+ * <Await
595
+ * errorElement={<ReviewsError />}
596
+ * resolve={reviewsPromise}
597
+ * >
598
+ * <Reviews />
599
+ * </Await>
600
+ *
601
+ * function ReviewsError() {
602
+ * const error = useAsyncError();
603
+ * return <div>Error loading reviews: {error.message}</div>;
604
+ * }
605
+ * ```
606
+ *
607
+ * If you do not provide an `errorElement`, the rejected value will bubble up
608
+ * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
609
+ * and be accessible via the {@link useRouteError} hook.
610
+ */
611
+ errorElement?: React.ReactNode;
612
+ /**
613
+ * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
614
+ * returned from a [`loader`](../../start/framework/route-module#loader) to be
615
+ * resolved and rendered.
616
+ *
617
+ * ```tsx
618
+ * import { Await, useLoaderData } from "react-router";
619
+ *
620
+ * export async function loader() {
621
+ * let reviews = getReviews(); // not awaited
622
+ * let book = await getBook();
623
+ * return {
624
+ * book,
625
+ * reviews, // this is a promise
626
+ * };
627
+ * }
628
+ *
629
+ * export default function Book() {
630
+ * const {
631
+ * book,
632
+ * reviews, // this is the same promise
633
+ * } = useLoaderData();
634
+ *
635
+ * return (
636
+ * <div>
637
+ * <h1>{book.title}</h1>
638
+ * <p>{book.description}</p>
639
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
640
+ * <Await
641
+ * // and is the promise we pass to Await
642
+ * resolve={reviews}
643
+ * >
644
+ * <Reviews />
645
+ * </Await>
646
+ * </React.Suspense>
647
+ * </div>
648
+ * );
649
+ * }
650
+ * ```
651
+ */
652
+ resolve: Resolve;
653
+ }
654
+ /**
655
+ * Used to render promise values with automatic error handling.
656
+ *
657
+ * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
658
+ *
659
+ * @example
660
+ * import { Await, useLoaderData } from "react-router";
661
+ *
662
+ * export async function loader() {
663
+ * // not awaited
664
+ * const reviews = getReviews();
665
+ * // awaited (blocks the transition)
666
+ * const book = await fetch("/api/book").then((res) => res.json());
667
+ * return { book, reviews };
668
+ * }
669
+ *
670
+ * function Book() {
671
+ * const { book, reviews } = useLoaderData();
672
+ * return (
673
+ * <div>
674
+ * <h1>{book.title}</h1>
675
+ * <p>{book.description}</p>
676
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
677
+ * <Await
678
+ * resolve={reviews}
679
+ * errorElement={
680
+ * <div>Could not load reviews 😬</div>
681
+ * }
682
+ * children={(resolvedReviews) => (
683
+ * <Reviews items={resolvedReviews} />
684
+ * )}
685
+ * />
686
+ * </React.Suspense>
687
+ * </div>
688
+ * );
689
+ * }
690
+ *
691
+ * @public
692
+ * @category Components
693
+ * @mode framework
694
+ * @mode data
695
+ * @param props Props
696
+ * @param {AwaitProps.children} props.children n/a
697
+ * @param {AwaitProps.errorElement} props.errorElement n/a
698
+ * @param {AwaitProps.resolve} props.resolve n/a
699
+ * @returns React element for the rendered awaited value
700
+ */
701
+ declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
702
+ /**
703
+ * Creates a route config from a React "children" object, which is usually
704
+ * either a `<Route>` element or an array of them. Used internally by
705
+ * `<Routes>` to create a route config from its children.
706
+ *
707
+ * @category Utils
708
+ * @mode data
709
+ * @param children The React children to convert into a route config
710
+ * @param parentPath The path of the parent route, used to generate unique IDs.
711
+ * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
712
+ */
713
+ declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
714
+ /**
715
+ * Create route objects from JSX elements instead of arrays of objects.
716
+ *
717
+ * @example
718
+ * const routes = createRoutesFromElements(
719
+ * <>
720
+ * <Route index loader={step1Loader} Component={StepOne} />
721
+ * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
722
+ * <Route path="step-3" loader={step3Loader} Component={StepThree} />
723
+ * </>
724
+ * );
725
+ *
726
+ * const router = createBrowserRouter(routes);
727
+ *
728
+ * function App() {
729
+ * return <RouterProvider router={router} />;
730
+ * }
731
+ *
732
+ * @name createRoutesFromElements
733
+ * @public
734
+ * @category Utils
735
+ * @mode data
736
+ * @param children The React children to convert into a route config
737
+ * @param parentPath The path of the parent route, used to generate unique IDs.
738
+ * This is used for internal recursion and is not intended to be used by the
739
+ * application developer.
740
+ * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
741
+ */
742
+ declare const createRoutesFromElements: typeof createRoutesFromChildren;
743
+ /**
744
+ * Renders the result of {@link matchRoutes} into a React element.
745
+ *
746
+ * @public
747
+ * @category Utils
748
+ * @param matches The array of {@link RouteMatch | route matches} to render
749
+ * @returns A React element that renders the matched routes or `null` if no matches
750
+ */
751
+ declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
752
+ declare function useRouteComponentProps(): {
753
+ params: Readonly<Params<string>>;
754
+ loaderData: any;
755
+ actionData: any;
756
+ matches: UIMatch<unknown, unknown>[];
757
+ };
758
+ type RouteComponentProps = ReturnType<typeof useRouteComponentProps>;
759
+ type RouteComponentType = React.ComponentType<RouteComponentProps>;
760
+ declare function WithComponentProps({ children, }: {
761
+ children: React.ReactElement;
762
+ }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
763
+ declare function withComponentProps(Component: RouteComponentType): () => React.ReactElement<{
764
+ params: Readonly<Params<string>>;
765
+ loaderData: any;
766
+ actionData: any;
767
+ matches: UIMatch<unknown, unknown>[];
768
+ }, string | React.JSXElementConstructor<any>>;
769
+ declare function useHydrateFallbackProps(): {
770
+ params: Readonly<Params<string>>;
771
+ loaderData: any;
772
+ actionData: any;
773
+ };
774
+ type HydrateFallbackProps = ReturnType<typeof useHydrateFallbackProps>;
775
+ type HydrateFallbackType = React.ComponentType<HydrateFallbackProps>;
776
+ declare function WithHydrateFallbackProps({ children, }: {
777
+ children: React.ReactElement;
778
+ }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
779
+ declare function withHydrateFallbackProps(HydrateFallback: HydrateFallbackType): () => React.ReactElement<{
780
+ params: Readonly<Params<string>>;
781
+ loaderData: any;
782
+ actionData: any;
783
+ }, string | React.JSXElementConstructor<any>>;
784
+ declare function useErrorBoundaryProps(): {
785
+ params: Readonly<Params<string>>;
786
+ loaderData: any;
787
+ actionData: any;
788
+ error: unknown;
789
+ };
790
+ type ErrorBoundaryProps = ReturnType<typeof useErrorBoundaryProps>;
791
+ type ErrorBoundaryType = React.ComponentType<ErrorBoundaryProps>;
792
+ declare function WithErrorBoundaryProps({ children, }: {
793
+ children: React.ReactElement;
794
+ }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
795
+ declare function withErrorBoundaryProps(ErrorBoundary: ErrorBoundaryType): () => React.ReactElement<{
796
+ params: Readonly<Params<string>>;
797
+ loaderData: any;
798
+ actionData: any;
799
+ error: unknown;
800
+ }, string | React.JSXElementConstructor<any>>;
801
+
802
+ export { type AwaitProps as A, type ErrorBoundaryType as E, type HydrateFallbackType as H, type IndexRouteProps as I, type LayoutRouteProps as L, type MemoryRouterOpts as M, type NavigateProps as N, type OutletProps as O, type PathRouteProps as P, type RouterProviderProps as R, WithComponentProps as W, type RouteComponentType as a, type MemoryRouterProps as b, type RouteProps as c, type RouterProps as d, type RoutesProps as e, Await as f, MemoryRouter as g, Navigate as h, Outlet as i, Route as j, Router as k, RouterProvider as l, Routes as m, createMemoryRouter as n, createRoutesFromChildren as o, createRoutesFromElements as p, hydrationRouteProperties as q, renderMatches as r, mapRouteProperties as s, WithHydrateFallbackProps as t, withHydrateFallbackProps as u, WithErrorBoundaryProps as v, withComponentProps as w, withErrorBoundaryProps as x };