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
@@ -1,3344 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentType, ReactElement } from 'react';
3
-
4
- /**
5
- * Actions represent the type of change to a location value.
6
- */
7
- declare enum Action {
8
- /**
9
- * A POP indicates a change to an arbitrary index in the history stack, such
10
- * as a back or forward navigation. It does not describe the direction of the
11
- * navigation, only that the current index changed.
12
- *
13
- * Note: This is the default action for newly created history objects.
14
- */
15
- Pop = "POP",
16
- /**
17
- * A PUSH indicates a new entry being added to the history stack, such as when
18
- * a link is clicked and a new page loads. When this happens, all subsequent
19
- * entries in the stack are lost.
20
- */
21
- Push = "PUSH",
22
- /**
23
- * A REPLACE indicates the entry at the current index in the history stack
24
- * being replaced by a new one.
25
- */
26
- Replace = "REPLACE"
27
- }
28
- /**
29
- * The pathname, search, and hash values of a URL.
30
- */
31
- interface Path {
32
- /**
33
- * A URL pathname, beginning with a /.
34
- */
35
- pathname: string;
36
- /**
37
- * A URL search string, beginning with a ?.
38
- */
39
- search: string;
40
- /**
41
- * A URL fragment identifier, beginning with a #.
42
- */
43
- hash: string;
44
- }
45
- /**
46
- * An entry in a history stack. A location contains information about the
47
- * URL path, as well as possibly some arbitrary state and a key.
48
- */
49
- interface Location<State = any> extends Path {
50
- /**
51
- * A value of arbitrary data associated with this location.
52
- */
53
- state: State;
54
- /**
55
- * A unique string associated with this location. May be used to safely store
56
- * and retrieve data in some other storage API, like `localStorage`.
57
- *
58
- * Note: This value is always "default" on the initial location.
59
- */
60
- key: string;
61
- /**
62
- * The masked location displayed in the URL bar, which differs from the URL the
63
- * router is operating on
64
- */
65
- unstable_mask: Path | undefined;
66
- }
67
- /**
68
- * A change to the current location.
69
- */
70
- interface Update {
71
- /**
72
- * The action that triggered the change.
73
- */
74
- action: Action;
75
- /**
76
- * The new location.
77
- */
78
- location: Location;
79
- /**
80
- * The delta between this location and the former location in the history stack
81
- */
82
- delta: number | null;
83
- }
84
- /**
85
- * A function that receives notifications about location changes.
86
- */
87
- interface Listener {
88
- (update: Update): void;
89
- }
90
- /**
91
- * Describes a location that is the destination of some navigation used in
92
- * {@link Link}, {@link useNavigate}, etc.
93
- */
94
- type To = string | Partial<Path>;
95
- /**
96
- * A history is an interface to the navigation stack. The history serves as the
97
- * source of truth for the current location, as well as provides a set of
98
- * methods that may be used to change it.
99
- *
100
- * It is similar to the DOM's `window.history` object, but with a smaller, more
101
- * focused API.
102
- */
103
- interface History {
104
- /**
105
- * The last action that modified the current location. This will always be
106
- * Action.Pop when a history instance is first created. This value is mutable.
107
- */
108
- readonly action: Action;
109
- /**
110
- * The current location. This value is mutable.
111
- */
112
- readonly location: Location;
113
- /**
114
- * Returns a valid href for the given `to` value that may be used as
115
- * the value of an <a href> attribute.
116
- *
117
- * @param to - The destination URL
118
- */
119
- createHref(to: To): string;
120
- /**
121
- * Returns a URL for the given `to` value
122
- *
123
- * @param to - The destination URL
124
- */
125
- createURL(to: To): URL;
126
- /**
127
- * Encode a location the same way window.history would do (no-op for memory
128
- * history) so we ensure our PUSH/REPLACE navigations for data routers
129
- * behave the same as POP
130
- *
131
- * @param to Unencoded path
132
- */
133
- encodeLocation(to: To): Path;
134
- /**
135
- * Pushes a new location onto the history stack, increasing its length by one.
136
- * If there were any entries in the stack after the current one, they are
137
- * lost.
138
- *
139
- * @param to - The new URL
140
- * @param state - Data to associate with the new location
141
- */
142
- push(to: To, state?: any): void;
143
- /**
144
- * Replaces the current location in the history stack with a new one. The
145
- * location that was replaced will no longer be available.
146
- *
147
- * @param to - The new URL
148
- * @param state - Data to associate with the new location
149
- */
150
- replace(to: To, state?: any): void;
151
- /**
152
- * Navigates `n` entries backward/forward in the history stack relative to the
153
- * current index. For example, a "back" navigation would use go(-1).
154
- *
155
- * @param delta - The delta in the stack index
156
- */
157
- go(delta: number): void;
158
- /**
159
- * Sets up a listener that will be called whenever the current location
160
- * changes.
161
- *
162
- * @param listener - A function that will be called when the location changes
163
- * @returns unlisten - A function that may be used to stop listening
164
- */
165
- listen(listener: Listener): () => void;
166
- }
167
- /**
168
- * A user-supplied object that describes a location. Used when providing
169
- * entries to `createMemoryHistory` via its `initialEntries` option.
170
- */
171
- type InitialEntry = string | Partial<Location>;
172
- type MemoryHistoryOptions = {
173
- initialEntries?: InitialEntry[];
174
- initialIndex?: number;
175
- v5Compat?: boolean;
176
- };
177
- /**
178
- * A memory history stores locations in memory. This is useful in stateful
179
- * environments where there is no web browser, such as node tests or React
180
- * Native.
181
- */
182
- interface MemoryHistory extends History {
183
- /**
184
- * The current index in the history stack.
185
- */
186
- readonly index: number;
187
- }
188
- /**
189
- * Memory history stores the current location in memory. It is designed for use
190
- * in stateful non-browser environments like tests and React Native.
191
- */
192
- declare function createMemoryHistory(options?: MemoryHistoryOptions): MemoryHistory;
193
- /**
194
- * A browser history stores the current location in regular URLs in a web
195
- * browser environment. This is the standard for most web apps and provides the
196
- * cleanest URLs the browser's address bar.
197
- *
198
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
199
- */
200
- interface BrowserHistory extends UrlHistory {
201
- }
202
- type BrowserHistoryOptions = UrlHistoryOptions;
203
- /**
204
- * Browser history stores the location in regular URLs. This is the standard for
205
- * most web apps, but it requires some configuration on the server to ensure you
206
- * serve the same app at multiple URLs.
207
- *
208
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
209
- */
210
- declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
211
- /**
212
- * A hash history stores the current location in the fragment identifier portion
213
- * of the URL in a web browser environment.
214
- *
215
- * This is ideal for apps that do not control the server for some reason
216
- * (because the fragment identifier is never sent to the server), including some
217
- * shared hosting environments that do not provide fine-grained controls over
218
- * which pages are served at which URLs.
219
- *
220
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory
221
- */
222
- interface HashHistory extends UrlHistory {
223
- }
224
- type HashHistoryOptions = UrlHistoryOptions;
225
- /**
226
- * Hash history stores the location in window.location.hash. This makes it ideal
227
- * for situations where you don't want to send the location to the server for
228
- * some reason, either because you do cannot configure it or the URL space is
229
- * reserved for something else.
230
- *
231
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
232
- */
233
- declare function createHashHistory(options?: HashHistoryOptions): HashHistory;
234
- /**
235
- * @private
236
- */
237
- declare function invariant(value: boolean, message?: string): asserts value;
238
- declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
239
- /**
240
- * Creates a string URL path from the given pathname, search, and hash components.
241
- *
242
- * @category Utils
243
- */
244
- declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
245
- /**
246
- * Parses a string URL path into its separate pathname, search, and hash components.
247
- *
248
- * @category Utils
249
- */
250
- declare function parsePath(path: string): Partial<Path>;
251
- interface UrlHistory extends History {
252
- }
253
- type UrlHistoryOptions = {
254
- window?: Window;
255
- v5Compat?: boolean;
256
- };
257
-
258
- /**
259
- * An augmentable interface users can modify in their app-code to opt into
260
- * future-flag-specific types
261
- */
262
- interface Future {
263
- }
264
- type MiddlewareEnabled = Future extends {
265
- v8_middleware: infer T extends boolean;
266
- } ? T : false;
267
-
268
- type MaybePromise<T> = T | Promise<T>;
269
- /**
270
- * Map of routeId -> data returned from a loader/action/error
271
- */
272
- interface RouteData {
273
- [routeId: string]: any;
274
- }
275
- type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
276
- type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
277
- /**
278
- * Users can specify either lowercase or uppercase form methods on `<Form>`,
279
- * useSubmit(), `<fetcher.Form>`, etc.
280
- */
281
- type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
282
- /**
283
- * Active navigation/fetcher form methods are exposed in uppercase on the
284
- * RouterState. This is to align with the normalization done via fetch().
285
- */
286
- type FormMethod = UpperCaseFormMethod;
287
- type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
288
- type JsonObject = {
289
- [Key in string]: JsonValue;
290
- } & {
291
- [Key in string]?: JsonValue | undefined;
292
- };
293
- type JsonArray = JsonValue[] | readonly JsonValue[];
294
- type JsonPrimitive = string | number | boolean | null;
295
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
296
- /**
297
- * @private
298
- * Internal interface to pass around for action submissions, not intended for
299
- * external consumption
300
- */
301
- type Submission = {
302
- formMethod: FormMethod;
303
- formAction: string;
304
- formEncType: FormEncType;
305
- formData: FormData;
306
- json: undefined;
307
- text: undefined;
308
- } | {
309
- formMethod: FormMethod;
310
- formAction: string;
311
- formEncType: FormEncType;
312
- formData: undefined;
313
- json: JsonValue;
314
- text: undefined;
315
- } | {
316
- formMethod: FormMethod;
317
- formAction: string;
318
- formEncType: FormEncType;
319
- formData: undefined;
320
- json: undefined;
321
- text: string;
322
- };
323
- /**
324
- * A context instance used as the key for the `get`/`set` methods of a
325
- * {@link RouterContextProvider}. Accepts an optional default
326
- * value to be returned if no value has been set.
327
- */
328
- interface RouterContext<T = unknown> {
329
- defaultValue?: T;
330
- }
331
- /**
332
- * Creates a type-safe {@link RouterContext} object that can be used to
333
- * store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
334
- * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
335
- * Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
336
- * but specifically designed for React Router's request/response lifecycle.
337
- *
338
- * If a `defaultValue` is provided, it will be returned from `context.get()`
339
- * when no value has been set for the context. Otherwise, reading this context
340
- * when no value has been set will throw an error.
341
- *
342
- * ```tsx filename=app/context.ts
343
- * import { createContext } from "react-router";
344
- *
345
- * // Create a context for user data
346
- * export const userContext =
347
- * createContext<User | null>(null);
348
- * ```
349
- *
350
- * ```tsx filename=app/middleware/auth.ts
351
- * import { getUserFromSession } from "~/auth.server";
352
- * import { userContext } from "~/context";
353
- *
354
- * export const authMiddleware = async ({
355
- * context,
356
- * request,
357
- * }) => {
358
- * const user = await getUserFromSession(request);
359
- * context.set(userContext, user);
360
- * };
361
- * ```
362
- *
363
- * ```tsx filename=app/routes/profile.tsx
364
- * import { userContext } from "~/context";
365
- *
366
- * export async function loader({
367
- * context,
368
- * }: Route.LoaderArgs) {
369
- * const user = context.get(userContext);
370
- *
371
- * if (!user) {
372
- * throw new Response("Unauthorized", { status: 401 });
373
- * }
374
- *
375
- * return { user };
376
- * }
377
- * ```
378
- *
379
- * @public
380
- * @category Utils
381
- * @mode framework
382
- * @mode data
383
- * @param defaultValue An optional default value for the context. This value
384
- * will be returned if no value has been set for this context.
385
- * @returns A {@link RouterContext} object that can be used with
386
- * `context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
387
- * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
388
- */
389
- declare function createContext<T>(defaultValue?: T): RouterContext<T>;
390
- /**
391
- * Provides methods for writing/reading values in application context in a
392
- * type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
393
- *
394
- * @example
395
- * import {
396
- * createContext,
397
- * RouterContextProvider
398
- * } from "react-router";
399
- *
400
- * const userContext = createContext<User | null>(null);
401
- * const contextProvider = new RouterContextProvider();
402
- * contextProvider.set(userContext, getUser());
403
- * // ^ Type-safe
404
- * const user = contextProvider.get(userContext);
405
- * // ^ User
406
- *
407
- * @public
408
- * @category Utils
409
- * @mode framework
410
- * @mode data
411
- */
412
- declare class RouterContextProvider {
413
- #private;
414
- /**
415
- * Create a new `RouterContextProvider` instance
416
- * @param init An optional initial context map to populate the provider with
417
- */
418
- constructor(init?: Map<RouterContext, unknown>);
419
- /**
420
- * Access a value from the context. If no value has been set for the context,
421
- * it will return the context's `defaultValue` if provided, or throw an error
422
- * if no `defaultValue` was set.
423
- * @param context The context to get the value for
424
- * @returns The value for the context, or the context's `defaultValue` if no
425
- * value was set
426
- */
427
- get<T>(context: RouterContext<T>): T;
428
- /**
429
- * Set a value for the context. If the context already has a value set, this
430
- * will overwrite it.
431
- *
432
- * @param context The context to set the value for
433
- * @param value The value to set for the context
434
- * @returns {void}
435
- */
436
- set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
437
- }
438
- type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : any;
439
- /**
440
- * @private
441
- * Arguments passed to route loader/action functions. Same for now but we keep
442
- * this as a private implementation detail in case they diverge in the future.
443
- */
444
- interface DataFunctionArgs<Context> {
445
- /** 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. */
446
- request: Request;
447
- /**
448
- * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
449
- * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
450
- */
451
- unstable_pattern: string;
452
- /**
453
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
454
- * @example
455
- * // app/routes.ts
456
- * route("teams/:teamId", "./team.tsx"),
457
- *
458
- * // app/team.tsx
459
- * export function loader({
460
- * params,
461
- * }: Route.LoaderArgs) {
462
- * params.teamId;
463
- * // ^ string
464
- * }
465
- */
466
- params: Params;
467
- /**
468
- * This is the context passed in to your server adapter's getLoadContext() function.
469
- * It's a way to bridge the gap between the adapter's request/response API with your React Router app.
470
- * It is only applicable if you are using a custom server adapter.
471
- */
472
- context: Context;
473
- }
474
- /**
475
- * Route middleware `next` function to call downstream handlers and then complete
476
- * middlewares from the bottom-up
477
- */
478
- interface MiddlewareNextFunction<Result = unknown> {
479
- (): Promise<Result>;
480
- }
481
- /**
482
- * Route middleware function signature. Receives the same "data" arguments as a
483
- * `loader`/`action` (`request`, `params`, `context`) as the first parameter and
484
- * a `next` function as the second parameter which will call downstream handlers
485
- * and then complete middlewares from the bottom-up
486
- */
487
- type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<RouterContextProvider>>, next: MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
488
- /**
489
- * Arguments passed to loader functions
490
- */
491
- interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
492
- }
493
- /**
494
- * Arguments passed to action functions
495
- */
496
- interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
497
- }
498
- /**
499
- * Loaders and actions can return anything
500
- */
501
- type DataFunctionValue = unknown;
502
- type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
503
- /**
504
- * Route loader function signature
505
- */
506
- type LoaderFunction<Context = DefaultContext> = {
507
- (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
508
- } & {
509
- hydrate?: boolean;
510
- };
511
- /**
512
- * Route action function signature
513
- */
514
- interface ActionFunction<Context = DefaultContext> {
515
- (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
516
- }
517
- /**
518
- * Arguments passed to shouldRevalidate function
519
- */
520
- interface ShouldRevalidateFunctionArgs {
521
- /** 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. */
522
- currentUrl: URL;
523
- /** 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. */
524
- currentParams: AgnosticDataRouteMatch["params"];
525
- /** 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. */
526
- nextUrl: URL;
527
- /** 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. */
528
- nextParams: AgnosticDataRouteMatch["params"];
529
- /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
530
- formMethod?: Submission["formMethod"];
531
- /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
532
- formAction?: Submission["formAction"];
533
- /** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
534
- formEncType?: Submission["formEncType"];
535
- /** The form submission data when the form's encType is `text/plain` */
536
- text?: Submission["text"];
537
- /** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
538
- formData?: Submission["formData"];
539
- /** The form submission data when the form's encType is `application/json` */
540
- json?: Submission["json"];
541
- /** The status code of the action response */
542
- actionStatus?: number;
543
- /**
544
- * When a submission causes the revalidation this will be the result of the action—either action data or an error if the action failed. It's common to include some information in the action result to instruct shouldRevalidate to revalidate or not.
545
- *
546
- * @example
547
- * export async function action() {
548
- * await saveSomeStuff();
549
- * return { ok: true };
550
- * }
551
- *
552
- * export function shouldRevalidate({
553
- * actionResult,
554
- * }) {
555
- * if (actionResult?.ok) {
556
- * return false;
557
- * }
558
- * return true;
559
- * }
560
- */
561
- actionResult?: any;
562
- /**
563
- * By default, React Router doesn't call every loader all the time. There are reliable optimizations it can make by default. For example, only loaders with changing params are called. Consider navigating from the following URL to the one below it:
564
- *
565
- * /projects/123/tasks/abc
566
- * /projects/123/tasks/def
567
- * React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
568
- *
569
- * It's safest to always return defaultShouldRevalidate after you've done your specific optimizations that return false, otherwise your UI might get out of sync with your data on the server.
570
- */
571
- defaultShouldRevalidate: boolean;
572
- }
573
- /**
574
- * Route shouldRevalidate function signature. This runs after any submission
575
- * (navigation or fetcher), so we flatten the navigation/fetcher submission
576
- * onto the arguments. It shouldn't matter whether it came from a navigation
577
- * or a fetcher, what really matters is the URLs and the formData since loaders
578
- * have to re-run based on the data models that were potentially mutated.
579
- */
580
- interface ShouldRevalidateFunction {
581
- (args: ShouldRevalidateFunctionArgs): boolean;
582
- }
583
- interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
584
- /**
585
- * @private
586
- */
587
- _lazyPromises?: {
588
- middleware: Promise<void> | undefined;
589
- handler: Promise<void> | undefined;
590
- route: Promise<void> | undefined;
591
- };
592
- /**
593
- * @deprecated Deprecated in favor of `shouldCallHandler`
594
- *
595
- * A boolean value indicating whether this route handler should be called in
596
- * this pass.
597
- *
598
- * The `matches` array always includes _all_ matched routes even when only
599
- * _some_ route handlers need to be called so that things like middleware can
600
- * be implemented.
601
- *
602
- * `shouldLoad` is usually only interesting if you are skipping the route
603
- * handler entirely and implementing custom handler logic - since it lets you
604
- * determine if that custom logic should run for this route or not.
605
- *
606
- * For example:
607
- * - If you are on `/parent/child/a` and you navigate to `/parent/child/b` -
608
- * you'll get an array of three matches (`[parent, child, b]`), but only `b`
609
- * will have `shouldLoad=true` because the data for `parent` and `child` is
610
- * already loaded
611
- * - If you are on `/parent/child/a` and you submit to `a`'s [`action`](https://reactrouter.com/docs/start/data/route-object#action),
612
- * then only `a` will have `shouldLoad=true` for the action execution of
613
- * `dataStrategy`
614
- * - After the [`action`](https://reactrouter.com/docs/start/data/route-object#action),
615
- * `dataStrategy` will be called again for the [`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
616
- * revalidation, and all matches will have `shouldLoad=true` (assuming no
617
- * custom `shouldRevalidate` implementations)
618
- */
619
- shouldLoad: boolean;
620
- /**
621
- * Arguments passed to the `shouldRevalidate` function for this `loader` execution.
622
- * Will be `null` if this is not a revalidating loader {@link DataStrategyMatch}.
623
- */
624
- shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
625
- /**
626
- * Determine if this route's handler should be called during this `dataStrategy`
627
- * execution. Calling it with no arguments will leverage the default revalidation
628
- * behavior. You can pass your own `defaultShouldRevalidate` value if you wish
629
- * to change the default revalidation behavior with your `dataStrategy`.
630
- *
631
- * @param defaultShouldRevalidate `defaultShouldRevalidate` override value (optional)
632
- */
633
- shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
634
- /**
635
- * An async function that will resolve any `route.lazy` implementations and
636
- * execute the route's handler (if necessary), returning a {@link DataStrategyResult}
637
- *
638
- * - Calling `match.resolve` does not mean you're calling the
639
- * [`action`](https://reactrouter.com/docs/start/data/route-object#action)/[`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
640
- * (the "handler") - `resolve` will only call the `handler` internally if
641
- * needed _and_ if you don't pass your own `handlerOverride` function parameter
642
- * - It is safe to call `match.resolve` for all matches, even if they have
643
- * `shouldLoad=false`, and it will no-op if no loading is required
644
- * - You should generally always call `match.resolve()` for `shouldLoad:true`
645
- * routes to ensure that any `route.lazy` implementations are processed
646
- * - See the examples below for how to implement custom handler execution via
647
- * `match.resolve`
648
- */
649
- resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
650
- }
651
- interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
652
- /**
653
- * Matches for this route extended with Data strategy APIs
654
- */
655
- matches: DataStrategyMatch[];
656
- runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
657
- /**
658
- * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
659
- * for navigational executions
660
- */
661
- fetcherKey: string | null;
662
- }
663
- /**
664
- * Result from a loader or action called via dataStrategy
665
- */
666
- interface DataStrategyResult {
667
- type: "data" | "error";
668
- result: unknown;
669
- }
670
- interface DataStrategyFunction<Context = DefaultContext> {
671
- (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
672
- }
673
- type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
674
- signal: AbortSignal;
675
- path: string;
676
- matches: M[];
677
- fetcherKey: string | undefined;
678
- patch: (routeId: string | null, children: O[]) => void;
679
- };
680
- type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
681
- /**
682
- * Function provided by the framework-aware layers to set any framework-specific
683
- * properties from framework-agnostic properties
684
- */
685
- interface MapRoutePropertiesFunction {
686
- (route: AgnosticDataRouteObject): {
687
- hasErrorBoundary: boolean;
688
- } & Record<string, any>;
689
- }
690
- /**
691
- * Keys we cannot change from within a lazy object. We spread all other keys
692
- * onto the route. Either they're meaningful to the router, or they'll get
693
- * ignored.
694
- */
695
- type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
696
- /**
697
- * Keys we cannot change from within a lazy() function. We spread all other keys
698
- * onto the route. Either they're meaningful to the router, or they'll get
699
- * ignored.
700
- */
701
- type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middleware";
702
- /**
703
- * lazy object to load route properties, which can add non-matching
704
- * related properties to a route
705
- */
706
- type LazyRouteObject<R extends AgnosticRouteObject> = {
707
- [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
708
- };
709
- /**
710
- * lazy() function to load a route definition, which can add non-matching
711
- * related properties to a route
712
- */
713
- interface LazyRouteFunction<R extends AgnosticRouteObject> {
714
- (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
715
- }
716
- type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
717
- /**
718
- * Base RouteObject with common props shared by all types of routes
719
- */
720
- type AgnosticBaseRouteObject = {
721
- caseSensitive?: boolean;
722
- path?: string;
723
- id?: string;
724
- middleware?: MiddlewareFunction[];
725
- loader?: LoaderFunction | boolean;
726
- action?: ActionFunction | boolean;
727
- hasErrorBoundary?: boolean;
728
- shouldRevalidate?: ShouldRevalidateFunction;
729
- handle?: any;
730
- lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
731
- };
732
- /**
733
- * Index routes must not have children
734
- */
735
- type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
736
- children?: undefined;
737
- index: true;
738
- };
739
- /**
740
- * Non-index routes may have children, but cannot have index
741
- */
742
- type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
743
- children?: AgnosticRouteObject[];
744
- index?: false;
745
- };
746
- /**
747
- * A route object represents a logical route, with (optionally) its child
748
- * routes organized in a tree-like structure.
749
- */
750
- type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
751
- type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
752
- id: string;
753
- };
754
- type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
755
- children?: AgnosticDataRouteObject[];
756
- id: string;
757
- };
758
- /**
759
- * A data route object, which is just a RouteObject with a required unique ID
760
- */
761
- type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
762
- type RouteManifest<R = AgnosticDataRouteObject> = Record<string, R | undefined>;
763
- type Regex_az = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
764
- type Regez_AZ = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
765
- type Regex_09 = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
766
- type Regex_w = Regex_az | Regez_AZ | Regex_09 | "_";
767
- type ParamChar = Regex_w | "-";
768
- type RegexMatchPlus<CharPattern extends string, T extends string> = T extends `${infer First}${infer Rest}` ? First extends CharPattern ? RegexMatchPlus<CharPattern, Rest> extends never ? First : `${First}${RegexMatchPlus<CharPattern, Rest>}` : never : never;
769
- type _PathParam<Path extends string> = Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> : Path extends `:${infer Param}` ? Param extends `${infer Optional}?${string}` ? RegexMatchPlus<ParamChar, Optional> : RegexMatchPlus<ParamChar, Param> : never;
770
- type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
771
- type ParamParseKey<Segment extends string> = [
772
- PathParam<Segment>
773
- ] extends [never] ? string : PathParam<Segment>;
774
- /**
775
- * The parameters that were parsed from the URL path.
776
- */
777
- type Params<Key extends string = string> = {
778
- readonly [key in Key]: string | undefined;
779
- };
780
- /**
781
- * A RouteMatch contains info about how a route matched a URL.
782
- */
783
- interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
784
- /**
785
- * The names and values of dynamic parameters in the URL.
786
- */
787
- params: Params<ParamKey>;
788
- /**
789
- * The portion of the URL pathname that was matched.
790
- */
791
- pathname: string;
792
- /**
793
- * The portion of the URL pathname that was matched before child routes.
794
- */
795
- pathnameBase: string;
796
- /**
797
- * The route object that was used to match.
798
- */
799
- route: RouteObjectType;
800
- }
801
- interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
802
- }
803
- /**
804
- * Matches the given routes to a location and returns the match data.
805
- *
806
- * @example
807
- * import { matchRoutes } from "react-router";
808
- *
809
- * let routes = [{
810
- * path: "/",
811
- * Component: Root,
812
- * children: [{
813
- * path: "dashboard",
814
- * Component: Dashboard,
815
- * }]
816
- * }];
817
- *
818
- * matchRoutes(routes, "/dashboard"); // [rootMatch, dashboardMatch]
819
- *
820
- * @public
821
- * @category Utils
822
- * @param routes The array of route objects to match against.
823
- * @param locationArg The location to match against, either a string path or a
824
- * partial {@link Location} object
825
- * @param basename Optional base path to strip from the location before matching.
826
- * Defaults to `/`.
827
- * @returns An array of matched routes, or `null` if no matches were found.
828
- */
829
- declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
830
- interface UIMatch<Data = unknown, Handle = unknown> {
831
- id: string;
832
- pathname: string;
833
- /**
834
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
835
- */
836
- params: AgnosticRouteMatch["params"];
837
- /**
838
- * The return value from the matched route's loader or clientLoader. This might
839
- * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
840
- * an error and we're currently displaying an `ErrorBoundary`.
841
- *
842
- * @deprecated Use `UIMatch.loaderData` instead
843
- */
844
- data: Data | undefined;
845
- /**
846
- * The return value from the matched route's loader or clientLoader. This might
847
- * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
848
- * an error and we're currently displaying an `ErrorBoundary`.
849
- */
850
- loaderData: Data | undefined;
851
- /**
852
- * The {@link https://reactrouter.com/start/framework/route-module#handle handle object}
853
- * exported from the matched route module
854
- */
855
- handle: Handle;
856
- }
857
- /**
858
- * Returns a path with params interpolated.
859
- *
860
- * @example
861
- * import { generatePath } from "react-router";
862
- *
863
- * generatePath("/users/:id", { id: "123" }); // "/users/123"
864
- *
865
- * @public
866
- * @category Utils
867
- * @param originalPath The original path to generate.
868
- * @param params The parameters to interpolate into the path.
869
- * @returns The generated path with parameters interpolated.
870
- */
871
- declare function generatePath<Path extends string>(originalPath: Path, params?: {
872
- [key in PathParam<Path>]: string | null;
873
- }): string;
874
- /**
875
- * Used to match on some portion of a URL pathname.
876
- */
877
- interface PathPattern<Path extends string = string> {
878
- /**
879
- * A string to match against a URL pathname. May contain `:id`-style segments
880
- * to indicate placeholders for dynamic parameters. It May also end with `/*`
881
- * to indicate matching the rest of the URL pathname.
882
- */
883
- path: Path;
884
- /**
885
- * Should be `true` if the static portions of the `path` should be matched in
886
- * the same case.
887
- */
888
- caseSensitive?: boolean;
889
- /**
890
- * Should be `true` if this pattern should match the entire URL pathname.
891
- */
892
- end?: boolean;
893
- }
894
- /**
895
- * Contains info about how a {@link PathPattern} matched on a URL pathname.
896
- */
897
- interface PathMatch<ParamKey extends string = string> {
898
- /**
899
- * The names and values of dynamic parameters in the URL.
900
- */
901
- params: Params<ParamKey>;
902
- /**
903
- * The portion of the URL pathname that was matched.
904
- */
905
- pathname: string;
906
- /**
907
- * The portion of the URL pathname that was matched before child routes.
908
- */
909
- pathnameBase: string;
910
- /**
911
- * The pattern that was used to match.
912
- */
913
- pattern: PathPattern;
914
- }
915
- /**
916
- * Performs pattern matching on a URL pathname and returns information about
917
- * the match.
918
- *
919
- * @public
920
- * @category Utils
921
- * @param pattern The pattern to match against the URL pathname. This can be a
922
- * string or a {@link PathPattern} object. If a string is provided, it will be
923
- * treated as a pattern with `caseSensitive` set to `false` and `end` set to
924
- * `true`.
925
- * @param pathname The URL pathname to match against the pattern.
926
- * @returns A path match object if the pattern matches the pathname,
927
- * or `null` if it does not match.
928
- */
929
- declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
930
- /**
931
- * Returns a resolved {@link Path} object relative to the given pathname.
932
- *
933
- * @public
934
- * @category Utils
935
- * @param to The path to resolve, either a string or a partial {@link Path}
936
- * object.
937
- * @param fromPathname The pathname to resolve the path from. Defaults to `/`.
938
- * @returns A {@link Path} object with the resolved pathname, search, and hash.
939
- */
940
- declare function resolvePath(to: To, fromPathname?: string): Path;
941
- declare class DataWithResponseInit<D> {
942
- type: string;
943
- data: D;
944
- init: ResponseInit | null;
945
- constructor(data: D, init?: ResponseInit);
946
- }
947
- /**
948
- * Create "responses" that contain `headers`/`status` without forcing
949
- * serialization into an actual [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
950
- *
951
- * @example
952
- * import { data } from "react-router";
953
- *
954
- * export async function action({ request }: Route.ActionArgs) {
955
- * let formData = await request.formData();
956
- * let item = await createItem(formData);
957
- * return data(item, {
958
- * headers: { "X-Custom-Header": "value" }
959
- * status: 201,
960
- * });
961
- * }
962
- *
963
- * @public
964
- * @category Utils
965
- * @mode framework
966
- * @mode data
967
- * @param data The data to be included in the response.
968
- * @param init The status code or a `ResponseInit` object to be included in the
969
- * response.
970
- * @returns A {@link DataWithResponseInit} instance containing the data and
971
- * response init.
972
- */
973
- declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
974
- interface TrackedPromise extends Promise<any> {
975
- _tracked?: boolean;
976
- _data?: any;
977
- _error?: any;
978
- }
979
- type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
980
- /**
981
- * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
982
- * Sets the status code and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
983
- * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
984
- *
985
- * @example
986
- * import { redirect } from "react-router";
987
- *
988
- * export async function loader({ request }: Route.LoaderArgs) {
989
- * if (!isLoggedIn(request))
990
- * throw redirect("/login");
991
- * }
992
- *
993
- * // ...
994
- * }
995
- *
996
- * @public
997
- * @category Utils
998
- * @mode framework
999
- * @mode data
1000
- * @param url The URL to redirect to.
1001
- * @param init The status code or a `ResponseInit` object to be included in the
1002
- * response.
1003
- * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
1004
- * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
1005
- * header.
1006
- */
1007
- declare const redirect: RedirectFunction;
1008
- /**
1009
- * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
1010
- * that will force a document reload to the new location. Sets the status code
1011
- * and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
1012
- * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
1013
- *
1014
- * ```tsx filename=routes/logout.tsx
1015
- * import { redirectDocument } from "react-router";
1016
- *
1017
- * import { destroySession } from "../sessions.server";
1018
- *
1019
- * export async function action({ request }: Route.ActionArgs) {
1020
- * let session = await getSession(request.headers.get("Cookie"));
1021
- * return redirectDocument("/", {
1022
- * headers: { "Set-Cookie": await destroySession(session) }
1023
- * });
1024
- * }
1025
- * ```
1026
- *
1027
- * @public
1028
- * @category Utils
1029
- * @mode framework
1030
- * @mode data
1031
- * @param url The URL to redirect to.
1032
- * @param init The status code or a `ResponseInit` object to be included in the
1033
- * response.
1034
- * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
1035
- * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
1036
- * header.
1037
- */
1038
- declare const redirectDocument: RedirectFunction;
1039
- /**
1040
- * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
1041
- * that will perform a [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState)
1042
- * instead of a [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
1043
- * for client-side navigation redirects. Sets the status code and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
1044
- * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
1045
- *
1046
- * @example
1047
- * import { replace } from "react-router";
1048
- *
1049
- * export async function loader() {
1050
- * return replace("/new-location");
1051
- * }
1052
- *
1053
- * @public
1054
- * @category Utils
1055
- * @mode framework
1056
- * @mode data
1057
- * @param url The URL to redirect to.
1058
- * @param init The status code or a `ResponseInit` object to be included in the
1059
- * response.
1060
- * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
1061
- * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
1062
- * header.
1063
- */
1064
- declare const replace: RedirectFunction;
1065
- type ErrorResponse = {
1066
- status: number;
1067
- statusText: string;
1068
- data: any;
1069
- };
1070
- declare class ErrorResponseImpl implements ErrorResponse {
1071
- status: number;
1072
- statusText: string;
1073
- data: any;
1074
- private error?;
1075
- private internal;
1076
- constructor(status: number, statusText: string | undefined, data: any, internal?: boolean);
1077
- }
1078
- /**
1079
- * Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
1080
- * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
1081
- * thrown from an [`action`](../../start/framework/route-module#action) or
1082
- * [`loader`](../../start/framework/route-module#loader) function.
1083
- *
1084
- * @example
1085
- * import { isRouteErrorResponse } from "react-router";
1086
- *
1087
- * export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
1088
- * if (isRouteErrorResponse(error)) {
1089
- * return (
1090
- * <>
1091
- * <p>Error: `${error.status}: ${error.statusText}`</p>
1092
- * <p>{error.data}</p>
1093
- * </>
1094
- * );
1095
- * }
1096
- *
1097
- * return (
1098
- * <p>Error: {error instanceof Error ? error.message : "Unknown Error"}</p>
1099
- * );
1100
- * }
1101
- *
1102
- * @public
1103
- * @category Utils
1104
- * @mode framework
1105
- * @mode data
1106
- * @param error The error to check.
1107
- * @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
1108
- */
1109
- declare function isRouteErrorResponse(error: any): error is ErrorResponse;
1110
-
1111
- /**
1112
- * An object of unknown type for route loaders and actions provided by the
1113
- * server's `getLoadContext()` function. This is defined as an empty interface
1114
- * specifically so apps can leverage declaration merging to augment this type
1115
- * globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
1116
- */
1117
- interface AppLoadContext {
1118
- [key: string]: unknown;
1119
- }
1120
-
1121
- declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
1122
- hasErrorBoundary: boolean;
1123
- };
1124
- declare const hydrationRouteProperties: (keyof RouteObject)[];
1125
- /**
1126
- * @category Data Routers
1127
- */
1128
- interface MemoryRouterOpts {
1129
- /**
1130
- * Basename path for the application.
1131
- */
1132
- basename?: string;
1133
- /**
1134
- * A function that returns an {@link RouterContextProvider} instance
1135
- * which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
1136
- * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
1137
- * This function is called to generate a fresh `context` instance on each
1138
- * navigation or fetcher call.
1139
- */
1140
- getContext?: RouterInit["getContext"];
1141
- /**
1142
- * Future flags to enable for the router.
1143
- */
1144
- future?: Partial<FutureConfig>;
1145
- /**
1146
- * Hydration data to initialize the router with if you have already performed
1147
- * data loading on the server.
1148
- */
1149
- hydrationData?: HydrationState;
1150
- /**
1151
- * Initial entries in the in-memory history stack
1152
- */
1153
- initialEntries?: InitialEntry[];
1154
- /**
1155
- * Index of `initialEntries` the application should initialize to
1156
- */
1157
- initialIndex?: number;
1158
- /**
1159
- * Array of instrumentation objects allowing you to instrument the router and
1160
- * individual routes prior to router initialization (and on any subsequently
1161
- * added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
1162
- * mostly useful for observability such as wrapping navigations, fetches,
1163
- * as well as route loaders/actions/middlewares with logging and/or performance
1164
- * tracing. See the [docs](../../how-to/instrumentation) for more information.
1165
- *
1166
- * ```tsx
1167
- * let router = createBrowserRouter(routes, {
1168
- * unstable_instrumentations: [logging]
1169
- * });
1170
- *
1171
- *
1172
- * let logging = {
1173
- * router({ instrument }) {
1174
- * instrument({
1175
- * navigate: (impl, info) => logExecution(`navigate ${info.to}`, impl),
1176
- * fetch: (impl, info) => logExecution(`fetch ${info.to}`, impl)
1177
- * });
1178
- * },
1179
- * route({ instrument, id }) {
1180
- * instrument({
1181
- * middleware: (impl, info) => logExecution(
1182
- * `middleware ${info.request.url} (route ${id})`,
1183
- * impl
1184
- * ),
1185
- * loader: (impl, info) => logExecution(
1186
- * `loader ${info.request.url} (route ${id})`,
1187
- * impl
1188
- * ),
1189
- * action: (impl, info) => logExecution(
1190
- * `action ${info.request.url} (route ${id})`,
1191
- * impl
1192
- * ),
1193
- * })
1194
- * }
1195
- * };
1196
- *
1197
- * async function logExecution(label: string, impl: () => Promise<void>) {
1198
- * let start = performance.now();
1199
- * console.log(`start ${label}`);
1200
- * await impl();
1201
- * let duration = Math.round(performance.now() - start);
1202
- * console.log(`end ${label} (${duration}ms)`);
1203
- * }
1204
- * ```
1205
- */
1206
- unstable_instrumentations?: unstable_ClientInstrumentation[];
1207
- /**
1208
- * Override the default data strategy of running loaders in parallel -
1209
- * see the [docs](../../how-to/data-strategy) for more information.
1210
- *
1211
- * ```tsx
1212
- * let router = createBrowserRouter(routes, {
1213
- * async dataStrategy({
1214
- * matches,
1215
- * request,
1216
- * runClientMiddleware,
1217
- * }) {
1218
- * const matchesToLoad = matches.filter((m) =>
1219
- * m.shouldCallHandler(),
1220
- * );
1221
- *
1222
- * const results: Record<string, DataStrategyResult> = {};
1223
- * await runClientMiddleware(() =>
1224
- * Promise.all(
1225
- * matchesToLoad.map(async (match) => {
1226
- * results[match.route.id] = await match.resolve();
1227
- * }),
1228
- * ),
1229
- * );
1230
- * return results;
1231
- * },
1232
- * });
1233
- * ```
1234
- */
1235
- dataStrategy?: DataStrategyFunction;
1236
- /**
1237
- * Lazily define portions of the route tree on navigations.
1238
- */
1239
- patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
1240
- }
1241
- /**
1242
- * Create a new {@link DataRouter} that manages the application path using an
1243
- * in-memory [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1244
- * stack. Useful for non-browser environments without a DOM API.
1245
- *
1246
- * @public
1247
- * @category Data Routers
1248
- * @mode data
1249
- * @param routes Application routes
1250
- * @param opts Options
1251
- * @param {MemoryRouterOpts.basename} opts.basename n/a
1252
- * @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
1253
- * @param {MemoryRouterOpts.future} opts.future n/a
1254
- * @param {MemoryRouterOpts.getContext} opts.getContext n/a
1255
- * @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
1256
- * @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
1257
- * @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
1258
- * @param {MemoryRouterOpts.unstable_instrumentations} opts.unstable_instrumentations n/a
1259
- * @param {MemoryRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
1260
- * @returns An initialized {@link DataRouter} to pass to {@link RouterProvider | `<RouterProvider>`}
1261
- */
1262
- declare function createMemoryRouter(routes: RouteObject[], opts?: MemoryRouterOpts): Router;
1263
- /**
1264
- * Function signature for client side error handling for loader/actions errors
1265
- * and rendering errors via `componentDidCatch`
1266
- */
1267
- interface ClientOnErrorFunction {
1268
- (error: unknown, info: {
1269
- location: Location;
1270
- params: Params;
1271
- unstable_pattern: string;
1272
- errorInfo?: React.ErrorInfo;
1273
- }): void;
1274
- }
1275
- /**
1276
- * @category Types
1277
- */
1278
- interface RouterProviderProps {
1279
- /**
1280
- * The {@link DataRouter} instance to use for navigation and data fetching.
1281
- */
1282
- router: Router;
1283
- /**
1284
- * The [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
1285
- * implementation to use for flushing updates.
1286
- *
1287
- * You usually don't have to worry about this:
1288
- * - The `RouterProvider` exported from `react-router/dom` handles this internally for you
1289
- * - If you are rendering in a non-DOM environment, you can import
1290
- * `RouterProvider` from `react-router` and ignore this prop
1291
- */
1292
- flushSync?: (fn: () => unknown) => undefined;
1293
- /**
1294
- * An error handler function that will be called for any middleware, loader, action,
1295
- * or render errors that are encountered in your application. This is useful for
1296
- * logging or reporting errors instead of in the {@link ErrorBoundary} because it's not
1297
- * subject to re-rendering and will only run one time per error.
1298
- *
1299
- * The `errorInfo` parameter is passed along from
1300
- * [`componentDidCatch`](https://react.dev/reference/react/Component#componentdidcatch)
1301
- * and is only present for render errors.
1302
- *
1303
- * ```tsx
1304
- * <RouterProvider onError=(error, info) => {
1305
- * let { location, params, unstable_pattern, errorInfo } = info;
1306
- * console.error(error, location, errorInfo);
1307
- * reportToErrorService(error, location, errorInfo);
1308
- * }} />
1309
- * ```
1310
- */
1311
- onError?: ClientOnErrorFunction;
1312
- /**
1313
- * Control whether router state updates are internally wrapped in
1314
- * [`React.startTransition`](https://react.dev/reference/react/startTransition).
1315
- *
1316
- * - When left `undefined`, all state updates are wrapped in
1317
- * `React.startTransition`
1318
- * - This can lead to buggy behaviors if you are wrapping your own
1319
- * navigations/fetchers in `startTransition`.
1320
- * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
1321
- * in `React.startTransition` and router state changes will be wrapped in
1322
- * `React.startTransition` and also sent through
1323
- * [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
1324
- * surface mid-navigation router state changes to the UI.
1325
- * - When set to `false`, the router will not leverage `React.startTransition` or
1326
- * `React.useOptimistic` on any navigations or state changes.
1327
- *
1328
- * For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
1329
- */
1330
- unstable_useTransitions?: boolean;
1331
- }
1332
- /**
1333
- * Render the UI for the given {@link DataRouter}. This component should
1334
- * typically be at the top of an app's element tree.
1335
- *
1336
- * ```tsx
1337
- * import { createBrowserRouter } from "react-router";
1338
- * import { RouterProvider } from "react-router/dom";
1339
- * import { createRoot } from "react-dom/client";
1340
- *
1341
- * const router = createBrowserRouter(routes);
1342
- * createRoot(document.getElementById("root")).render(
1343
- * <RouterProvider router={router} />
1344
- * );
1345
- * ```
1346
- *
1347
- * <docs-info>Please note that this component is exported both from
1348
- * `react-router` and `react-router/dom` with the only difference being that the
1349
- * latter automatically wires up `react-dom`'s [`flushSync`](https://react.dev/reference/react-dom/flushSync)
1350
- * implementation. You _almost always_ want to use the version from
1351
- * `react-router/dom` unless you're running in a non-DOM environment.</docs-info>
1352
- *
1353
- *
1354
- * @public
1355
- * @category Data Routers
1356
- * @mode data
1357
- * @param props Props
1358
- * @param {RouterProviderProps.flushSync} props.flushSync n/a
1359
- * @param {RouterProviderProps.onError} props.onError n/a
1360
- * @param {RouterProviderProps.router} props.router n/a
1361
- * @param {RouterProviderProps.unstable_useTransitions} props.unstable_useTransitions n/a
1362
- * @returns React element for the rendered router
1363
- */
1364
- declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, unstable_useTransitions, }: RouterProviderProps): React.ReactElement;
1365
- /**
1366
- * @category Types
1367
- */
1368
- interface MemoryRouterProps {
1369
- /**
1370
- * Application basename
1371
- */
1372
- basename?: string;
1373
- /**
1374
- * Nested {@link Route} elements describing the route tree
1375
- */
1376
- children?: React.ReactNode;
1377
- /**
1378
- * Initial entries in the in-memory history stack
1379
- */
1380
- initialEntries?: InitialEntry[];
1381
- /**
1382
- * Index of `initialEntries` the application should initialize to
1383
- */
1384
- initialIndex?: number;
1385
- /**
1386
- * Control whether router state updates are internally wrapped in
1387
- * [`React.startTransition`](https://react.dev/reference/react/startTransition).
1388
- *
1389
- * - When left `undefined`, all router state updates are wrapped in
1390
- * `React.startTransition`
1391
- * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
1392
- * in `React.startTransition` and all router state updates are wrapped in
1393
- * `React.startTransition`
1394
- * - When set to `false`, the router will not leverage `React.startTransition`
1395
- * on any navigations or state changes.
1396
- *
1397
- * For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
1398
- */
1399
- unstable_useTransitions?: boolean;
1400
- }
1401
- /**
1402
- * A declarative {@link Router | `<Router>`} that stores all entries in memory.
1403
- *
1404
- * @public
1405
- * @category Declarative Routers
1406
- * @mode declarative
1407
- * @param props Props
1408
- * @param {MemoryRouterProps.basename} props.basename n/a
1409
- * @param {MemoryRouterProps.children} props.children n/a
1410
- * @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
1411
- * @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
1412
- * @param {MemoryRouterProps.unstable_useTransitions} props.unstable_useTransitions n/a
1413
- * @returns A declarative in-memory {@link Router | `<Router>`} for client-side
1414
- * routing.
1415
- */
1416
- declare function MemoryRouter({ basename, children, initialEntries, initialIndex, unstable_useTransitions, }: MemoryRouterProps): React.ReactElement;
1417
- /**
1418
- * @category Types
1419
- */
1420
- interface NavigateProps {
1421
- /**
1422
- * The path to navigate to. This can be a string or a {@link Path} object
1423
- */
1424
- to: To;
1425
- /**
1426
- * Whether to replace the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1427
- * stack
1428
- */
1429
- replace?: boolean;
1430
- /**
1431
- * State to pass to the new {@link Location} to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
1432
- */
1433
- state?: any;
1434
- /**
1435
- * How to interpret relative routing in the `to` prop.
1436
- * See {@link RelativeRoutingType}.
1437
- */
1438
- relative?: RelativeRoutingType;
1439
- }
1440
- /**
1441
- * A component-based version of {@link useNavigate} to use in a
1442
- * [`React.Component` class](https://react.dev/reference/react/Component) where
1443
- * hooks cannot be used.
1444
- *
1445
- * It's recommended to avoid using this component in favor of {@link useNavigate}.
1446
- *
1447
- * @example
1448
- * <Navigate to="/tasks" />
1449
- *
1450
- * @public
1451
- * @category Components
1452
- * @param props Props
1453
- * @param {NavigateProps.relative} props.relative n/a
1454
- * @param {NavigateProps.replace} props.replace n/a
1455
- * @param {NavigateProps.state} props.state n/a
1456
- * @param {NavigateProps.to} props.to n/a
1457
- * @returns {void}
1458
- *
1459
- */
1460
- declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
1461
- /**
1462
- * @category Types
1463
- */
1464
- interface OutletProps {
1465
- /**
1466
- * Provides a context value to the element tree below the outlet. Use when
1467
- * the parent route needs to provide values to child routes.
1468
- *
1469
- * ```tsx
1470
- * <Outlet context={myContextValue} />
1471
- * ```
1472
- *
1473
- * Access the context with {@link useOutletContext}.
1474
- */
1475
- context?: unknown;
1476
- }
1477
- /**
1478
- * Renders the matching child route of a parent route or nothing if no child
1479
- * route matches.
1480
- *
1481
- * @example
1482
- * import { Outlet } from "react-router";
1483
- *
1484
- * export default function SomeParent() {
1485
- * return (
1486
- * <div>
1487
- * <h1>Parent Content</h1>
1488
- * <Outlet />
1489
- * </div>
1490
- * );
1491
- * }
1492
- *
1493
- * @public
1494
- * @category Components
1495
- * @param props Props
1496
- * @param {OutletProps.context} props.context n/a
1497
- * @returns React element for the rendered outlet or `null` if no child route matches.
1498
- */
1499
- declare function Outlet(props: OutletProps): React.ReactElement | null;
1500
- /**
1501
- * @category Types
1502
- */
1503
- interface PathRouteProps {
1504
- /**
1505
- * Whether the path should be case-sensitive. Defaults to `false`.
1506
- */
1507
- caseSensitive?: NonIndexRouteObject["caseSensitive"];
1508
- /**
1509
- * The path pattern to match. If unspecified or empty, then this becomes a
1510
- * layout route.
1511
- */
1512
- path?: NonIndexRouteObject["path"];
1513
- /**
1514
- * The unique identifier for this route (for use with {@link DataRouter}s)
1515
- */
1516
- id?: NonIndexRouteObject["id"];
1517
- /**
1518
- * A function that returns a promise that resolves to the route object.
1519
- * Used for code-splitting routes.
1520
- * See [`lazy`](../../start/data/route-object#lazy).
1521
- */
1522
- lazy?: LazyRouteFunction<NonIndexRouteObject>;
1523
- /**
1524
- * The route middleware.
1525
- * See [`middleware`](../../start/data/route-object#middleware).
1526
- */
1527
- middleware?: NonIndexRouteObject["middleware"];
1528
- /**
1529
- * The route loader.
1530
- * See [`loader`](../../start/data/route-object#loader).
1531
- */
1532
- loader?: NonIndexRouteObject["loader"];
1533
- /**
1534
- * The route action.
1535
- * See [`action`](../../start/data/route-object#action).
1536
- */
1537
- action?: NonIndexRouteObject["action"];
1538
- hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
1539
- /**
1540
- * The route shouldRevalidate function.
1541
- * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
1542
- */
1543
- shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
1544
- /**
1545
- * The route handle.
1546
- */
1547
- handle?: NonIndexRouteObject["handle"];
1548
- /**
1549
- * Whether this is an index route.
1550
- */
1551
- index?: false;
1552
- /**
1553
- * Child Route components
1554
- */
1555
- children?: React.ReactNode;
1556
- /**
1557
- * The React element to render when this Route matches.
1558
- * Mutually exclusive with `Component`.
1559
- */
1560
- element?: React.ReactNode | null;
1561
- /**
1562
- * The React element to render while this router is loading data.
1563
- * Mutually exclusive with `HydrateFallback`.
1564
- */
1565
- hydrateFallbackElement?: React.ReactNode | null;
1566
- /**
1567
- * The React element to render at this route if an error occurs.
1568
- * Mutually exclusive with `ErrorBoundary`.
1569
- */
1570
- errorElement?: React.ReactNode | null;
1571
- /**
1572
- * The React Component to render when this route matches.
1573
- * Mutually exclusive with `element`.
1574
- */
1575
- Component?: React.ComponentType | null;
1576
- /**
1577
- * The React Component to render while this router is loading data.
1578
- * Mutually exclusive with `hydrateFallbackElement`.
1579
- */
1580
- HydrateFallback?: React.ComponentType | null;
1581
- /**
1582
- * The React Component to render at this route if an error occurs.
1583
- * Mutually exclusive with `errorElement`.
1584
- */
1585
- ErrorBoundary?: React.ComponentType | null;
1586
- }
1587
- /**
1588
- * @category Types
1589
- */
1590
- interface LayoutRouteProps extends PathRouteProps {
1591
- }
1592
- /**
1593
- * @category Types
1594
- */
1595
- interface IndexRouteProps {
1596
- /**
1597
- * Whether the path should be case-sensitive. Defaults to `false`.
1598
- */
1599
- caseSensitive?: IndexRouteObject["caseSensitive"];
1600
- /**
1601
- * The path pattern to match. If unspecified or empty, then this becomes a
1602
- * layout route.
1603
- */
1604
- path?: IndexRouteObject["path"];
1605
- /**
1606
- * The unique identifier for this route (for use with {@link DataRouter}s)
1607
- */
1608
- id?: IndexRouteObject["id"];
1609
- /**
1610
- * A function that returns a promise that resolves to the route object.
1611
- * Used for code-splitting routes.
1612
- * See [`lazy`](../../start/data/route-object#lazy).
1613
- */
1614
- lazy?: LazyRouteFunction<IndexRouteObject>;
1615
- /**
1616
- * The route middleware.
1617
- * See [`middleware`](../../start/data/route-object#middleware).
1618
- */
1619
- middleware?: IndexRouteObject["middleware"];
1620
- /**
1621
- * The route loader.
1622
- * See [`loader`](../../start/data/route-object#loader).
1623
- */
1624
- loader?: IndexRouteObject["loader"];
1625
- /**
1626
- * The route action.
1627
- * See [`action`](../../start/data/route-object#action).
1628
- */
1629
- action?: IndexRouteObject["action"];
1630
- hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
1631
- /**
1632
- * The route shouldRevalidate function.
1633
- * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
1634
- */
1635
- shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
1636
- /**
1637
- * The route handle.
1638
- */
1639
- handle?: IndexRouteObject["handle"];
1640
- /**
1641
- * Whether this is an index route.
1642
- */
1643
- index: true;
1644
- /**
1645
- * Child Route components
1646
- */
1647
- children?: undefined;
1648
- /**
1649
- * The React element to render when this Route matches.
1650
- * Mutually exclusive with `Component`.
1651
- */
1652
- element?: React.ReactNode | null;
1653
- /**
1654
- * The React element to render while this router is loading data.
1655
- * Mutually exclusive with `HydrateFallback`.
1656
- */
1657
- hydrateFallbackElement?: React.ReactNode | null;
1658
- /**
1659
- * The React element to render at this route if an error occurs.
1660
- * Mutually exclusive with `ErrorBoundary`.
1661
- */
1662
- errorElement?: React.ReactNode | null;
1663
- /**
1664
- * The React Component to render when this route matches.
1665
- * Mutually exclusive with `element`.
1666
- */
1667
- Component?: React.ComponentType | null;
1668
- /**
1669
- * The React Component to render while this router is loading data.
1670
- * Mutually exclusive with `hydrateFallbackElement`.
1671
- */
1672
- HydrateFallback?: React.ComponentType | null;
1673
- /**
1674
- * The React Component to render at this route if an error occurs.
1675
- * Mutually exclusive with `errorElement`.
1676
- */
1677
- ErrorBoundary?: React.ComponentType | null;
1678
- }
1679
- type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
1680
- /**
1681
- * Configures an element to render when a pattern matches the current location.
1682
- * It must be rendered within a {@link Routes} element. Note that these routes
1683
- * do not participate in data loading, actions, code splitting, or any other
1684
- * route module features.
1685
- *
1686
- * @example
1687
- * // Usually used in a declarative router
1688
- * function App() {
1689
- * return (
1690
- * <BrowserRouter>
1691
- * <Routes>
1692
- * <Route index element={<StepOne />} />
1693
- * <Route path="step-2" element={<StepTwo />} />
1694
- * <Route path="step-3" element={<StepThree />} />
1695
- * </Routes>
1696
- * </BrowserRouter>
1697
- * );
1698
- * }
1699
- *
1700
- * // But can be used with a data router as well if you prefer the JSX notation
1701
- * const routes = createRoutesFromElements(
1702
- * <>
1703
- * <Route index loader={step1Loader} Component={StepOne} />
1704
- * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
1705
- * <Route path="step-3" loader={step3Loader} Component={StepThree} />
1706
- * </>
1707
- * );
1708
- *
1709
- * const router = createBrowserRouter(routes);
1710
- *
1711
- * function App() {
1712
- * return <RouterProvider router={router} />;
1713
- * }
1714
- *
1715
- * @public
1716
- * @category Components
1717
- * @param props Props
1718
- * @param {PathRouteProps.action} props.action n/a
1719
- * @param {PathRouteProps.caseSensitive} props.caseSensitive n/a
1720
- * @param {PathRouteProps.Component} props.Component n/a
1721
- * @param {PathRouteProps.children} props.children n/a
1722
- * @param {PathRouteProps.element} props.element n/a
1723
- * @param {PathRouteProps.ErrorBoundary} props.ErrorBoundary n/a
1724
- * @param {PathRouteProps.errorElement} props.errorElement n/a
1725
- * @param {PathRouteProps.handle} props.handle n/a
1726
- * @param {PathRouteProps.HydrateFallback} props.HydrateFallback n/a
1727
- * @param {PathRouteProps.hydrateFallbackElement} props.hydrateFallbackElement n/a
1728
- * @param {PathRouteProps.id} props.id n/a
1729
- * @param {PathRouteProps.index} props.index n/a
1730
- * @param {PathRouteProps.lazy} props.lazy n/a
1731
- * @param {PathRouteProps.loader} props.loader n/a
1732
- * @param {PathRouteProps.path} props.path n/a
1733
- * @param {PathRouteProps.shouldRevalidate} props.shouldRevalidate n/a
1734
- * @returns {void}
1735
- */
1736
- declare function Route(props: RouteProps): React.ReactElement | null;
1737
- /**
1738
- * @category Types
1739
- */
1740
- interface RouterProps {
1741
- /**
1742
- * The base path for the application. This is prepended to all locations
1743
- */
1744
- basename?: string;
1745
- /**
1746
- * Nested {@link Route} elements describing the route tree
1747
- */
1748
- children?: React.ReactNode;
1749
- /**
1750
- * The location to match against. Defaults to the current location.
1751
- * This can be a string or a {@link Location} object.
1752
- */
1753
- location: Partial<Location> | string;
1754
- /**
1755
- * The type of navigation that triggered this `location` change.
1756
- * Defaults to {@link NavigationType.Pop}.
1757
- */
1758
- navigationType?: Action;
1759
- /**
1760
- * The navigator to use for navigation. This is usually a history object
1761
- * or a custom navigator that implements the {@link Navigator} interface.
1762
- */
1763
- navigator: Navigator;
1764
- /**
1765
- * Whether this router is static or not (used for SSR). If `true`, the router
1766
- * will not be reactive to location changes.
1767
- */
1768
- static?: boolean;
1769
- /**
1770
- * Control whether router state updates are internally wrapped in
1771
- * [`React.startTransition`](https://react.dev/reference/react/startTransition).
1772
- *
1773
- * - When left `undefined`, all router state updates are wrapped in
1774
- * `React.startTransition`
1775
- * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
1776
- * in `React.startTransition` and all router state updates are wrapped in
1777
- * `React.startTransition`
1778
- * - When set to `false`, the router will not leverage `React.startTransition`
1779
- * on any navigations or state changes.
1780
- *
1781
- * For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
1782
- */
1783
- unstable_useTransitions?: boolean;
1784
- }
1785
- /**
1786
- * Provides location context for the rest of the app.
1787
- *
1788
- * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
1789
- * router that is more specific to your environment such as a {@link BrowserRouter}
1790
- * in web browsers or a {@link ServerRouter} for server rendering.
1791
- *
1792
- * @public
1793
- * @category Declarative Routers
1794
- * @mode declarative
1795
- * @param props Props
1796
- * @param {RouterProps.basename} props.basename n/a
1797
- * @param {RouterProps.children} props.children n/a
1798
- * @param {RouterProps.location} props.location n/a
1799
- * @param {RouterProps.navigationType} props.navigationType n/a
1800
- * @param {RouterProps.navigator} props.navigator n/a
1801
- * @param {RouterProps.static} props.static n/a
1802
- * @param {RouterProps.unstable_useTransitions} props.unstable_useTransitions n/a
1803
- * @returns React element for the rendered router or `null` if the location does
1804
- * not match the {@link props.basename}
1805
- */
1806
- declare function Router$1({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, unstable_useTransitions, }: RouterProps): React.ReactElement | null;
1807
- /**
1808
- * @category Types
1809
- */
1810
- interface RoutesProps {
1811
- /**
1812
- * Nested {@link Route} elements
1813
- */
1814
- children?: React.ReactNode;
1815
- /**
1816
- * The {@link Location} to match against. Defaults to the current location.
1817
- */
1818
- location?: Partial<Location> | string;
1819
- }
1820
- /**
1821
- * Renders a branch of {@link Route | `<Route>`s} that best matches the current
1822
- * location. Note that these routes do not participate in [data loading](../../start/framework/route-module#loader),
1823
- * [`action`](../../start/framework/route-module#action), code splitting, or
1824
- * any other [route module](../../start/framework/route-module) features.
1825
- *
1826
- * @example
1827
- * import { Route, Routes } from "react-router";
1828
- *
1829
- * <Routes>
1830
- * <Route index element={<StepOne />} />
1831
- * <Route path="step-2" element={<StepTwo />} />
1832
- * <Route path="step-3" element={<StepThree />} />
1833
- * </Routes>
1834
- *
1835
- * @public
1836
- * @category Components
1837
- * @param props Props
1838
- * @param {RoutesProps.children} props.children n/a
1839
- * @param {RoutesProps.location} props.location n/a
1840
- * @returns React element for the rendered routes or `null` if no route matches
1841
- */
1842
- declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
1843
- interface AwaitResolveRenderFunction<Resolve = any> {
1844
- (data: Awaited<Resolve>): React.ReactNode;
1845
- }
1846
- /**
1847
- * @category Types
1848
- */
1849
- interface AwaitProps<Resolve> {
1850
- /**
1851
- * When using a function, the resolved value is provided as the parameter.
1852
- *
1853
- * ```tsx [2]
1854
- * <Await resolve={reviewsPromise}>
1855
- * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
1856
- * </Await>
1857
- * ```
1858
- *
1859
- * When using React elements, {@link useAsyncValue} will provide the
1860
- * resolved value:
1861
- *
1862
- * ```tsx [2]
1863
- * <Await resolve={reviewsPromise}>
1864
- * <Reviews />
1865
- * </Await>
1866
- *
1867
- * function Reviews() {
1868
- * const resolvedReviews = useAsyncValue();
1869
- * return <div>...</div>;
1870
- * }
1871
- * ```
1872
- */
1873
- children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
1874
- /**
1875
- * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1876
- * rejects.
1877
- *
1878
- * ```tsx
1879
- * <Await
1880
- * errorElement={<div>Oops</div>}
1881
- * resolve={reviewsPromise}
1882
- * >
1883
- * <Reviews />
1884
- * </Await>
1885
- * ```
1886
- *
1887
- * To provide a more contextual error, you can use the {@link useAsyncError} in a
1888
- * child component
1889
- *
1890
- * ```tsx
1891
- * <Await
1892
- * errorElement={<ReviewsError />}
1893
- * resolve={reviewsPromise}
1894
- * >
1895
- * <Reviews />
1896
- * </Await>
1897
- *
1898
- * function ReviewsError() {
1899
- * const error = useAsyncError();
1900
- * return <div>Error loading reviews: {error.message}</div>;
1901
- * }
1902
- * ```
1903
- *
1904
- * If you do not provide an `errorElement`, the rejected value will bubble up
1905
- * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
1906
- * and be accessible via the {@link useRouteError} hook.
1907
- */
1908
- errorElement?: React.ReactNode;
1909
- /**
1910
- * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1911
- * returned from a [`loader`](../../start/framework/route-module#loader) to be
1912
- * resolved and rendered.
1913
- *
1914
- * ```tsx
1915
- * import { Await, useLoaderData } from "react-router";
1916
- *
1917
- * export async function loader() {
1918
- * let reviews = getReviews(); // not awaited
1919
- * let book = await getBook();
1920
- * return {
1921
- * book,
1922
- * reviews, // this is a promise
1923
- * };
1924
- * }
1925
- *
1926
- * export default function Book() {
1927
- * const {
1928
- * book,
1929
- * reviews, // this is the same promise
1930
- * } = useLoaderData();
1931
- *
1932
- * return (
1933
- * <div>
1934
- * <h1>{book.title}</h1>
1935
- * <p>{book.description}</p>
1936
- * <React.Suspense fallback={<ReviewsSkeleton />}>
1937
- * <Await
1938
- * // and is the promise we pass to Await
1939
- * resolve={reviews}
1940
- * >
1941
- * <Reviews />
1942
- * </Await>
1943
- * </React.Suspense>
1944
- * </div>
1945
- * );
1946
- * }
1947
- * ```
1948
- */
1949
- resolve: Resolve;
1950
- }
1951
- /**
1952
- * Used to render promise values with automatic error handling.
1953
- *
1954
- * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
1955
- *
1956
- * @example
1957
- * import { Await, useLoaderData } from "react-router";
1958
- *
1959
- * export async function loader() {
1960
- * // not awaited
1961
- * const reviews = getReviews();
1962
- * // awaited (blocks the transition)
1963
- * const book = await fetch("/api/book").then((res) => res.json());
1964
- * return { book, reviews };
1965
- * }
1966
- *
1967
- * function Book() {
1968
- * const { book, reviews } = useLoaderData();
1969
- * return (
1970
- * <div>
1971
- * <h1>{book.title}</h1>
1972
- * <p>{book.description}</p>
1973
- * <React.Suspense fallback={<ReviewsSkeleton />}>
1974
- * <Await
1975
- * resolve={reviews}
1976
- * errorElement={
1977
- * <div>Could not load reviews 😬</div>
1978
- * }
1979
- * children={(resolvedReviews) => (
1980
- * <Reviews items={resolvedReviews} />
1981
- * )}
1982
- * />
1983
- * </React.Suspense>
1984
- * </div>
1985
- * );
1986
- * }
1987
- *
1988
- * @public
1989
- * @category Components
1990
- * @mode framework
1991
- * @mode data
1992
- * @param props Props
1993
- * @param {AwaitProps.children} props.children n/a
1994
- * @param {AwaitProps.errorElement} props.errorElement n/a
1995
- * @param {AwaitProps.resolve} props.resolve n/a
1996
- * @returns React element for the rendered awaited value
1997
- */
1998
- declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
1999
- /**
2000
- * Creates a route config from a React "children" object, which is usually
2001
- * either a `<Route>` element or an array of them. Used internally by
2002
- * `<Routes>` to create a route config from its children.
2003
- *
2004
- * @category Utils
2005
- * @mode data
2006
- * @param children The React children to convert into a route config
2007
- * @param parentPath The path of the parent route, used to generate unique IDs.
2008
- * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
2009
- */
2010
- declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
2011
- /**
2012
- * Create route objects from JSX elements instead of arrays of objects.
2013
- *
2014
- * @example
2015
- * const routes = createRoutesFromElements(
2016
- * <>
2017
- * <Route index loader={step1Loader} Component={StepOne} />
2018
- * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
2019
- * <Route path="step-3" loader={step3Loader} Component={StepThree} />
2020
- * </>
2021
- * );
2022
- *
2023
- * const router = createBrowserRouter(routes);
2024
- *
2025
- * function App() {
2026
- * return <RouterProvider router={router} />;
2027
- * }
2028
- *
2029
- * @name createRoutesFromElements
2030
- * @public
2031
- * @category Utils
2032
- * @mode data
2033
- * @param children The React children to convert into a route config
2034
- * @param parentPath The path of the parent route, used to generate unique IDs.
2035
- * This is used for internal recursion and is not intended to be used by the
2036
- * application developer.
2037
- * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
2038
- */
2039
- declare const createRoutesFromElements: typeof createRoutesFromChildren;
2040
- /**
2041
- * Renders the result of {@link matchRoutes} into a React element.
2042
- *
2043
- * @public
2044
- * @category Utils
2045
- * @param matches The array of {@link RouteMatch | route matches} to render
2046
- * @returns A React element that renders the matched routes or `null` if no matches
2047
- */
2048
- declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
2049
- declare function useRouteComponentProps(): {
2050
- params: Readonly<Params<string>>;
2051
- loaderData: any;
2052
- actionData: any;
2053
- matches: UIMatch<unknown, unknown>[];
2054
- };
2055
- type RouteComponentProps = ReturnType<typeof useRouteComponentProps>;
2056
- type RouteComponentType = React.ComponentType<RouteComponentProps>;
2057
- declare function WithComponentProps({ children, }: {
2058
- children: React.ReactElement;
2059
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
2060
- declare function withComponentProps(Component: RouteComponentType): () => React.ReactElement<{
2061
- params: Readonly<Params<string>>;
2062
- loaderData: any;
2063
- actionData: any;
2064
- matches: UIMatch<unknown, unknown>[];
2065
- }, string | React.JSXElementConstructor<any>>;
2066
- declare function useHydrateFallbackProps(): {
2067
- params: Readonly<Params<string>>;
2068
- loaderData: any;
2069
- actionData: any;
2070
- };
2071
- type HydrateFallbackProps = ReturnType<typeof useHydrateFallbackProps>;
2072
- type HydrateFallbackType = React.ComponentType<HydrateFallbackProps>;
2073
- declare function WithHydrateFallbackProps({ children, }: {
2074
- children: React.ReactElement;
2075
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
2076
- declare function withHydrateFallbackProps(HydrateFallback: HydrateFallbackType): () => React.ReactElement<{
2077
- params: Readonly<Params<string>>;
2078
- loaderData: any;
2079
- actionData: any;
2080
- }, string | React.JSXElementConstructor<any>>;
2081
- declare function useErrorBoundaryProps(): {
2082
- params: Readonly<Params<string>>;
2083
- loaderData: any;
2084
- actionData: any;
2085
- error: unknown;
2086
- };
2087
- type ErrorBoundaryProps = ReturnType<typeof useErrorBoundaryProps>;
2088
- type ErrorBoundaryType = React.ComponentType<ErrorBoundaryProps>;
2089
- declare function WithErrorBoundaryProps({ children, }: {
2090
- children: React.ReactElement;
2091
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
2092
- declare function withErrorBoundaryProps(ErrorBoundary: ErrorBoundaryType): () => React.ReactElement<{
2093
- params: Readonly<Params<string>>;
2094
- loaderData: any;
2095
- actionData: any;
2096
- error: unknown;
2097
- }, string | React.JSXElementConstructor<any>>;
2098
-
2099
- interface IndexRouteObject {
2100
- caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
2101
- path?: AgnosticIndexRouteObject["path"];
2102
- id?: AgnosticIndexRouteObject["id"];
2103
- middleware?: AgnosticIndexRouteObject["middleware"];
2104
- loader?: AgnosticIndexRouteObject["loader"];
2105
- action?: AgnosticIndexRouteObject["action"];
2106
- hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
2107
- shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
2108
- handle?: AgnosticIndexRouteObject["handle"];
2109
- index: true;
2110
- children?: undefined;
2111
- element?: React.ReactNode | null;
2112
- hydrateFallbackElement?: React.ReactNode | null;
2113
- errorElement?: React.ReactNode | null;
2114
- Component?: React.ComponentType | null;
2115
- HydrateFallback?: React.ComponentType | null;
2116
- ErrorBoundary?: React.ComponentType | null;
2117
- lazy?: LazyRouteDefinition<RouteObject>;
2118
- }
2119
- interface NonIndexRouteObject {
2120
- caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
2121
- path?: AgnosticNonIndexRouteObject["path"];
2122
- id?: AgnosticNonIndexRouteObject["id"];
2123
- middleware?: AgnosticNonIndexRouteObject["middleware"];
2124
- loader?: AgnosticNonIndexRouteObject["loader"];
2125
- action?: AgnosticNonIndexRouteObject["action"];
2126
- hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
2127
- shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
2128
- handle?: AgnosticNonIndexRouteObject["handle"];
2129
- index?: false;
2130
- children?: RouteObject[];
2131
- element?: React.ReactNode | null;
2132
- hydrateFallbackElement?: React.ReactNode | null;
2133
- errorElement?: React.ReactNode | null;
2134
- Component?: React.ComponentType | null;
2135
- HydrateFallback?: React.ComponentType | null;
2136
- ErrorBoundary?: React.ComponentType | null;
2137
- lazy?: LazyRouteDefinition<RouteObject>;
2138
- }
2139
- type RouteObject = IndexRouteObject | NonIndexRouteObject;
2140
- type DataRouteObject = RouteObject & {
2141
- children?: DataRouteObject[];
2142
- id: string;
2143
- };
2144
- interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
2145
- }
2146
- interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
2147
- }
2148
- type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
2149
- type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
2150
- interface DataRouterContextObject extends Omit<NavigationContextObject, "future" | "unstable_useTransitions"> {
2151
- router: Router;
2152
- staticContext?: StaticHandlerContext;
2153
- onError?: ClientOnErrorFunction;
2154
- }
2155
- declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
2156
- declare const DataRouterStateContext: React.Context<RouterState | null>;
2157
- type ViewTransitionContextObject = {
2158
- isTransitioning: false;
2159
- } | {
2160
- isTransitioning: true;
2161
- flushSync: boolean;
2162
- currentLocation: Location;
2163
- nextLocation: Location;
2164
- };
2165
- declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
2166
- type FetchersContextObject = Map<string, any>;
2167
- declare const FetchersContext: React.Context<FetchersContextObject>;
2168
- declare const AwaitContext: React.Context<TrackedPromise | null>;
2169
- declare const AwaitContextProvider: (props: React.ComponentProps<typeof AwaitContext.Provider>) => React.FunctionComponentElement<React.ProviderProps<TrackedPromise | null>>;
2170
- interface NavigateOptions {
2171
- /** Replace the current entry in the history stack instead of pushing a new one */
2172
- replace?: boolean;
2173
- /** Masked URL */
2174
- unstable_mask?: To;
2175
- /** Adds persistent client side routing state to the next location */
2176
- state?: any;
2177
- /** If you are using {@link ScrollRestoration `<ScrollRestoration>`}, prevent the scroll position from being reset to the top of the window when navigating */
2178
- preventScrollReset?: boolean;
2179
- /** Defines the relative path behavior for the link. "route" will use the route hierarchy so ".." will remove all URL segments of the current route pattern while "path" will use the URL path so ".." will remove one URL segment. */
2180
- relative?: RelativeRoutingType;
2181
- /** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
2182
- flushSync?: boolean;
2183
- /** Enables a {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API View Transition} for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the {@link useViewTransitionState `useViewTransitionState()`} hook. */
2184
- viewTransition?: boolean;
2185
- /** Specifies the default revalidation behavior after this submission */
2186
- unstable_defaultShouldRevalidate?: boolean;
2187
- }
2188
- /**
2189
- * A Navigator is a "location changer"; it's how you get to different locations.
2190
- *
2191
- * Every history instance conforms to the Navigator interface, but the
2192
- * distinction is useful primarily when it comes to the low-level `<Router>` API
2193
- * where both the location and a navigator must be provided separately in order
2194
- * to avoid "tearing" that may occur in a suspense-enabled app if the action
2195
- * and/or location were to be read directly from the history instance.
2196
- */
2197
- interface Navigator {
2198
- createHref: History["createHref"];
2199
- encodeLocation?: History["encodeLocation"];
2200
- go: History["go"];
2201
- push(to: To, state?: any, opts?: NavigateOptions): void;
2202
- replace(to: To, state?: any, opts?: NavigateOptions): void;
2203
- }
2204
- interface NavigationContextObject {
2205
- basename: string;
2206
- navigator: Navigator;
2207
- static: boolean;
2208
- unstable_useTransitions: boolean | undefined;
2209
- future: {};
2210
- }
2211
- declare const NavigationContext: React.Context<NavigationContextObject>;
2212
- interface LocationContextObject {
2213
- location: Location;
2214
- navigationType: Action;
2215
- }
2216
- declare const LocationContext: React.Context<LocationContextObject>;
2217
- interface RouteContextObject {
2218
- outlet: React.ReactElement | null;
2219
- matches: RouteMatch[];
2220
- isDataRoute: boolean;
2221
- }
2222
- declare const RouteContext: React.Context<RouteContextObject>;
2223
-
2224
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
2225
- type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
2226
- interface HtmlLinkProps {
2227
- /**
2228
- * Address of the hyperlink
2229
- */
2230
- href?: string;
2231
- /**
2232
- * How the element handles crossorigin requests
2233
- */
2234
- crossOrigin?: "anonymous" | "use-credentials";
2235
- /**
2236
- * Relationship between the document containing the hyperlink and the destination resource
2237
- */
2238
- rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
2239
- /**
2240
- * Applicable media: "screen", "print", "(max-width: 764px)"
2241
- */
2242
- media?: string;
2243
- /**
2244
- * Integrity metadata used in Subresource Integrity checks
2245
- */
2246
- integrity?: string;
2247
- /**
2248
- * Language of the linked resource
2249
- */
2250
- hrefLang?: string;
2251
- /**
2252
- * Hint for the type of the referenced resource
2253
- */
2254
- type?: string;
2255
- /**
2256
- * Referrer policy for fetches initiated by the element
2257
- */
2258
- referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
2259
- /**
2260
- * Sizes of the icons (for rel="icon")
2261
- */
2262
- sizes?: string;
2263
- /**
2264
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
2265
- */
2266
- as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
2267
- /**
2268
- * Color to use when customizing a site's icon (for rel="mask-icon")
2269
- */
2270
- color?: string;
2271
- /**
2272
- * Whether the link is disabled
2273
- */
2274
- disabled?: boolean;
2275
- /**
2276
- * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
2277
- */
2278
- title?: string;
2279
- /**
2280
- * Images to use in different situations, e.g., high-resolution displays,
2281
- * small monitors, etc. (for rel="preload")
2282
- */
2283
- imageSrcSet?: string;
2284
- /**
2285
- * Image sizes for different page layouts (for rel="preload")
2286
- */
2287
- imageSizes?: string;
2288
- }
2289
- interface HtmlLinkPreloadImage extends HtmlLinkProps {
2290
- /**
2291
- * Relationship between the document containing the hyperlink and the destination resource
2292
- */
2293
- rel: "preload";
2294
- /**
2295
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
2296
- */
2297
- as: "image";
2298
- /**
2299
- * Address of the hyperlink
2300
- */
2301
- href?: string;
2302
- /**
2303
- * Images to use in different situations, e.g., high-resolution displays,
2304
- * small monitors, etc. (for rel="preload")
2305
- */
2306
- imageSrcSet: string;
2307
- /**
2308
- * Image sizes for different page layouts (for rel="preload")
2309
- */
2310
- imageSizes?: string;
2311
- }
2312
- /**
2313
- * Represents a `<link>` element.
2314
- *
2315
- * WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
2316
- */
2317
- type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
2318
- imageSizes?: never;
2319
- });
2320
- interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
2321
- /**
2322
- * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
2323
- * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
2324
- * element
2325
- */
2326
- nonce?: string | undefined;
2327
- /**
2328
- * The absolute path of the page to prefetch, e.g. `/absolute/path`.
2329
- */
2330
- page: string;
2331
- }
2332
- type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
2333
-
2334
- type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
2335
- [key: PropertyKey]: Serializable;
2336
- } | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
2337
-
2338
- type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
2339
- type IsAny<T> = 0 extends 1 & T ? true : false;
2340
- type Func = (...args: any[]) => unknown;
2341
- type Pretty<T> = {
2342
- [K in keyof T]: T[K];
2343
- } & {};
2344
- type Normalize<T> = _Normalize<UnionKeys<T>, T>;
2345
- type _Normalize<Key extends keyof any, T> = T extends infer U ? Pretty<{
2346
- [K in Key as K extends keyof U ? undefined extends U[K] ? never : K : never]: K extends keyof U ? U[K] : never;
2347
- } & {
2348
- [K in Key as K extends keyof U ? undefined extends U[K] ? K : never : never]?: K extends keyof U ? U[K] : never;
2349
- } & {
2350
- [K in Key as K extends keyof U ? never : K]?: undefined;
2351
- }> : never;
2352
- type UnionKeys<T> = T extends any ? keyof T : never;
2353
-
2354
- type RouteModule$1 = {
2355
- meta?: Func;
2356
- links?: Func;
2357
- headers?: Func;
2358
- loader?: Func;
2359
- clientLoader?: Func;
2360
- action?: Func;
2361
- clientAction?: Func;
2362
- HydrateFallback?: Func;
2363
- default?: Func;
2364
- ErrorBoundary?: Func;
2365
- [key: string]: unknown;
2366
- };
2367
-
2368
- /**
2369
- * A brand that can be applied to a type to indicate that it will serialize
2370
- * to a specific type when transported to the client from a loader.
2371
- * Only use this if you have additional serialization/deserialization logic
2372
- * in your application.
2373
- */
2374
- type unstable_SerializesTo<T> = {
2375
- unstable__ReactRouter_SerializesTo: [T];
2376
- };
2377
-
2378
- type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
2379
- [K in keyof T]: Serialize<T[K]>;
2380
- } : undefined;
2381
- type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
2382
- type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
2383
- type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
2384
- type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
2385
- type ServerDataFrom<T> = ServerData<DataFrom<T>>;
2386
- type ClientDataFrom<T> = ClientData<DataFrom<T>>;
2387
- type ClientDataFunctionArgs<Params> = {
2388
- /**
2389
- * A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
2390
- *
2391
- * @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.
2392
- **/
2393
- request: Request;
2394
- /**
2395
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
2396
- * @example
2397
- * // app/routes.ts
2398
- * route("teams/:teamId", "./team.tsx"),
2399
- *
2400
- * // app/team.tsx
2401
- * export function clientLoader({
2402
- * params,
2403
- * }: Route.ClientLoaderArgs) {
2404
- * params.teamId;
2405
- * // ^ string
2406
- * }
2407
- **/
2408
- params: Params;
2409
- /**
2410
- * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
2411
- * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
2412
- */
2413
- unstable_pattern: string;
2414
- /**
2415
- * When `future.v8_middleware` is not enabled, this is undefined.
2416
- *
2417
- * When `future.v8_middleware` is enabled, this is an instance of
2418
- * `RouterContextProvider` and can be used to access context values
2419
- * from your route middlewares. You may pass in initial context values in your
2420
- * `<HydratedRouter getContext>` prop
2421
- */
2422
- context: Readonly<RouterContextProvider>;
2423
- };
2424
- type ServerDataFunctionArgs<Params> = {
2425
- /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
2426
- request: Request;
2427
- /**
2428
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
2429
- * @example
2430
- * // app/routes.ts
2431
- * route("teams/:teamId", "./team.tsx"),
2432
- *
2433
- * // app/team.tsx
2434
- * export function loader({
2435
- * params,
2436
- * }: Route.LoaderArgs) {
2437
- * params.teamId;
2438
- * // ^ string
2439
- * }
2440
- **/
2441
- params: Params;
2442
- /**
2443
- * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
2444
- * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
2445
- */
2446
- unstable_pattern: string;
2447
- /**
2448
- * Without `future.v8_middleware` enabled, this is the context passed in
2449
- * to your server adapter's `getLoadContext` function. It's a way to bridge the
2450
- * gap between the adapter's request/response API with your React Router app.
2451
- * It is only applicable if you are using a custom server adapter.
2452
- *
2453
- * With `future.v8_middleware` enabled, this is an instance of
2454
- * `RouterContextProvider` and can be used for type-safe access to
2455
- * context value set in your route middlewares. If you are using a custom
2456
- * server adapter, you may provide an initial set of context values from your
2457
- * `getLoadContext` function.
2458
- */
2459
- context: MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : AppLoadContext;
2460
- };
2461
- type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
2462
- ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
2463
- ] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
2464
- type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
2465
- type IsHydrate<ClientLoader> = ClientLoader extends {
2466
- hydrate: true;
2467
- } ? true : ClientLoader extends {
2468
- hydrate: false;
2469
- } ? false : false;
2470
- type GetLoaderData<T extends RouteModule$1> = _DataLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
2471
- HydrateFallback: Func;
2472
- } ? true : false>;
2473
- type _DataLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
2474
- HasHydrateFallback,
2475
- ClientLoaderHydrate
2476
- ] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
2477
- IsDefined<ClientLoaderData>,
2478
- IsDefined<ServerLoaderData>
2479
- ] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
2480
- type GetActionData<T extends RouteModule$1> = _DataActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
2481
- type _DataActionData<ServerActionData, ClientActionData> = Awaited<[
2482
- IsDefined<ServerActionData>,
2483
- IsDefined<ClientActionData>
2484
- ] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
2485
-
2486
- interface RouteModules {
2487
- [routeId: string]: RouteModule | undefined;
2488
- }
2489
- /**
2490
- * The shape of a route module shipped to the client
2491
- */
2492
- interface RouteModule {
2493
- clientAction?: ClientActionFunction;
2494
- clientLoader?: ClientLoaderFunction;
2495
- clientMiddleware?: MiddlewareFunction<Record<string, DataStrategyResult>>[];
2496
- ErrorBoundary?: ErrorBoundaryComponent;
2497
- HydrateFallback?: HydrateFallbackComponent;
2498
- Layout?: LayoutComponent;
2499
- default: RouteComponent;
2500
- handle?: RouteHandle;
2501
- links?: LinksFunction;
2502
- meta?: MetaFunction;
2503
- shouldRevalidate?: ShouldRevalidateFunction;
2504
- }
2505
- /**
2506
- * The shape of a route module on the server
2507
- */
2508
- interface ServerRouteModule extends RouteModule {
2509
- action?: ActionFunction;
2510
- headers?: HeadersFunction | {
2511
- [name: string]: string;
2512
- };
2513
- loader?: LoaderFunction;
2514
- middleware?: MiddlewareFunction<Response>[];
2515
- }
2516
- /**
2517
- * A function that handles data mutations for a route on the client
2518
- */
2519
- type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<ActionFunction>;
2520
- /**
2521
- * Arguments passed to a route `clientAction` function
2522
- */
2523
- type ClientActionFunctionArgs = ActionFunctionArgs & {
2524
- serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
2525
- };
2526
- /**
2527
- * A function that loads data for a route on the client
2528
- */
2529
- type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
2530
- hydrate?: boolean;
2531
- };
2532
- /**
2533
- * Arguments passed to a route `clientLoader` function
2534
- */
2535
- type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
2536
- serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
2537
- };
2538
- /**
2539
- * ErrorBoundary to display for this route
2540
- */
2541
- type ErrorBoundaryComponent = ComponentType;
2542
- type HeadersArgs = {
2543
- loaderHeaders: Headers;
2544
- parentHeaders: Headers;
2545
- actionHeaders: Headers;
2546
- errorHeaders: Headers | undefined;
2547
- };
2548
- /**
2549
- * A function that returns HTTP headers to be used for a route. These headers
2550
- * will be merged with (and take precedence over) headers from parent routes.
2551
- */
2552
- interface HeadersFunction {
2553
- (args: HeadersArgs): Headers | HeadersInit;
2554
- }
2555
- /**
2556
- * `<Route HydrateFallback>` component to render on initial loads
2557
- * when client loaders are present
2558
- */
2559
- type HydrateFallbackComponent = ComponentType;
2560
- /**
2561
- * Optional, root-only `<Route Layout>` component to wrap the root content in.
2562
- * Useful for defining the <html>/<head>/<body> document shell shared by the
2563
- * Component, HydrateFallback, and ErrorBoundary
2564
- */
2565
- type LayoutComponent = ComponentType<{
2566
- children: ReactElement<unknown, ErrorBoundaryComponent | HydrateFallbackComponent | RouteComponent>;
2567
- }>;
2568
- /**
2569
- * A function that defines `<link>` tags to be inserted into the `<head>` of
2570
- * the document on route transitions.
2571
- *
2572
- * @see https://reactrouter.com/start/framework/route-module#meta
2573
- */
2574
- interface LinksFunction {
2575
- (): LinkDescriptor[];
2576
- }
2577
- interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
2578
- id: RouteId;
2579
- pathname: DataRouteMatch["pathname"];
2580
- /** @deprecated Use `MetaMatch.loaderData` instead */
2581
- data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
2582
- loaderData: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
2583
- handle?: RouteHandle;
2584
- params: DataRouteMatch["params"];
2585
- meta: MetaDescriptor[];
2586
- error?: unknown;
2587
- }
2588
- type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
2589
- [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
2590
- }[keyof MatchLoaders]>;
2591
- interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2592
- /** @deprecated Use `MetaArgs.loaderData` instead */
2593
- data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
2594
- loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
2595
- params: Params;
2596
- location: Location;
2597
- matches: MetaMatches<MatchLoaders>;
2598
- error?: unknown;
2599
- }
2600
- /**
2601
- * A function that returns an array of data objects to use for rendering
2602
- * metadata HTML tags in a route. These tags are not rendered on descendant
2603
- * routes in the route hierarchy. In other words, they will only be rendered on
2604
- * the route in which they are exported.
2605
- *
2606
- * @param Loader - The type of the current route's loader function
2607
- * @param MatchLoaders - Mapping from a parent route's filepath to its loader
2608
- * function type
2609
- *
2610
- * Note that parent route filepaths are relative to the `app/` directory.
2611
- *
2612
- * For example, if this meta function is for `/sales/customers/$customerId`:
2613
- *
2614
- * ```ts
2615
- * // app/root.tsx
2616
- * const loader = () => ({ hello: "world" })
2617
- * export type Loader = typeof loader
2618
- *
2619
- * // app/routes/sales.tsx
2620
- * const loader = () => ({ salesCount: 1074 })
2621
- * export type Loader = typeof loader
2622
- *
2623
- * // app/routes/sales/customers.tsx
2624
- * const loader = () => ({ customerCount: 74 })
2625
- * export type Loader = typeof loader
2626
- *
2627
- * // app/routes/sales/customers/$customersId.tsx
2628
- * import type { Loader as RootLoader } from "../../../root"
2629
- * import type { Loader as SalesLoader } from "../../sales"
2630
- * import type { Loader as CustomersLoader } from "../../sales/customers"
2631
- *
2632
- * const loader = () => ({ name: "Customer name" })
2633
- *
2634
- * const meta: MetaFunction<typeof loader, {
2635
- * "root": RootLoader,
2636
- * "routes/sales": SalesLoader,
2637
- * "routes/sales/customers": CustomersLoader,
2638
- * }> = ({ data, matches }) => {
2639
- * const { name } = data
2640
- * // ^? string
2641
- * const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").data
2642
- * // ^? number
2643
- * const { salesCount } = matches.find((match) => match.id === "routes/sales").data
2644
- * // ^? number
2645
- * const { hello } = matches.find((match) => match.id === "root").data
2646
- * // ^? "world"
2647
- * }
2648
- * ```
2649
- */
2650
- interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2651
- (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
2652
- }
2653
- type MetaDescriptor = {
2654
- charSet: "utf-8";
2655
- } | {
2656
- title: string;
2657
- } | {
2658
- name: string;
2659
- content: string;
2660
- } | {
2661
- property: string;
2662
- content: string;
2663
- } | {
2664
- httpEquiv: string;
2665
- content: string;
2666
- } | {
2667
- "script:ld+json": LdJsonObject;
2668
- } | {
2669
- tagName: "meta" | "link";
2670
- [name: string]: string;
2671
- } | {
2672
- [name: string]: unknown;
2673
- };
2674
- type LdJsonObject = {
2675
- [Key in string]: LdJsonValue;
2676
- } & {
2677
- [Key in string]?: LdJsonValue | undefined;
2678
- };
2679
- type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
2680
- type LdJsonPrimitive = string | number | boolean | null;
2681
- type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
2682
- /**
2683
- * A React component that is rendered for a route.
2684
- */
2685
- type RouteComponent = ComponentType<{}>;
2686
- /**
2687
- * An arbitrary object that is associated with a route.
2688
- *
2689
- * @see https://reactrouter.com/how-to/using-handle
2690
- */
2691
- type RouteHandle = unknown;
2692
-
2693
- type unstable_ServerInstrumentation = {
2694
- handler?: unstable_InstrumentRequestHandlerFunction;
2695
- route?: unstable_InstrumentRouteFunction;
2696
- };
2697
- type unstable_ClientInstrumentation = {
2698
- router?: unstable_InstrumentRouterFunction;
2699
- route?: unstable_InstrumentRouteFunction;
2700
- };
2701
- type unstable_InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
2702
- type unstable_InstrumentRouterFunction = (router: InstrumentableRouter) => void;
2703
- type unstable_InstrumentRouteFunction = (route: InstrumentableRoute) => void;
2704
- type unstable_InstrumentationHandlerResult = {
2705
- status: "success";
2706
- error: undefined;
2707
- } | {
2708
- status: "error";
2709
- error: Error;
2710
- };
2711
- type InstrumentFunction<T> = (handler: () => Promise<unstable_InstrumentationHandlerResult>, info: T) => Promise<void>;
2712
- type ReadonlyRequest = {
2713
- method: string;
2714
- url: string;
2715
- headers: Pick<Headers, "get">;
2716
- };
2717
- type ReadonlyContext = MiddlewareEnabled extends true ? Pick<RouterContextProvider, "get"> : Readonly<AppLoadContext>;
2718
- type InstrumentableRoute = {
2719
- id: string;
2720
- index: boolean | undefined;
2721
- path: string | undefined;
2722
- instrument(instrumentations: RouteInstrumentations): void;
2723
- };
2724
- type RouteInstrumentations = {
2725
- lazy?: InstrumentFunction<RouteLazyInstrumentationInfo>;
2726
- "lazy.loader"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
2727
- "lazy.action"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
2728
- "lazy.middleware"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
2729
- middleware?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
2730
- loader?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
2731
- action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
2732
- };
2733
- type RouteLazyInstrumentationInfo = undefined;
2734
- type RouteHandlerInstrumentationInfo = Readonly<{
2735
- request: ReadonlyRequest;
2736
- params: LoaderFunctionArgs["params"];
2737
- unstable_pattern: string;
2738
- context: ReadonlyContext;
2739
- }>;
2740
- type InstrumentableRouter = {
2741
- instrument(instrumentations: RouterInstrumentations): void;
2742
- };
2743
- type RouterInstrumentations = {
2744
- navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
2745
- fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
2746
- };
2747
- type RouterNavigationInstrumentationInfo = Readonly<{
2748
- to: string | number;
2749
- currentUrl: string;
2750
- formMethod?: HTMLFormMethod;
2751
- formEncType?: FormEncType;
2752
- formData?: FormData;
2753
- body?: any;
2754
- }>;
2755
- type RouterFetchInstrumentationInfo = Readonly<{
2756
- href: string;
2757
- currentUrl: string;
2758
- fetcherKey: string;
2759
- formMethod?: HTMLFormMethod;
2760
- formEncType?: FormEncType;
2761
- formData?: FormData;
2762
- body?: any;
2763
- }>;
2764
- type InstrumentableRequestHandler = {
2765
- instrument(instrumentations: RequestHandlerInstrumentations): void;
2766
- };
2767
- type RequestHandlerInstrumentations = {
2768
- request?: InstrumentFunction<RequestHandlerInstrumentationInfo>;
2769
- };
2770
- type RequestHandlerInstrumentationInfo = Readonly<{
2771
- request: ReadonlyRequest;
2772
- context: ReadonlyContext | undefined;
2773
- }>;
2774
-
2775
- /**
2776
- * A Router instance manages all navigation and data loading/mutations
2777
- */
2778
- interface Router {
2779
- /**
2780
- * @private
2781
- * PRIVATE - DO NOT USE
2782
- *
2783
- * Return the basename for the router
2784
- */
2785
- get basename(): RouterInit["basename"];
2786
- /**
2787
- * @private
2788
- * PRIVATE - DO NOT USE
2789
- *
2790
- * Return the future config for the router
2791
- */
2792
- get future(): FutureConfig;
2793
- /**
2794
- * @private
2795
- * PRIVATE - DO NOT USE
2796
- *
2797
- * Return the current state of the router
2798
- */
2799
- get state(): RouterState;
2800
- /**
2801
- * @private
2802
- * PRIVATE - DO NOT USE
2803
- *
2804
- * Return the routes for this router instance
2805
- */
2806
- get routes(): AgnosticDataRouteObject[];
2807
- /**
2808
- * @private
2809
- * PRIVATE - DO NOT USE
2810
- *
2811
- * Return the window associated with the router
2812
- */
2813
- get window(): RouterInit["window"];
2814
- /**
2815
- * @private
2816
- * PRIVATE - DO NOT USE
2817
- *
2818
- * Initialize the router, including adding history listeners and kicking off
2819
- * initial data fetches. Returns a function to cleanup listeners and abort
2820
- * any in-progress loads
2821
- */
2822
- initialize(): Router;
2823
- /**
2824
- * @private
2825
- * PRIVATE - DO NOT USE
2826
- *
2827
- * Subscribe to router.state updates
2828
- *
2829
- * @param fn function to call with the new state
2830
- */
2831
- subscribe(fn: RouterSubscriber): () => void;
2832
- /**
2833
- * @private
2834
- * PRIVATE - DO NOT USE
2835
- *
2836
- * Enable scroll restoration behavior in the router
2837
- *
2838
- * @param savedScrollPositions Object that will manage positions, in case
2839
- * it's being restored from sessionStorage
2840
- * @param getScrollPosition Function to get the active Y scroll position
2841
- * @param getKey Function to get the key to use for restoration
2842
- */
2843
- enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
2844
- /**
2845
- * @private
2846
- * PRIVATE - DO NOT USE
2847
- *
2848
- * Navigate forward/backward in the history stack
2849
- * @param to Delta to move in the history stack
2850
- */
2851
- navigate(to: number): Promise<void>;
2852
- /**
2853
- * Navigate to the given path
2854
- * @param to Path to navigate to
2855
- * @param opts Navigation options (method, submission, etc.)
2856
- */
2857
- navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
2858
- /**
2859
- * @private
2860
- * PRIVATE - DO NOT USE
2861
- *
2862
- * Trigger a fetcher load/submission
2863
- *
2864
- * @param key Fetcher key
2865
- * @param routeId Route that owns the fetcher
2866
- * @param href href to fetch
2867
- * @param opts Fetcher options, (method, submission, etc.)
2868
- */
2869
- fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
2870
- /**
2871
- * @private
2872
- * PRIVATE - DO NOT USE
2873
- *
2874
- * Trigger a revalidation of all current route loaders and fetcher loads
2875
- */
2876
- revalidate(): Promise<void>;
2877
- /**
2878
- * @private
2879
- * PRIVATE - DO NOT USE
2880
- *
2881
- * Utility function to create an href for the given location
2882
- * @param location
2883
- */
2884
- createHref(location: Location | URL): string;
2885
- /**
2886
- * @private
2887
- * PRIVATE - DO NOT USE
2888
- *
2889
- * Utility function to URL encode a destination path according to the internal
2890
- * history implementation
2891
- * @param to
2892
- */
2893
- encodeLocation(to: To): Path;
2894
- /**
2895
- * @private
2896
- * PRIVATE - DO NOT USE
2897
- *
2898
- * Get/create a fetcher for the given key
2899
- * @param key
2900
- */
2901
- getFetcher<TData = any>(key: string): Fetcher<TData>;
2902
- /**
2903
- * @internal
2904
- * PRIVATE - DO NOT USE
2905
- *
2906
- * Reset the fetcher for a given key
2907
- * @param key
2908
- */
2909
- resetFetcher(key: string, opts?: {
2910
- reason?: unknown;
2911
- }): void;
2912
- /**
2913
- * @private
2914
- * PRIVATE - DO NOT USE
2915
- *
2916
- * Delete the fetcher for a given key
2917
- * @param key
2918
- */
2919
- deleteFetcher(key: string): void;
2920
- /**
2921
- * @private
2922
- * PRIVATE - DO NOT USE
2923
- *
2924
- * Cleanup listeners and abort any in-progress loads
2925
- */
2926
- dispose(): void;
2927
- /**
2928
- * @private
2929
- * PRIVATE - DO NOT USE
2930
- *
2931
- * Get a navigation blocker
2932
- * @param key The identifier for the blocker
2933
- * @param fn The blocker function implementation
2934
- */
2935
- getBlocker(key: string, fn: BlockerFunction): Blocker;
2936
- /**
2937
- * @private
2938
- * PRIVATE - DO NOT USE
2939
- *
2940
- * Delete a navigation blocker
2941
- * @param key The identifier for the blocker
2942
- */
2943
- deleteBlocker(key: string): void;
2944
- /**
2945
- * @private
2946
- * PRIVATE DO NOT USE
2947
- *
2948
- * Patch additional children routes into an existing parent route
2949
- * @param routeId The parent route id or a callback function accepting `patch`
2950
- * to perform batch patching
2951
- * @param children The additional children routes
2952
- * @param unstable_allowElementMutations Allow mutation or route elements on
2953
- * existing routes. Intended for RSC-usage
2954
- * only.
2955
- */
2956
- patchRoutes(routeId: string | null, children: AgnosticRouteObject[], unstable_allowElementMutations?: boolean): void;
2957
- /**
2958
- * @private
2959
- * PRIVATE - DO NOT USE
2960
- *
2961
- * HMR needs to pass in-flight route updates to React Router
2962
- * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
2963
- */
2964
- _internalSetRoutes(routes: AgnosticRouteObject[]): void;
2965
- /**
2966
- * @private
2967
- * PRIVATE - DO NOT USE
2968
- *
2969
- * Cause subscribers to re-render. This is used to force a re-render.
2970
- */
2971
- _internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
2972
- /**
2973
- * @private
2974
- * PRIVATE - DO NOT USE
2975
- *
2976
- * Internal fetch AbortControllers accessed by unit tests
2977
- */
2978
- _internalFetchControllers: Map<string, AbortController>;
2979
- }
2980
- /**
2981
- * State maintained internally by the router. During a navigation, all states
2982
- * reflect the "old" location unless otherwise noted.
2983
- */
2984
- interface RouterState {
2985
- /**
2986
- * The action of the most recent navigation
2987
- */
2988
- historyAction: Action;
2989
- /**
2990
- * The current location reflected by the router
2991
- */
2992
- location: Location;
2993
- /**
2994
- * The current set of route matches
2995
- */
2996
- matches: AgnosticDataRouteMatch[];
2997
- /**
2998
- * Tracks whether we've completed our initial data load
2999
- */
3000
- initialized: boolean;
3001
- /**
3002
- * Tracks whether we should be rendering a HydrateFallback during hydration
3003
- */
3004
- renderFallback: boolean;
3005
- /**
3006
- * Current scroll position we should start at for a new view
3007
- * - number -> scroll position to restore to
3008
- * - false -> do not restore scroll at all (used during submissions/revalidations)
3009
- * - null -> don't have a saved position, scroll to hash or top of page
3010
- */
3011
- restoreScrollPosition: number | false | null;
3012
- /**
3013
- * Indicate whether this navigation should skip resetting the scroll position
3014
- * if we are unable to restore the scroll position
3015
- */
3016
- preventScrollReset: boolean;
3017
- /**
3018
- * Tracks the state of the current navigation
3019
- */
3020
- navigation: Navigation;
3021
- /**
3022
- * Tracks any in-progress revalidations
3023
- */
3024
- revalidation: RevalidationState;
3025
- /**
3026
- * Data from the loaders for the current matches
3027
- */
3028
- loaderData: RouteData;
3029
- /**
3030
- * Data from the action for the current matches
3031
- */
3032
- actionData: RouteData | null;
3033
- /**
3034
- * Errors caught from loaders for the current matches
3035
- */
3036
- errors: RouteData | null;
3037
- /**
3038
- * Map of current fetchers
3039
- */
3040
- fetchers: Map<string, Fetcher>;
3041
- /**
3042
- * Map of current blockers
3043
- */
3044
- blockers: Map<string, Blocker>;
3045
- }
3046
- /**
3047
- * Data that can be passed into hydrate a Router from SSR
3048
- */
3049
- type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
3050
- /**
3051
- * Future flags to toggle new feature behavior
3052
- */
3053
- interface FutureConfig {
3054
- }
3055
- /**
3056
- * Initialization options for createRouter
3057
- */
3058
- interface RouterInit {
3059
- routes: AgnosticRouteObject[];
3060
- history: History;
3061
- basename?: string;
3062
- getContext?: () => MaybePromise<RouterContextProvider>;
3063
- unstable_instrumentations?: unstable_ClientInstrumentation[];
3064
- mapRouteProperties?: MapRoutePropertiesFunction;
3065
- future?: Partial<FutureConfig>;
3066
- hydrationRouteProperties?: string[];
3067
- hydrationData?: HydrationState;
3068
- window?: Window;
3069
- dataStrategy?: DataStrategyFunction;
3070
- patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
3071
- }
3072
- /**
3073
- * State returned from a server-side query() call
3074
- */
3075
- interface StaticHandlerContext {
3076
- basename: Router["basename"];
3077
- location: RouterState["location"];
3078
- matches: RouterState["matches"];
3079
- loaderData: RouterState["loaderData"];
3080
- actionData: RouterState["actionData"];
3081
- errors: RouterState["errors"];
3082
- statusCode: number;
3083
- loaderHeaders: Record<string, Headers>;
3084
- actionHeaders: Record<string, Headers>;
3085
- _deepestRenderedBoundaryId?: string | null;
3086
- }
3087
- /**
3088
- * A StaticHandler instance manages a singular SSR navigation/fetch event
3089
- */
3090
- interface StaticHandler {
3091
- dataRoutes: AgnosticDataRouteObject[];
3092
- query(request: Request, opts?: {
3093
- requestContext?: unknown;
3094
- filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
3095
- skipLoaderErrorBubbling?: boolean;
3096
- skipRevalidation?: boolean;
3097
- dataStrategy?: DataStrategyFunction<unknown>;
3098
- generateMiddlewareResponse?: (query: (r: Request, args?: {
3099
- filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
3100
- }) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
3101
- }): Promise<StaticHandlerContext | Response>;
3102
- queryRoute(request: Request, opts?: {
3103
- routeId?: string;
3104
- requestContext?: unknown;
3105
- dataStrategy?: DataStrategyFunction<unknown>;
3106
- generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
3107
- }): Promise<any>;
3108
- }
3109
- type ViewTransitionOpts = {
3110
- currentLocation: Location;
3111
- nextLocation: Location;
3112
- };
3113
- /**
3114
- * Subscriber function signature for changes to router state
3115
- */
3116
- interface RouterSubscriber {
3117
- (state: RouterState, opts: {
3118
- deletedFetchers: string[];
3119
- newErrors: RouteData | null;
3120
- viewTransitionOpts?: ViewTransitionOpts;
3121
- flushSync: boolean;
3122
- }): void;
3123
- }
3124
- /**
3125
- * Function signature for determining the key to be used in scroll restoration
3126
- * for a given location
3127
- */
3128
- interface GetScrollRestorationKeyFunction {
3129
- (location: Location, matches: UIMatch[]): string | null;
3130
- }
3131
- /**
3132
- * Function signature for determining the current scroll position
3133
- */
3134
- interface GetScrollPositionFunction {
3135
- (): number;
3136
- }
3137
- /**
3138
- * - "route": relative to the route hierarchy so `..` means remove all segments
3139
- * of the current route even if it has many. For example, a `route("posts/:id")`
3140
- * would have both `:id` and `posts` removed from the url.
3141
- * - "path": relative to the pathname so `..` means remove one segment of the
3142
- * pathname. For example, a `route("posts/:id")` would have only `:id` removed
3143
- * from the url.
3144
- */
3145
- type RelativeRoutingType = "route" | "path";
3146
- type BaseNavigateOrFetchOptions = {
3147
- preventScrollReset?: boolean;
3148
- relative?: RelativeRoutingType;
3149
- flushSync?: boolean;
3150
- unstable_defaultShouldRevalidate?: boolean;
3151
- };
3152
- type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
3153
- replace?: boolean;
3154
- state?: any;
3155
- fromRouteId?: string;
3156
- viewTransition?: boolean;
3157
- unstable_mask?: To;
3158
- };
3159
- type BaseSubmissionOptions = {
3160
- formMethod?: HTMLFormMethod;
3161
- formEncType?: FormEncType;
3162
- } & ({
3163
- formData: FormData;
3164
- body?: undefined;
3165
- } | {
3166
- formData?: undefined;
3167
- body: any;
3168
- });
3169
- /**
3170
- * Options for a navigate() call for a normal (non-submission) navigation
3171
- */
3172
- type LinkNavigateOptions = BaseNavigateOptions;
3173
- /**
3174
- * Options for a navigate() call for a submission navigation
3175
- */
3176
- type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
3177
- /**
3178
- * Options to pass to navigate() for a navigation
3179
- */
3180
- type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
3181
- /**
3182
- * Options for a fetch() load
3183
- */
3184
- type LoadFetchOptions = BaseNavigateOrFetchOptions;
3185
- /**
3186
- * Options for a fetch() submission
3187
- */
3188
- type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
3189
- /**
3190
- * Options to pass to fetch()
3191
- */
3192
- type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
3193
- /**
3194
- * Potential states for state.navigation
3195
- */
3196
- type NavigationStates = {
3197
- Idle: {
3198
- state: "idle";
3199
- location: undefined;
3200
- formMethod: undefined;
3201
- formAction: undefined;
3202
- formEncType: undefined;
3203
- formData: undefined;
3204
- json: undefined;
3205
- text: undefined;
3206
- };
3207
- Loading: {
3208
- state: "loading";
3209
- location: Location;
3210
- formMethod: Submission["formMethod"] | undefined;
3211
- formAction: Submission["formAction"] | undefined;
3212
- formEncType: Submission["formEncType"] | undefined;
3213
- formData: Submission["formData"] | undefined;
3214
- json: Submission["json"] | undefined;
3215
- text: Submission["text"] | undefined;
3216
- };
3217
- Submitting: {
3218
- state: "submitting";
3219
- location: Location;
3220
- formMethod: Submission["formMethod"];
3221
- formAction: Submission["formAction"];
3222
- formEncType: Submission["formEncType"];
3223
- formData: Submission["formData"];
3224
- json: Submission["json"];
3225
- text: Submission["text"];
3226
- };
3227
- };
3228
- type Navigation = NavigationStates[keyof NavigationStates];
3229
- type RevalidationState = "idle" | "loading";
3230
- /**
3231
- * Potential states for fetchers
3232
- */
3233
- type FetcherStates<TData = any> = {
3234
- /**
3235
- * The fetcher is not calling a loader or action
3236
- *
3237
- * ```tsx
3238
- * fetcher.state === "idle"
3239
- * ```
3240
- */
3241
- Idle: {
3242
- state: "idle";
3243
- formMethod: undefined;
3244
- formAction: undefined;
3245
- formEncType: undefined;
3246
- text: undefined;
3247
- formData: undefined;
3248
- json: undefined;
3249
- /**
3250
- * If the fetcher has never been called, this will be undefined.
3251
- */
3252
- data: TData | undefined;
3253
- };
3254
- /**
3255
- * The fetcher is loading data from a {@link LoaderFunction | loader} from a
3256
- * call to {@link FetcherWithComponents.load | `fetcher.load`}.
3257
- *
3258
- * ```tsx
3259
- * // somewhere
3260
- * <button onClick={() => fetcher.load("/some/route") }>Load</button>
3261
- *
3262
- * // the state will update
3263
- * fetcher.state === "loading"
3264
- * ```
3265
- */
3266
- Loading: {
3267
- state: "loading";
3268
- formMethod: Submission["formMethod"] | undefined;
3269
- formAction: Submission["formAction"] | undefined;
3270
- formEncType: Submission["formEncType"] | undefined;
3271
- text: Submission["text"] | undefined;
3272
- formData: Submission["formData"] | undefined;
3273
- json: Submission["json"] | undefined;
3274
- data: TData | undefined;
3275
- };
3276
- /**
3277
- The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
3278
-
3279
- ```tsx
3280
- // somewhere
3281
- <input
3282
- onChange={e => {
3283
- fetcher.submit(event.currentTarget.form, { method: "post" });
3284
- }}
3285
- />
3286
-
3287
- // the state will update
3288
- fetcher.state === "submitting"
3289
-
3290
- // and formData will be available
3291
- fetcher.formData
3292
- ```
3293
- */
3294
- Submitting: {
3295
- state: "submitting";
3296
- formMethod: Submission["formMethod"];
3297
- formAction: Submission["formAction"];
3298
- formEncType: Submission["formEncType"];
3299
- text: Submission["text"];
3300
- formData: Submission["formData"];
3301
- json: Submission["json"];
3302
- data: TData | undefined;
3303
- };
3304
- };
3305
- type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
3306
- interface BlockerBlocked {
3307
- state: "blocked";
3308
- reset: () => void;
3309
- proceed: () => void;
3310
- location: Location;
3311
- }
3312
- interface BlockerUnblocked {
3313
- state: "unblocked";
3314
- reset: undefined;
3315
- proceed: undefined;
3316
- location: undefined;
3317
- }
3318
- interface BlockerProceeding {
3319
- state: "proceeding";
3320
- reset: undefined;
3321
- proceed: undefined;
3322
- location: Location;
3323
- }
3324
- type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
3325
- type BlockerFunction = (args: {
3326
- currentLocation: Location;
3327
- nextLocation: Location;
3328
- historyAction: Action;
3329
- }) => boolean;
3330
- declare const IDLE_NAVIGATION: NavigationStates["Idle"];
3331
- declare const IDLE_FETCHER: FetcherStates["Idle"];
3332
- declare const IDLE_BLOCKER: BlockerUnblocked;
3333
- /**
3334
- * Create a router and listen to history POP navigations
3335
- */
3336
- declare function createRouter(init: RouterInit): Router;
3337
- interface CreateStaticHandlerOptions {
3338
- basename?: string;
3339
- mapRouteProperties?: MapRoutePropertiesFunction;
3340
- unstable_instrumentations?: Pick<unstable_ServerInstrumentation, "route">[];
3341
- future?: {};
3342
- }
3343
-
3344
- export { type NonIndexRouteObject as $, type ActionFunction as A, type BlockerFunction as B, type ClientActionFunction as C, type DataStrategyResult as D, type Path as E, type Func as F, type GetLoaderData as G, type HeadersFunction as H, type PathPattern as I, type PathMatch as J, type Navigation as K, type Location as L, type MetaFunction as M, type Normalize as N, Action as O, type Params as P, type RouteObject as Q, type RouteModule$1 as R, type ShouldRevalidateFunction as S, type To as T, type UIMatch as U, type InitialEntry as V, type HydrationState as W, type IndexRouteObject as X, type RouteComponentType as Y, type HydrateFallbackType as Z, type ErrorBoundaryType as _, type ClientLoaderFunction as a, type RouterProps as a$, type Equal as a0, type RouterState as a1, type PatchRoutesOnNavigationFunction as a2, type DataRouteObject as a3, type StaticHandler as a4, type GetScrollPositionFunction as a5, type GetScrollRestorationKeyFunction as a6, type StaticHandlerContext as a7, type Fetcher as a8, type NavigationStates as a9, type unstable_InstrumentationHandlerResult as aA, IDLE_NAVIGATION as aB, IDLE_FETCHER as aC, IDLE_BLOCKER as aD, data as aE, generatePath as aF, isRouteErrorResponse as aG, matchPath as aH, matchRoutes as aI, redirect as aJ, redirectDocument as aK, replace as aL, resolvePath as aM, type DataRouteMatch as aN, type Navigator as aO, type PatchRoutesOnNavigationFunctionArgs as aP, type RouteMatch as aQ, AwaitContextProvider as aR, type AwaitProps as aS, type IndexRouteProps as aT, type LayoutRouteProps as aU, type MemoryRouterOpts as aV, type MemoryRouterProps as aW, type NavigateProps as aX, type OutletProps as aY, type PathRouteProps as aZ, type RouteProps as a_, type RouterSubscriber as aa, type RouterNavigateOptions as ab, type RouterFetchOptions as ac, type RevalidationState as ad, type ActionFunctionArgs as ae, type DataStrategyFunctionArgs as af, type DataStrategyMatch as ag, DataWithResponseInit as ah, type ErrorResponse as ai, type FormEncType as aj, type FormMethod as ak, type HTMLFormMethod as al, type LazyRouteFunction as am, type LoaderFunctionArgs as an, type MiddlewareFunction as ao, type PathParam as ap, type RedirectFunction as aq, type RouterContext as ar, type ShouldRevalidateFunctionArgs as as, createContext as at, createPath as au, parsePath as av, type unstable_ServerInstrumentation as aw, type unstable_InstrumentRequestHandlerFunction as ax, type unstable_InstrumentRouterFunction as ay, type unstable_InstrumentRouteFunction as az, type LinksFunction as b, type RoutesProps as b0, Await as b1, MemoryRouter as b2, Navigate as b3, Outlet as b4, Route as b5, Router$1 as b6, RouterProvider as b7, Routes as b8, createMemoryRouter as b9, WithComponentProps as bA, withComponentProps as bB, WithHydrateFallbackProps as bC, withHydrateFallbackProps as bD, WithErrorBoundaryProps as bE, withErrorBoundaryProps as bF, type RouteManifest as bG, type ServerRouteModule as bH, type History as bI, type FutureConfig as bJ, type CreateStaticHandlerOptions as bK, createRoutesFromChildren as ba, createRoutesFromElements as bb, renderMatches as bc, type ClientActionFunctionArgs as bd, type ClientLoaderFunctionArgs as be, type HeadersArgs as bf, type MetaArgs as bg, type PageLinkDescriptor as bh, type HtmlLinkDescriptor as bi, type Future as bj, type unstable_SerializesTo as bk, createMemoryHistory as bl, createBrowserHistory as bm, createHashHistory as bn, invariant as bo, createRouter as bp, ErrorResponseImpl as bq, DataRouterContext as br, DataRouterStateContext as bs, FetchersContext as bt, LocationContext as bu, NavigationContext as bv, RouteContext as bw, ViewTransitionContext as bx, hydrationRouteProperties as by, mapRouteProperties as bz, RouterContextProvider as c, type LoaderFunction as d, type RouterInit as e, type RouterProviderProps as f, type ClientOnErrorFunction as g, type LinkDescriptor as h, type Pretty as i, type MetaDescriptor as j, type ServerDataFunctionArgs as k, type MiddlewareNextFunction as l, type ClientDataFunctionArgs as m, type ServerDataFrom as n, type GetActionData as o, type Router as p, type RouteModules as q, type DataStrategyFunction as r, type MiddlewareEnabled as s, type AppLoadContext as t, type unstable_ClientInstrumentation as u, type NavigateOptions as v, type Blocker as w, type SerializeFrom as x, type RelativeRoutingType as y, type ParamParseKey as z };