react-router 7.7.0 → 7.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +11 -23
  2. package/dist/development/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  3. package/dist/development/{chunk-EF7DTUVF.mjs → chunk-C37GKA54.mjs} +83 -80
  4. package/dist/development/{chunk-V6PEDDZI.js → chunk-K7YFBME3.js} +79 -76
  5. package/dist/{production/chunk-GNZILI6H.mjs → development/chunk-KIUJAIYX.mjs} +3 -5
  6. package/dist/{production/chunk-2TYFPE3B.js → development/chunk-R73PQUJU.js} +132 -132
  7. package/dist/development/components-CjQijYga.d.mts +802 -0
  8. package/dist/development/dom-export.d.mts +13 -6
  9. package/dist/development/dom-export.d.ts +10 -3
  10. package/dist/development/dom-export.js +3 -3
  11. package/dist/development/dom-export.mjs +3 -3
  12. package/dist/development/index-react-server-client-Bi_fx8qz.d.ts +3163 -0
  13. package/dist/development/index-react-server-client-KLg-U4nr.d.mts +2366 -0
  14. package/dist/development/index-react-server-client.d.mts +3 -3
  15. package/dist/development/index-react-server-client.d.ts +2 -2
  16. package/dist/development/index-react-server-client.js +4 -4
  17. package/dist/development/index-react-server-client.mjs +2 -2
  18. package/dist/development/index-react-server.d.mts +109 -2
  19. package/dist/development/index-react-server.d.ts +109 -2
  20. package/dist/development/index-react-server.js +28 -20
  21. package/dist/development/index-react-server.mjs +29 -21
  22. package/dist/development/index.d.mts +918 -287
  23. package/dist/development/index.d.ts +1010 -283
  24. package/dist/development/index.js +98 -100
  25. package/dist/development/index.mjs +3 -3
  26. package/dist/development/lib/types/internal.d.mts +1 -1
  27. package/dist/development/lib/types/internal.d.ts +1 -1
  28. package/dist/development/lib/types/internal.js +1 -1
  29. package/dist/development/lib/types/internal.mjs +1 -1
  30. package/dist/{production/route-data-DjzmHYNR.d.mts → development/route-data-CqEmXQub.d.mts} +48 -2
  31. package/dist/{production/routeModules-g5PTiDfO.d.ts → development/routeModules-BR2FO0ix.d.ts} +48 -2
  32. package/dist/production/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  33. package/dist/{development/chunk-4ADB4KIO.js → production/chunk-4DGLNKXF.js} +132 -132
  34. package/dist/production/{chunk-5KHO4FML.js → chunk-7OQROU2D.js} +79 -76
  35. package/dist/production/{chunk-WPPIQDYG.mjs → chunk-IZ57JD2V.mjs} +83 -80
  36. package/dist/{development/chunk-T3VM44WY.mjs → production/chunk-K3SBCRK4.mjs} +3 -5
  37. package/dist/production/components-CjQijYga.d.mts +802 -0
  38. package/dist/production/dom-export.d.mts +13 -6
  39. package/dist/production/dom-export.d.ts +10 -3
  40. package/dist/production/dom-export.js +3 -3
  41. package/dist/production/dom-export.mjs +3 -3
  42. package/dist/production/index-react-server-client-Bi_fx8qz.d.ts +3163 -0
  43. package/dist/production/index-react-server-client-KLg-U4nr.d.mts +2366 -0
  44. package/dist/production/index-react-server-client.d.mts +3 -3
  45. package/dist/production/index-react-server-client.d.ts +2 -2
  46. package/dist/production/index-react-server-client.js +4 -4
  47. package/dist/production/index-react-server-client.mjs +2 -2
  48. package/dist/production/index-react-server.d.mts +109 -2
  49. package/dist/production/index-react-server.d.ts +109 -2
  50. package/dist/production/index-react-server.js +28 -20
  51. package/dist/production/index-react-server.mjs +29 -21
  52. package/dist/production/index.d.mts +918 -287
  53. package/dist/production/index.d.ts +1010 -283
  54. package/dist/production/index.js +98 -100
  55. package/dist/production/index.mjs +3 -3
  56. package/dist/production/lib/types/internal.d.mts +1 -1
  57. package/dist/production/lib/types/internal.d.ts +1 -1
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/{development/route-data-DjzmHYNR.d.mts → production/route-data-CqEmXQub.d.mts} +48 -2
  61. package/dist/{development/routeModules-g5PTiDfO.d.ts → production/routeModules-BR2FO0ix.d.ts} +48 -2
  62. package/package.json +1 -1
  63. package/dist/development/components-DzqPLVI1.d.mts +0 -464
  64. package/dist/development/index-react-server-client-CUidsuu_.d.mts +0 -1360
  65. package/dist/development/index-react-server-client-kY8DvDF3.d.ts +0 -1819
  66. package/dist/production/components-DzqPLVI1.d.mts +0 -464
  67. package/dist/production/index-react-server-client-CUidsuu_.d.mts +0 -1360
  68. package/dist/production/index-react-server-client-kY8DvDF3.d.ts +0 -1819
@@ -0,0 +1,2366 @@
1
+ import './components-CjQijYga.mjs';
2
+ import * as React from 'react';
3
+ import { a_ as RouteManifest, a$ as ServerRouteModule, Y as MiddlewareEnabled, u as unstable_RouterContextProvider, X as AppLoadContext, ak as LoaderFunctionArgs, ab as ActionFunctionArgs, y as RouteModules, a4 as StaticHandlerContext, H as HydrationState, a0 as DataRouteObject, j as ClientLoaderFunction, aj as HTMLFormMethod, ah as FormEncType, a as RelativeRoutingType, aL as PageLinkDescriptor, T as To, b0 as History, a3 as GetScrollRestorationKeyFunction, e as RouterInit, F as FutureConfig$1, D as DataStrategyFunction, P as PatchRoutesOnNavigationFunction, z as NavigateOptions, a5 as Fetcher, f as RouteObject, R as Router, J as SerializeFrom, B as BlockerFunction, c as Location, b1 as CreateStaticHandlerOptions$1, a1 as StaticHandler } from './route-data-CqEmXQub.mjs';
4
+
5
+ type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
6
+ interface ServerRoute extends Route {
7
+ children: ServerRoute[];
8
+ module: ServerRouteModule;
9
+ }
10
+
11
+ type OptionalCriticalCss = CriticalCss | undefined;
12
+ /**
13
+ * The output of the compiler for the server build.
14
+ */
15
+ interface ServerBuild {
16
+ entry: {
17
+ module: ServerEntryModule;
18
+ };
19
+ routes: ServerRouteManifest;
20
+ assets: AssetsManifest;
21
+ basename?: string;
22
+ publicPath: string;
23
+ assetsBuildDirectory: string;
24
+ future: FutureConfig;
25
+ ssr: boolean;
26
+ unstable_getCriticalCss?: (args: {
27
+ pathname: string;
28
+ }) => OptionalCriticalCss | Promise<OptionalCriticalCss>;
29
+ /**
30
+ * @deprecated This is now done via a custom header during prerendering
31
+ */
32
+ isSpaMode: boolean;
33
+ prerender: string[];
34
+ routeDiscovery: {
35
+ mode: "lazy" | "initial";
36
+ manifestPath: string;
37
+ };
38
+ }
39
+ interface HandleDocumentRequestFunction {
40
+ (request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext): Promise<Response> | Response;
41
+ }
42
+ interface HandleDataRequestFunction {
43
+ (response: Response, args: LoaderFunctionArgs | ActionFunctionArgs): Promise<Response> | Response;
44
+ }
45
+ interface HandleErrorFunction {
46
+ (error: unknown, args: LoaderFunctionArgs | ActionFunctionArgs): void;
47
+ }
48
+ /**
49
+ * A module that serves as the entry point for a Remix app during server
50
+ * rendering.
51
+ */
52
+ interface ServerEntryModule {
53
+ default: HandleDocumentRequestFunction;
54
+ handleDataRequest?: HandleDataRequestFunction;
55
+ handleError?: HandleErrorFunction;
56
+ streamTimeout?: number;
57
+ }
58
+
59
+ type SerializedError = {
60
+ message: string;
61
+ stack?: string;
62
+ };
63
+ interface FrameworkContextObject {
64
+ manifest: AssetsManifest;
65
+ routeModules: RouteModules;
66
+ criticalCss?: CriticalCss;
67
+ serverHandoffString?: string;
68
+ future: FutureConfig;
69
+ ssr: boolean;
70
+ isSpaMode: boolean;
71
+ routeDiscovery: ServerBuild["routeDiscovery"];
72
+ serializeError?(error: Error): SerializedError;
73
+ renderMeta?: {
74
+ didRenderScripts?: boolean;
75
+ streamCache?: Record<number, Promise<void> & {
76
+ result?: {
77
+ done: boolean;
78
+ value: string;
79
+ };
80
+ error?: unknown;
81
+ }>;
82
+ };
83
+ }
84
+ interface EntryContext extends FrameworkContextObject {
85
+ staticHandlerContext: StaticHandlerContext;
86
+ serverHandoffStream?: ReadableStream<Uint8Array>;
87
+ }
88
+ interface FutureConfig {
89
+ unstable_subResourceIntegrity: boolean;
90
+ unstable_middleware: boolean;
91
+ }
92
+ type CriticalCss = string | {
93
+ rel: "stylesheet";
94
+ href: string;
95
+ };
96
+ interface AssetsManifest {
97
+ entry: {
98
+ imports: string[];
99
+ module: string;
100
+ };
101
+ routes: RouteManifest<EntryRoute>;
102
+ url: string;
103
+ version: string;
104
+ hmr?: {
105
+ timestamp?: number;
106
+ runtime: string;
107
+ };
108
+ sri?: Record<string, string> | true;
109
+ }
110
+
111
+ interface Route {
112
+ index?: boolean;
113
+ caseSensitive?: boolean;
114
+ id: string;
115
+ parentId?: string;
116
+ path?: string;
117
+ }
118
+ interface EntryRoute extends Route {
119
+ hasAction: boolean;
120
+ hasLoader: boolean;
121
+ hasClientAction: boolean;
122
+ hasClientLoader: boolean;
123
+ hasClientMiddleware: boolean;
124
+ hasErrorBoundary: boolean;
125
+ imports?: string[];
126
+ css?: string[];
127
+ module: string;
128
+ clientActionModule: string | undefined;
129
+ clientLoaderModule: string | undefined;
130
+ clientMiddlewareModule: string | undefined;
131
+ hydrateFallbackModule: string | undefined;
132
+ parentId?: string;
133
+ }
134
+ declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, ssr: boolean, isSpaMode: boolean): DataRouteObject[];
135
+ declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, ssr: boolean, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
136
+ declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
137
+
138
+ type ParamKeyValuePair = [string, string];
139
+ type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
140
+ /**
141
+ Creates a URLSearchParams object using the given initializer.
142
+
143
+ This is identical to `new URLSearchParams(init)` except it also
144
+ supports arrays as values in the object form of the initializer
145
+ instead of just strings. This is convenient when you need multiple
146
+ values for a given key, but don't want to use an array initializer.
147
+
148
+ For example, instead of:
149
+
150
+ ```tsx
151
+ let searchParams = new URLSearchParams([
152
+ ['sort', 'name'],
153
+ ['sort', 'price']
154
+ ]);
155
+ ```
156
+ you can do:
157
+
158
+ ```
159
+ let searchParams = createSearchParams({
160
+ sort: ['name', 'price']
161
+ });
162
+ ```
163
+
164
+ @category Utils
165
+ */
166
+ declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
167
+ type JsonObject = {
168
+ [Key in string]: JsonValue;
169
+ } & {
170
+ [Key in string]?: JsonValue | undefined;
171
+ };
172
+ type JsonArray = JsonValue[] | readonly JsonValue[];
173
+ type JsonPrimitive = string | number | boolean | null;
174
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
175
+ type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
176
+ /**
177
+ * Submit options shared by both navigations and fetchers
178
+ */
179
+ interface SharedSubmitOptions {
180
+ /**
181
+ * The HTTP method used to submit the form. Overrides `<form method>`.
182
+ * Defaults to "GET".
183
+ */
184
+ method?: HTMLFormMethod;
185
+ /**
186
+ * The action URL path used to submit the form. Overrides `<form action>`.
187
+ * Defaults to the path of the current route.
188
+ */
189
+ action?: string;
190
+ /**
191
+ * The encoding used to submit the form. Overrides `<form encType>`.
192
+ * Defaults to "application/x-www-form-urlencoded".
193
+ */
194
+ encType?: FormEncType;
195
+ /**
196
+ * Determines whether the form action is relative to the route hierarchy or
197
+ * the pathname. Use this if you want to opt out of navigating the route
198
+ * hierarchy and want to instead route based on /-delimited URL segments
199
+ */
200
+ relative?: RelativeRoutingType;
201
+ /**
202
+ * In browser-based environments, prevent resetting scroll after this
203
+ * navigation when using the <ScrollRestoration> component
204
+ */
205
+ preventScrollReset?: boolean;
206
+ /**
207
+ * Enable flushSync for this submission's state updates
208
+ */
209
+ flushSync?: boolean;
210
+ }
211
+ /**
212
+ * Submit options available to fetchers
213
+ */
214
+ interface FetcherSubmitOptions extends SharedSubmitOptions {
215
+ }
216
+ /**
217
+ * Submit options available to navigations
218
+ */
219
+ interface SubmitOptions extends FetcherSubmitOptions {
220
+ /**
221
+ * Set `true` to replace the current entry in the browser's history stack
222
+ * instead of creating a new one (i.e. stay on "the same page"). Defaults
223
+ * to `false`.
224
+ */
225
+ replace?: boolean;
226
+ /**
227
+ * State object to add to the history stack entry for this navigation
228
+ */
229
+ state?: any;
230
+ /**
231
+ * Indicate a specific fetcherKey to use when using navigate=false
232
+ */
233
+ fetcherKey?: string;
234
+ /**
235
+ * navigate=false will use a fetcher instead of a navigation
236
+ */
237
+ navigate?: boolean;
238
+ /**
239
+ * Enable view transitions on this submission navigation
240
+ */
241
+ viewTransition?: boolean;
242
+ }
243
+
244
+ declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
245
+ /**
246
+ * Defines the discovery behavior of the link:
247
+ *
248
+ * - "render" - default, discover the route when the link renders
249
+ * - "none" - don't eagerly discover, only discover if the link is clicked
250
+ */
251
+ type DiscoverBehavior = "render" | "none";
252
+ /**
253
+ * Defines the prefetching behavior of the link:
254
+ *
255
+ * - "none": Never fetched
256
+ * - "intent": Fetched when the user focuses or hovers the link
257
+ * - "render": Fetched when the link is rendered
258
+ * - "viewport": Fetched when the link is in the viewport
259
+ */
260
+ type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
261
+ /**
262
+ * Renders all of the `<link>` tags created by the route module
263
+ * [`links`](../../start/framework/route-module#links) export. You should render
264
+ * it inside the `<head>` of your document.
265
+ *
266
+ * @example
267
+ * import { Links } from "react-router";
268
+ *
269
+ * export default function Root() {
270
+ * return (
271
+ * <html>
272
+ * <head>
273
+ * <Links />
274
+ * </head>
275
+ * <body></body>
276
+ * </html>
277
+ * );
278
+ * }
279
+ *
280
+ * @public
281
+ * @category Components
282
+ * @mode framework
283
+ * @returns A collection of React elements for `<link>` tags
284
+ */
285
+ declare function Links(): React.JSX.Element;
286
+ /**
287
+ * Renders `<link rel=prefetch|modulepreload>` tags for modules and data of
288
+ * another page to enable an instant navigation to that page.
289
+ * [`<Link prefetch>`](../../components/Link#prefetch) uses this internally, but
290
+ * you can render it to prefetch a page for any other reason.
291
+ *
292
+ * For example, you may render one of this as the user types into a search field
293
+ * to prefetch search results before they click through to their selection.
294
+ *
295
+ * @example
296
+ * import { PrefetchPageLinks } from "react-router";
297
+ *
298
+ * <PrefetchPageLinks page="/absolute/path" />
299
+ *
300
+ * @public
301
+ * @category Components
302
+ * @mode framework
303
+ * @param props Props
304
+ * @param props.page The absolute path of the page to prefetch, e.g. `/absolute/path`.
305
+ * @param props.linkProps Additional props to spread onto the
306
+ * [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link)
307
+ * tags, such as `crossOrigin`, `integrity`, `rel`, etc.
308
+ * @returns A collection of React elements for `<link>` tags
309
+ */
310
+ declare function PrefetchPageLinks({ page, ...linkProps }: PageLinkDescriptor): React.JSX.Element | null;
311
+ /**
312
+ * Renders all the `<meta>` tags created by the route module
313
+ * [`meta`](../../start/framework/route-module#meta) exports. You should render
314
+ * it inside the `<head>` of your HTML.
315
+ *
316
+ * @example
317
+ * import { Meta } from "react-router";
318
+ *
319
+ * export default function Root() {
320
+ * return (
321
+ * <html>
322
+ * <head>
323
+ * <Meta />
324
+ * </head>
325
+ * </html>
326
+ * );
327
+ * }
328
+ *
329
+ * @public
330
+ * @category Components
331
+ * @mode framework
332
+ * @returns A collection of React elements for `<meta>` tags
333
+ */
334
+ declare function Meta(): React.JSX.Element;
335
+ /**
336
+ * A couple common attributes:
337
+ *
338
+ * - `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
339
+ * - `<Scripts nonce>` to support a [content security policy for scripts](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) with [nonce-sources](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources#sources) for your `<script>` tags.
340
+ *
341
+ * You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
342
+ *
343
+ * @category Types
344
+ */
345
+ type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "async" | "children" | "dangerouslySetInnerHTML" | "defer" | "src" | "type" | "noModule" | "suppressHydrationWarning"> & {
346
+ /**
347
+ * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
348
+ * attribute to render on [the `<script>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script)
349
+ */
350
+ nonce?: string | undefined;
351
+ };
352
+ /**
353
+ * Renders the client runtime of your app. It should be rendered inside the
354
+ * [`<body>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/body)
355
+ * of the document.
356
+ *
357
+ * If server rendering, you can omit `<Scripts/>` and the app will work as a
358
+ * traditional web app without JavaScript, relying solely on HTML and browser
359
+ * behaviors.
360
+ *
361
+ * @example
362
+ * import { Scripts } from "react-router";
363
+ *
364
+ * export default function Root() {
365
+ * return (
366
+ * <html>
367
+ * <head />
368
+ * <body>
369
+ * <Scripts />
370
+ * </body>
371
+ * </html>
372
+ * );
373
+ * }
374
+ *
375
+ * @public
376
+ * @category Components
377
+ * @mode framework
378
+ * @param scriptProps Additional props to spread onto the
379
+ * [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script)
380
+ * tag, such as `crossOrigin`, `nonce`, etc.
381
+ * @returns A collection of React elements for `<script>` tags
382
+ */
383
+ declare function Scripts(scriptProps: ScriptsProps): React.JSX.Element | null;
384
+
385
+ /**
386
+ * @category Data Routers
387
+ */
388
+ interface DOMRouterOpts {
389
+ /**
390
+ * Basename path for the application.
391
+ */
392
+ basename?: string;
393
+ /**
394
+ * Function to provide the initial `context` values for all client side navigations/fetches
395
+ */
396
+ unstable_getContext?: RouterInit["unstable_getContext"];
397
+ /**
398
+ * Future flags to enable for the router.
399
+ */
400
+ future?: Partial<FutureConfig$1>;
401
+ /**
402
+ * When Server-Rendering and opting-out of automatic hydration, the `hydrationData`
403
+ * option allows you to pass in hydration data from your server-render. This will
404
+ * almost always be a subset of data from the {@link StaticHandlerContext} value you
405
+ * get back from the `{@link StaticHandler} `query()` method:
406
+ *
407
+ * ```tsx
408
+ * const router = createBrowserRouter(routes, {
409
+ * hydrationData: {
410
+ * loaderData: {
411
+ * // [routeId]: serverLoaderData
412
+ * },
413
+ * // may also include `errors` and/or `actionData`
414
+ * },
415
+ * });
416
+ * ```
417
+ *
418
+ * **Partial Hydration Data**
419
+ *
420
+ * You will almost always include a complete set of `loaderData` to hydrate a
421
+ * server-rendered app. But in advanced use-cases (such as Framework Mode's
422
+ * `clientLoader`), you may want to include `loaderData` for only some routes
423
+ * that were loaded/rendered on the server. This allows you to hydrate _some_
424
+ * of the routes (such as the app layout/shell) while showing a `HydrateFallback`
425
+ * and running the loaders for other routes during hydration.
426
+ *
427
+ * A route `loader` will run during hydration in 2 scenarios:
428
+ *
429
+ * - No hydration data is provided
430
+ * - In these cases the `HydrateFallback` component will render on initial hydration
431
+ * - The `loader.hydrate` property is set to true
432
+ * - This allows you to run the loader even if you did not render a fallback
433
+ * on initial hydration (i.e., to prime a cache with hydration data)
434
+ *
435
+ * ```tsx
436
+ * const router = createBrowserRouter(
437
+ * [
438
+ * {
439
+ * id: "root",
440
+ * loader: rootLoader,
441
+ * Component: Root,
442
+ * children: [
443
+ * {
444
+ * id: "index",
445
+ * loader: indexLoader,
446
+ * HydrateFallback: IndexSkeleton,
447
+ * Component: Index,
448
+ * },
449
+ * ],
450
+ * },
451
+ * ],
452
+ * {
453
+ * hydrationData: {
454
+ * loaderData: {
455
+ * root: "ROOT DATA",
456
+ * // No index data provided
457
+ * },
458
+ * },
459
+ * }
460
+ * );
461
+ * ```
462
+ */
463
+ hydrationData?: HydrationState;
464
+ /**
465
+ * Override the default data strategy of running loaders in parallel.
466
+ * See {@link DataStrategyFunction}.
467
+ *
468
+ * <docs-warning>This is a low-level API intended for advanced use-cases. This
469
+ * overrides React Router's internal handling of `loader`/`action` execution,
470
+ * and if done incorrectly will break your app code. Please use with caution
471
+ * and perform the appropriate testing.</docs-warning>
472
+ *
473
+ * By default, React Router is opinionated about how your data is loaded/submitted -
474
+ * and most notably, executes all of your loaders in parallel for optimal data
475
+ * fetching. While we think this is the right behavior for most use-cases, we
476
+ * realize that there is no "one size fits all" solution when it comes to data
477
+ * fetching for the wide landscape of application requirements.
478
+ *
479
+ * The `dataStrategy` option gives you full control over how your loaders and
480
+ * actions are executed and lays the foundation to build in more advanced APIs
481
+ * such as middleware, context, and caching layers. Over time, we expect that
482
+ * we'll leverage this API internally to bring more first class APIs to React
483
+ * Router, but until then (and beyond), this is your way to add more advanced
484
+ * functionality for your applications data needs.
485
+ *
486
+ * The `dataStrategy` function should return a key/value object of
487
+ * `routeId` -> {@link DataStrategyResult} and should include entries for any routes
488
+ * where a handler was executed. A `DataStrategyResult` indicates if the handler
489
+ * was successful or not based on the `DataStrategyResult.type` field. If the
490
+ * returned `DataStrategyResult["result"]` is a `Response`, React Router will
491
+ * unwrap it for you (via `res.json` or `res.text`). If you need to do custom
492
+ * decoding of a `Response` but want to preserve the status code, you can use
493
+ * the `data` utility to return your decoded data along with a `ResponseInit`.
494
+ *
495
+ * <details>
496
+ * <summary><b>Example <code>dataStrategy</code> Use Cases</b></summary>
497
+ *
498
+ * **Adding logging**
499
+ *
500
+ * In the simplest case, let's look at hooking into this API to add some logging
501
+ * for when our route loaders/actions execute:
502
+ *
503
+ * ```ts
504
+ * let router = createBrowserRouter(routes, {
505
+ * async dataStrategy({ request, matches }) {
506
+ * const matchesToLoad = matches.filter((m) => m.shouldLoad);
507
+ * const results = {};
508
+ * await Promise.all(
509
+ * matchesToLoad.map(async (match) => {
510
+ * console.log(`Processing ${match.route.id}`);
511
+ * results[match.route.id] = await match.resolve();;
512
+ * })
513
+ * );
514
+ * return results;
515
+ * },
516
+ * });
517
+ * ```
518
+ *
519
+ * **Middleware**
520
+ *
521
+ * Let's define a middleware on each route via `handle` and call middleware
522
+ * sequentially first, then call all loaders in parallel - providing any data
523
+ * made available via the middleware:
524
+ *
525
+ * ```ts
526
+ * const routes = [
527
+ * {
528
+ * id: "parent",
529
+ * path: "/parent",
530
+ * loader({ request }, context) {
531
+ * // ...
532
+ * },
533
+ * handle: {
534
+ * async middleware({ request }, context) {
535
+ * context.parent = "PARENT MIDDLEWARE";
536
+ * },
537
+ * },
538
+ * children: [
539
+ * {
540
+ * id: "child",
541
+ * path: "child",
542
+ * loader({ request }, context) {
543
+ * // ...
544
+ * },
545
+ * handle: {
546
+ * async middleware({ request }, context) {
547
+ * context.child = "CHILD MIDDLEWARE";
548
+ * },
549
+ * },
550
+ * },
551
+ * ],
552
+ * },
553
+ * ];
554
+ *
555
+ * let router = createBrowserRouter(routes, {
556
+ * async dataStrategy({ request, params, matches }) {
557
+ * // Run middleware sequentially and let them add data to `context`
558
+ * let context = {};
559
+ * for (const match of matches) {
560
+ * if (match.route.handle?.middleware) {
561
+ * await match.route.handle.middleware(
562
+ * { request, params },
563
+ * context
564
+ * );
565
+ * }
566
+ * }
567
+ *
568
+ * // Run loaders in parallel with the `context` value
569
+ * let matchesToLoad = matches.filter((m) => m.shouldLoad);
570
+ * let results = await Promise.all(
571
+ * matchesToLoad.map((match, i) =>
572
+ * match.resolve((handler) => {
573
+ * // Whatever you pass to `handler` will be passed as the 2nd parameter
574
+ * // to your loader/action
575
+ * return handler(context);
576
+ * })
577
+ * )
578
+ * );
579
+ * return results.reduce(
580
+ * (acc, result, i) =>
581
+ * Object.assign(acc, {
582
+ * [matchesToLoad[i].route.id]: result,
583
+ * }),
584
+ * {}
585
+ * );
586
+ * },
587
+ * });
588
+ * ```
589
+ *
590
+ * **Custom Handler**
591
+ *
592
+ * It's also possible you don't even want to define a loader implementation at
593
+ * the route level. Maybe you want to just determine the routes and issue a single
594
+ * GraphQL request for all of your data? You can do that by setting your
595
+ * `route.loader=true` so it qualifies as "having a loader", and then store GQL
596
+ * fragments on `route.handle`:
597
+ *
598
+ * ```ts
599
+ * const routes = [
600
+ * {
601
+ * id: "parent",
602
+ * path: "/parent",
603
+ * loader: true,
604
+ * handle: {
605
+ * gql: gql`
606
+ * fragment Parent on Whatever {
607
+ * parentField
608
+ * }
609
+ * `,
610
+ * },
611
+ * children: [
612
+ * {
613
+ * id: "child",
614
+ * path: "child",
615
+ * loader: true,
616
+ * handle: {
617
+ * gql: gql`
618
+ * fragment Child on Whatever {
619
+ * childField
620
+ * }
621
+ * `,
622
+ * },
623
+ * },
624
+ * ],
625
+ * },
626
+ * ];
627
+ *
628
+ * let router = createBrowserRouter(routes, {
629
+ * async dataStrategy({ request, params, matches }) {
630
+ * // Compose route fragments into a single GQL payload
631
+ * let gql = getFragmentsFromRouteHandles(matches);
632
+ * let data = await fetchGql(gql);
633
+ * // Parse results back out into individual route level `DataStrategyResult`'s
634
+ * // keyed by `routeId`
635
+ * let results = parseResultsFromGql(data);
636
+ * return results;
637
+ * },
638
+ * });
639
+ * ```
640
+ *</details>
641
+ */
642
+ dataStrategy?: DataStrategyFunction;
643
+ /**
644
+ * Lazily define portions of the route tree on navigations.
645
+ * See {@link PatchRoutesOnNavigationFunction}.
646
+ *
647
+ * By default, React Router wants you to provide a full route tree up front via
648
+ * `createBrowserRouter(routes)`. This allows React Router to perform synchronous
649
+ * route matching, execute loaders, and then render route components in the most
650
+ * optimistic manner without introducing waterfalls. The tradeoff is that your
651
+ * initial JS bundle is larger by definition - which may slow down application
652
+ * start-up times as your application grows.
653
+ *
654
+ * To combat this, we introduced [`route.lazy`][route-lazy] in [v6.9.0][6-9-0]
655
+ * which let's you lazily load the route _implementation_ (`loader`, `Component`,
656
+ * etc.) while still providing the route _definition_ aspects up front (`path`,
657
+ * `index`, etc.). This is a good middle ground because React Router still knows
658
+ * about your route definitions (the lightweight part) up front and can perform
659
+ * synchronous route matching, but then delay loading any of the route implementation
660
+ * aspects (the heavier part) until the route is actually navigated to.
661
+ *
662
+ * In some cases, even this doesn't go far enough. For very large applications,
663
+ * providing all route definitions up front can be prohibitively expensive.
664
+ * Additionally, it might not even be possible to provide all route definitions
665
+ * up front in certain Micro-Frontend or Module-Federation architectures.
666
+ *
667
+ * This is where `patchRoutesOnNavigation` comes in ([RFC][fog-of-war-rfc]).
668
+ * This API is for advanced use-cases where you are unable to provide the full
669
+ * route tree up-front and need a way to lazily "discover" portions of the route
670
+ * tree at runtime. This feature is often referred to as ["Fog of War"][fog-of-war]
671
+ * because similar to how video games expand the "world" as you move around -
672
+ * the router would be expanding its routing tree as the user navigated around
673
+ * the app - but would only ever end up loading portions of the tree that the
674
+ * user visited.
675
+ *
676
+ * `patchRoutesOnNavigation` will be called anytime React Router is unable to
677
+ * match a `path`. The arguments include the `path`, any partial `matches`, and
678
+ * a `patch` function you can call to patch new routes into the tree at a
679
+ * specific location. This method is executed during the `loading` portion of
680
+ * the navigation for `GET` requests and during the `submitting` portion of the
681
+ * navigation for non-`GET` requests.
682
+ *
683
+ * <details>
684
+ * <summary><b>Example <code>patchRoutesOnNavigation</code> Use Cases</b></summary>
685
+ *
686
+ * **Patching children into an existing route**
687
+ *
688
+ * ```tsx
689
+ * const router = createBrowserRouter(
690
+ * [
691
+ * {
692
+ * id: "root",
693
+ * path: "/",
694
+ * Component: RootComponent,
695
+ * },
696
+ * ],
697
+ * {
698
+ * async patchRoutesOnNavigation({ path, patch }) {
699
+ * if (path === "/a") {
700
+ * // Load/patch the `a` route as a child of the route with id `root`
701
+ * let route = await getARoute();
702
+ * // ^ { path: 'a', Component: A }
703
+ * patch("root", [route]);
704
+ * }
705
+ * },
706
+ * }
707
+ * );
708
+ * ```
709
+ *
710
+ * In the above example, if the user clicks a link to `/a`, React Router won't
711
+ * match any routes initially and will call `patchRoutesOnNavigation` with a
712
+ * `path = "/a"` and a `matches` array containing the root route match. By calling
713
+ * `patch('root', [route])`, the new route will be added to the route tree as a
714
+ * child of the `root` route and React Router will perform matching on the updated
715
+ * routes. This time it will successfully match the `/a` path and the navigation
716
+ * will complete successfully.
717
+ *
718
+ * **Patching new root-level routes**
719
+ *
720
+ * If you need to patch a new route to the top of the tree (i.e., it doesn't
721
+ * have a parent), you can pass `null` as the `routeId`:
722
+ *
723
+ * ```tsx
724
+ * const router = createBrowserRouter(
725
+ * [
726
+ * {
727
+ * id: "root",
728
+ * path: "/",
729
+ * Component: RootComponent,
730
+ * },
731
+ * ],
732
+ * {
733
+ * async patchRoutesOnNavigation({ path, patch }) {
734
+ * if (path === "/root-sibling") {
735
+ * // Load/patch the `/root-sibling` route as a sibling of the root route
736
+ * let route = await getRootSiblingRoute();
737
+ * // ^ { path: '/root-sibling', Component: RootSibling }
738
+ * patch(null, [route]);
739
+ * }
740
+ * },
741
+ * }
742
+ * );
743
+ * ```
744
+ *
745
+ * **Patching sub-trees asynchronously**
746
+ *
747
+ * You can also perform asynchronous matching to lazily fetch entire sections
748
+ * of your application:
749
+ *
750
+ * ```jsx
751
+ * let router = createBrowserRouter(
752
+ * [
753
+ * {
754
+ * path: "/",
755
+ * Component: Home,
756
+ * },
757
+ * ],
758
+ * {
759
+ * async patchRoutesOnNavigation({ path, patch }) {
760
+ * if (path.startsWith("/dashboard")) {
761
+ * let children = await import("./dashboard");
762
+ * patch(null, children);
763
+ * }
764
+ * if (path.startsWith("/account")) {
765
+ * let children = await import("./account");
766
+ * patch(null, children);
767
+ * }
768
+ * },
769
+ * }
770
+ * );
771
+ * ```
772
+ *
773
+ * <docs-info>If in-progress execution of `patchRoutesOnNavigation` is
774
+ * interrupted by a subsequent navigation, then any remaining `patch` calls
775
+ * in the interrupted execution will not update the route tree because the
776
+ * operation was cancelled.</docs-info>
777
+ *
778
+ * **Co-locating route discovery with route definition**
779
+ *
780
+ * If you don't wish to perform your own pseudo-matching, you can leverage the
781
+ * partial `matches` array and the `handle` field on a route to keep the children
782
+ * definitions co-located:
783
+ *
784
+ * ```jsx
785
+ * let router = createBrowserRouter(
786
+ * [
787
+ * {
788
+ * path: "/",
789
+ * Component: Home,
790
+ * },
791
+ * {
792
+ * path: "/dashboard",
793
+ * children: [
794
+ * {
795
+ * // If we want to include /dashboard in the critical routes, we need to
796
+ * // also include it's index route since patchRoutesOnNavigation will not be
797
+ * // called on a navigation to `/dashboard` because it will have successfully
798
+ * // matched the `/dashboard` parent route
799
+ * index: true,
800
+ * // ...
801
+ * },
802
+ * ],
803
+ * handle: {
804
+ * lazyChildren: () => import("./dashboard"),
805
+ * },
806
+ * },
807
+ * {
808
+ * path: "/account",
809
+ * children: [
810
+ * {
811
+ * index: true,
812
+ * // ...
813
+ * },
814
+ * ],
815
+ * handle: {
816
+ * lazyChildren: () => import("./account"),
817
+ * },
818
+ * },
819
+ * ],
820
+ * {
821
+ * async patchRoutesOnNavigation({ matches, patch }) {
822
+ * let leafRoute = matches[matches.length - 1]?.route;
823
+ * if (leafRoute?.handle?.lazyChildren) {
824
+ * let children =
825
+ * await leafRoute.handle.lazyChildren();
826
+ * patch(leafRoute.id, children);
827
+ * }
828
+ * },
829
+ * }
830
+ * );
831
+ * ```
832
+ *
833
+ * **A note on routes with parameters**
834
+ *
835
+ * Because React Router uses ranked routes to find the best match for a given
836
+ * path, there is an interesting ambiguity introduced when only a partial route
837
+ * tree is known at any given point in time. If we match a fully static route
838
+ * such as `path: "/about/contact-us"` then we know we've found the right match
839
+ * since it's composed entirely of static URL segments, and thus we do not need
840
+ * to bother asking for any other potentially higher-scoring routes.
841
+ *
842
+ * However, routes with parameters (dynamic or splat) can't make this assumption
843
+ * because there might be a not-yet-discovered route tht scores higher. Consider
844
+ * a full route tree such as:
845
+ *
846
+ * ```js
847
+ * // Assume this is the full route tree for your app
848
+ * const routes = [
849
+ * {
850
+ * path: "/",
851
+ * Component: Home,
852
+ * },
853
+ * {
854
+ * id: "blog",
855
+ * path: "/blog",
856
+ * Component: BlogLayout,
857
+ * children: [
858
+ * { path: "new", Component: NewPost },
859
+ * { path: ":slug", Component: BlogPost },
860
+ * ],
861
+ * },
862
+ * ];
863
+ * ```
864
+ *
865
+ * And then assume we want to use `patchRoutesOnNavigation` to fill this in
866
+ * as the user navigates around:
867
+ *
868
+ * ```js
869
+ * // Start with only the index route
870
+ * const router = createBrowserRouter(
871
+ * [
872
+ * {
873
+ * path: "/",
874
+ * Component: Home,
875
+ * },
876
+ * ],
877
+ * {
878
+ * patchRoutesOnNavigation({ path, patch }) {
879
+ * if (path === "/blog/new") {
880
+ * patch("blog", [
881
+ * {
882
+ * path: "new",
883
+ * Component: NewPost,
884
+ * },
885
+ * ]);
886
+ * } else if (path.startsWith("/blog")) {
887
+ * patch("blog", [
888
+ * {
889
+ * path: ":slug",
890
+ * Component: BlogPost,
891
+ * },
892
+ * ]);
893
+ * }
894
+ * },
895
+ * }
896
+ * );
897
+ * ```
898
+ *
899
+ * If the user were to a blog post first (i.e., `/blog/my-post`) we would patch
900
+ * in the `:slug` route. Then if the user navigated to `/blog/new` to write a
901
+ * new post, we'd match `/blog/:slug` but it wouldn't be the _right_ match!
902
+ * We need to call `patchRoutesOnNavigation` just in case there exists a
903
+ * higher-scoring route we've not yet discovered, which in this case there is.
904
+ *
905
+ * So, anytime React Router matches a path that contains at least one param,
906
+ * it will call `patchRoutesOnNavigation` and match routes again just to
907
+ * confirm it has found the best match.
908
+ *
909
+ * If your `patchRoutesOnNavigation` implementation is expensive or making
910
+ * side-effect `fetch` calls to a backend server, you may want to consider
911
+ * tracking previously seen routes to avoid over-fetching in cases where you
912
+ * know the proper route has already been found. This can usually be as simple
913
+ * as maintaining a small cache of prior `path` values for which you've already
914
+ * patched in the right routes:
915
+ *
916
+ * ```js
917
+ * let discoveredRoutes = new Set();
918
+ *
919
+ * const router = createBrowserRouter(routes, {
920
+ * patchRoutesOnNavigation({ path, patch }) {
921
+ * if (discoveredRoutes.has(path)) {
922
+ * // We've seen this before so nothing to patch in and we can let the router
923
+ * // use the routes it already knows about
924
+ * return;
925
+ * }
926
+ *
927
+ * discoveredRoutes.add(path);
928
+ *
929
+ * // ... patch routes in accordingly
930
+ * },
931
+ * });
932
+ * ```
933
+ * </details>
934
+ */
935
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
936
+ /**
937
+ * [`Window`](https://developer.mozilla.org/en-US/docs/Web/API/Window) object
938
+ * override - defaults to the global `window` instance.
939
+ */
940
+ window?: Window;
941
+ }
942
+ /**
943
+ * Create a new {@link DataRouter| data router} that manages the application
944
+ * path via [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
945
+ * and [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState).
946
+ *
947
+ * @public
948
+ * @category Data Routers
949
+ * @mode data
950
+ * @param routes Application routes
951
+ * @param opts Options
952
+ * @param {DOMRouterOpts.basename} opts.basename n/a
953
+ * @param {DOMRouterOpts.dataStrategy} opts.dataStrategy n/a
954
+ * @param {DOMRouterOpts.future} opts.future n/a
955
+ * @param {DOMRouterOpts.unstable_getContext} opts.unstable_getContext n/a
956
+ * @param {DOMRouterOpts.hydrationData} opts.hydrationData n/a
957
+ * @param {DOMRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
958
+ * @param {DOMRouterOpts.window} opts.window n/a
959
+ * @returns An initialized {@link DataRouter| data router} to pass to {@link RouterProvider | `<RouterProvider>`}
960
+ */
961
+ declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
962
+ /**
963
+ * Create a new {@link DataRouter| data router} that manages the application
964
+ * path via the URL [`hash`]https://developer.mozilla.org/en-US/docs/Web/API/URL/hash).
965
+ *
966
+ * @public
967
+ * @category Data Routers
968
+ * @mode data
969
+ * @param routes Application routes
970
+ * @param opts Options
971
+ * @param {DOMRouterOpts.basename} opts.basename n/a
972
+ * @param {DOMRouterOpts.future} opts.future n/a
973
+ * @param {DOMRouterOpts.unstable_getContext} opts.unstable_getContext n/a
974
+ * @param {DOMRouterOpts.hydrationData} opts.hydrationData n/a
975
+ * @param {DOMRouterOpts.dataStrategy} opts.dataStrategy n/a
976
+ * @param {DOMRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
977
+ * @param {DOMRouterOpts.window} opts.window n/a
978
+ * @returns An initialized {@link DataRouter| data router} to pass to {@link RouterProvider | `<RouterProvider>`}
979
+ */
980
+ declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
981
+ /**
982
+ * @category Types
983
+ */
984
+ interface BrowserRouterProps {
985
+ basename?: string;
986
+ children?: React.ReactNode;
987
+ window?: Window;
988
+ }
989
+ /**
990
+ * A declarative {@link Router | `<Router>`} using the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
991
+ * API for client-side routing.
992
+ *
993
+ * @public
994
+ * @category Declarative Routers
995
+ * @mode declarative
996
+ * @param props Props
997
+ * @param props.basename Application basename
998
+ * @param props.children {@link Route | `<Route>`} components describing your route configuration
999
+ * @param props.window [`Window`](https://developer.mozilla.org/en-US/docs/Web/API/Window)
1000
+ * object override - defaults to the global `window` instance
1001
+ * @returns A declarative {@link Router | `<Router>`} using the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1002
+ * API for client-side routing.
1003
+ */
1004
+ declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
1005
+ /**
1006
+ * @category Types
1007
+ */
1008
+ interface HashRouterProps {
1009
+ basename?: string;
1010
+ children?: React.ReactNode;
1011
+ window?: Window;
1012
+ }
1013
+ /**
1014
+ * A declarative {@link Router | `<Router>`} that stores the location in the
1015
+ * [`hash`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hash) portion
1016
+ * of the URL so it is not sent to the server.
1017
+ *
1018
+ * @public
1019
+ * @category Declarative Routers
1020
+ * @mode declarative
1021
+ * @param props Props
1022
+ * @param props.basename Application basename
1023
+ * @param props.children {@link Route | `<Route>`} components describing your route configuration
1024
+ * @param props.window [`Window`](https://developer.mozilla.org/en-US/docs/Web/API/Window)
1025
+ * object override - defaults to the global `window` instance
1026
+ * @returns A declarative {@link Router | `<Router>`} using the URL [`hash`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hash)
1027
+ * for client-side routing.
1028
+ */
1029
+ declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
1030
+ /**
1031
+ * @category Types
1032
+ */
1033
+ interface HistoryRouterProps {
1034
+ basename?: string;
1035
+ children?: React.ReactNode;
1036
+ history: History;
1037
+ }
1038
+ /**
1039
+ * A declarative {@link Router | `<Router>`} that accepts a pre-instantiated
1040
+ * `history` object.
1041
+ * It's important to note that using your own `history` object is highly discouraged
1042
+ * and may add two versions of the `history` library to your bundles unless you use
1043
+ * the same version of the `history` library that React Router uses internally.
1044
+ *
1045
+ * @name unstable_HistoryRouter
1046
+ * @public
1047
+ * @category Declarative Routers
1048
+ * @mode declarative
1049
+ * @param props Props
1050
+ * @param props.basename Application basename
1051
+ * @param props.children {@link Route | `<Route>`} components describing your route configuration
1052
+ * @param props.history A history implementation for use by the router
1053
+ * @returns A declarative router using the provided history implementation for client-side routing.
1054
+ */
1055
+ declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
1056
+ declare namespace HistoryRouter {
1057
+ var displayName: string;
1058
+ }
1059
+ /**
1060
+ * @category Types
1061
+ */
1062
+ interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
1063
+ /**
1064
+ * Defines the link discovery behavior
1065
+ *
1066
+ * ```tsx
1067
+ * <Link /> // default ("render")
1068
+ * <Link discover="render" />
1069
+ * <Link discover="none" />
1070
+ * ```
1071
+ *
1072
+ * - **render** - default, discover the route when the link renders
1073
+ * - **none** - don't eagerly discover, only discover if the link is clicked
1074
+ */
1075
+ discover?: DiscoverBehavior;
1076
+ /**
1077
+ * Defines the data and module prefetching behavior for the link.
1078
+ *
1079
+ * ```tsx
1080
+ * <Link /> // default
1081
+ * <Link prefetch="none" />
1082
+ * <Link prefetch="intent" />
1083
+ * <Link prefetch="render" />
1084
+ * <Link prefetch="viewport" />
1085
+ * ```
1086
+ *
1087
+ * - **none** - default, no prefetching
1088
+ * - **intent** - prefetches when the user hovers or focuses the link
1089
+ * - **render** - prefetches when the link renders
1090
+ * - **viewport** - prefetches when the link is in the viewport, very useful for mobile
1091
+ *
1092
+ * Prefetching is done with HTML [`<link rel="prefetch">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
1093
+ * tags. They are inserted after the link.
1094
+ *
1095
+ * ```tsx
1096
+ * <a href="..." />
1097
+ * <a href="..." />
1098
+ * <link rel="prefetch" /> // might conditionally render
1099
+ * ```
1100
+ *
1101
+ * Because of this, if you are using `nav :last-child` you will need to use
1102
+ * `nav :last-of-type` so the styles don't conditionally fall off your last link
1103
+ * (and any other similar selectors).
1104
+ */
1105
+ prefetch?: PrefetchBehavior;
1106
+ /**
1107
+ * Will use document navigation instead of client side routing when the link is
1108
+ * clicked: the browser will handle the transition normally (as if it were an
1109
+ * [`<a href>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)).
1110
+ *
1111
+ * ```tsx
1112
+ * <Link to="/logout" reloadDocument />
1113
+ * ```
1114
+ */
1115
+ reloadDocument?: boolean;
1116
+ /**
1117
+ * Replaces the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1118
+ * stack instead of pushing a new one onto it.
1119
+ *
1120
+ * ```tsx
1121
+ * <Link replace />
1122
+ * ```
1123
+ *
1124
+ * ```
1125
+ * # with a history stack like this
1126
+ * A -> B
1127
+ *
1128
+ * # normal link click pushes a new entry
1129
+ * A -> B -> C
1130
+ *
1131
+ * # but with `replace`, B is replaced by C
1132
+ * A -> C
1133
+ * ```
1134
+ */
1135
+ replace?: boolean;
1136
+ /**
1137
+ * Adds persistent client side routing state to the next location.
1138
+ *
1139
+ * ```tsx
1140
+ * <Link to="/somewhere/else" state={{ some: "value" }} />
1141
+ * ```
1142
+ *
1143
+ * The location state is accessed from the `location`.
1144
+ *
1145
+ * ```tsx
1146
+ * function SomeComp() {
1147
+ * const location = useLocation();
1148
+ * location.state; // { some: "value" }
1149
+ * }
1150
+ * ```
1151
+ *
1152
+ * This state is inaccessible on the server as it is implemented on top of
1153
+ * [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
1154
+ */
1155
+ state?: any;
1156
+ /**
1157
+ * Prevents the scroll position from being reset to the top of the window when
1158
+ * the link is clicked and the app is using {@link ScrollRestoration}. This only
1159
+ * prevents new locations resetting scroll to the top, scroll position will be
1160
+ * restored for back/forward button navigation.
1161
+ *
1162
+ * ```tsx
1163
+ * <Link to="?tab=one" preventScrollReset />
1164
+ * ```
1165
+ */
1166
+ preventScrollReset?: boolean;
1167
+ /**
1168
+ * Defines the relative path behavior for the link.
1169
+ *
1170
+ * ```tsx
1171
+ * <Link to=".." /> // default: "route"
1172
+ * <Link relative="route" />
1173
+ * <Link relative="path" />
1174
+ * ```
1175
+ *
1176
+ * Consider a route hierarchy where a parent route pattern is `"blog"` and a child
1177
+ * route pattern is `"blog/:slug/edit"`.
1178
+ *
1179
+ * - **route** - default, resolves the link relative to the route pattern. In the
1180
+ * example above, a relative link of `".."` will remove both `:slug/edit` segments
1181
+ * back to `"/blog"`.
1182
+ * - **path** - relative to the path so `".."` will only remove one URL segment up
1183
+ * to `"/blog/:slug"`
1184
+ *
1185
+ * Note that index routes and layout routes do not have paths so they are not
1186
+ * included in the relative path calculation.
1187
+ */
1188
+ relative?: RelativeRoutingType;
1189
+ /**
1190
+ * Can be a string or a partial {@link Path}:
1191
+ *
1192
+ * ```tsx
1193
+ * <Link to="/some/path" />
1194
+ *
1195
+ * <Link
1196
+ * to={{
1197
+ * pathname: "/some/path",
1198
+ * search: "?query=string",
1199
+ * hash: "#hash",
1200
+ * }}
1201
+ * />
1202
+ * ```
1203
+ */
1204
+ to: To;
1205
+ /**
1206
+ * Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1207
+ * for this navigation.
1208
+ *
1209
+ * ```jsx
1210
+ * <Link to={to} viewTransition>
1211
+ * Click me
1212
+ * </Link>
1213
+ * ```
1214
+ *
1215
+ * To apply specific styles for the transition, see {@link useViewTransitionState}
1216
+ */
1217
+ viewTransition?: boolean;
1218
+ }
1219
+ /**
1220
+ * A progressively enhanced [`<a href>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)
1221
+ * wrapper to enable navigation with client-side routing.
1222
+ *
1223
+ * @example
1224
+ * import { Link } from "react-router";
1225
+ *
1226
+ * <Link to="/dashboard">Dashboard</Link>;
1227
+ *
1228
+ * <Link
1229
+ * to={{
1230
+ * pathname: "/some/path",
1231
+ * search: "?query=string",
1232
+ * hash: "#hash",
1233
+ * }}
1234
+ * />;
1235
+ *
1236
+ * @public
1237
+ * @category Components
1238
+ * @param {LinkProps.discover} props.discover [modes: framework] n/a
1239
+ * @param {LinkProps.prefetch} props.prefetch [modes: framework] n/a
1240
+ * @param {LinkProps.preventScrollReset} props.preventScrollReset [modes: framework, data] n/a
1241
+ * @param {LinkProps.relative} props.relative n/a
1242
+ * @param {LinkProps.reloadDocument} props.reloadDocument n/a
1243
+ * @param {LinkProps.replace} props.replace n/a
1244
+ * @param {LinkProps.state} props.state n/a
1245
+ * @param {LinkProps.to} props.to n/a
1246
+ * @param {LinkProps.viewTransition} props.viewTransition [modes: framework, data] n/a
1247
+ */
1248
+ declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
1249
+ /**
1250
+ * The object passed to {@link NavLink} `children`, `className`, and `style` prop
1251
+ * callbacks to render and style the link based on its state.
1252
+ *
1253
+ * ```
1254
+ * // className
1255
+ * <NavLink
1256
+ * to="/messages"
1257
+ * className={({ isActive, isPending }) =>
1258
+ * isPending ? "pending" : isActive ? "active" : ""
1259
+ * }
1260
+ * >
1261
+ * Messages
1262
+ * </NavLink>
1263
+ *
1264
+ * // style
1265
+ * <NavLink
1266
+ * to="/messages"
1267
+ * style={({ isActive, isPending }) => {
1268
+ * return {
1269
+ * fontWeight: isActive ? "bold" : "",
1270
+ * color: isPending ? "red" : "black",
1271
+ * }
1272
+ * )}
1273
+ * />
1274
+ *
1275
+ * // children
1276
+ * <NavLink to="/tasks">
1277
+ * {({ isActive, isPending }) => (
1278
+ * <span className={isActive ? "active" : ""}>Tasks</span>
1279
+ * )}
1280
+ * </NavLink>
1281
+ * ```
1282
+ *
1283
+ */
1284
+ type NavLinkRenderProps = {
1285
+ /**
1286
+ * Indicates if the link's URL matches the current {@link Location}.
1287
+ */
1288
+ isActive: boolean;
1289
+ /**
1290
+ * Indicates if the pending {@link Location} matches the link's URL. Only
1291
+ * available in Framework/Data modes.
1292
+ */
1293
+ isPending: boolean;
1294
+ /**
1295
+ * Indicates if a view transition to the link's URL is in progress.
1296
+ * See {@link useViewTransitionState}
1297
+ */
1298
+ isTransitioning: boolean;
1299
+ };
1300
+ /**
1301
+ * @category Types
1302
+ */
1303
+ interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
1304
+ /**
1305
+ * Can be regular React children or a function that receives an object with the
1306
+ * `active` and `pending` states of the link.
1307
+ *
1308
+ * ```tsx
1309
+ * <NavLink to="/tasks">
1310
+ * {({ isActive }) => (
1311
+ * <span className={isActive ? "active" : ""}>Tasks</span>
1312
+ * )}
1313
+ * </NavLink>
1314
+ * ```
1315
+ */
1316
+ children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
1317
+ /**
1318
+ * Changes the matching logic to make it case-sensitive:
1319
+ *
1320
+ * | Link | URL | isActive |
1321
+ * | -------------------------------------------- | ------------- | -------- |
1322
+ * | `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
1323
+ * | `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
1324
+ */
1325
+ caseSensitive?: boolean;
1326
+ /**
1327
+ * Classes are automatically applied to `NavLink` that correspond to the state.
1328
+ *
1329
+ * ```css
1330
+ * a.active {
1331
+ * color: red;
1332
+ * }
1333
+ * a.pending {
1334
+ * color: blue;
1335
+ * }
1336
+ * a.transitioning {
1337
+ * view-transition-name: my-transition;
1338
+ * }
1339
+ * ```
1340
+ *
1341
+ * Or you can specify a function that receives {@link NavLinkRenderProps} and
1342
+ * returns the `className`:
1343
+ *
1344
+ * ```tsx
1345
+ * <NavLink className={({ isActive, isPending }) => (
1346
+ * isActive ? "my-active-class" :
1347
+ * isPending ? "my-pending-class" :
1348
+ * ""
1349
+ * )} />
1350
+ * ```
1351
+ */
1352
+ className?: string | ((props: NavLinkRenderProps) => string | undefined);
1353
+ /**
1354
+ * Changes the matching logic for the `active` and `pending` states to only match
1355
+ * to the "end" of the {@link NavLinkProps.to}. If the URL is longer, it will no
1356
+ * longer be considered active.
1357
+ *
1358
+ * | Link | URL | isActive |
1359
+ * | ----------------------------- | ------------ | -------- |
1360
+ * | `<NavLink to="/tasks" />` | `/tasks` | true |
1361
+ * | `<NavLink to="/tasks" />` | `/tasks/123` | true |
1362
+ * | `<NavLink to="/tasks" end />` | `/tasks` | true |
1363
+ * | `<NavLink to="/tasks" end />` | `/tasks/123` | false |
1364
+ *
1365
+ * `<NavLink to="/">` is an exceptional case because _every_ URL matches `/`.
1366
+ * To avoid this matching every single route by default, it effectively ignores
1367
+ * the `end` prop and only matches when you're at the root route.
1368
+ */
1369
+ end?: boolean;
1370
+ /**
1371
+ * Styles can also be applied dynamically via a function that receives
1372
+ * {@link NavLinkRenderProps} and returns the styles:
1373
+ *
1374
+ * ```tsx
1375
+ * <NavLink to="/tasks" style={{ color: "red" }} />
1376
+ * <NavLink to="/tasks" style={({ isActive, isPending }) => ({
1377
+ * color:
1378
+ * isActive ? "red" :
1379
+ * isPending ? "blue" : "black"
1380
+ * })} />
1381
+ * ```
1382
+ */
1383
+ style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
1384
+ }
1385
+ /**
1386
+ * Wraps {@link Link | `<Link>`} with additional props for styling active and
1387
+ * pending states.
1388
+ *
1389
+ * - Automatically applies classes to the link based on its `active` and `pending`
1390
+ * states, see {@link NavLinkProps.className}
1391
+ * - Note that `pending` is only available with Framework and Data modes.
1392
+ * - Automatically applies `aria-current="page"` to the link when the link is active.
1393
+ * See [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
1394
+ * on MDN.
1395
+ * - States are additionally available through the className, style, and children
1396
+ * render props. See {@link NavLinkRenderProps}.
1397
+ *
1398
+ * @example
1399
+ * <NavLink to="/message">Messages</NavLink>
1400
+ *
1401
+ * // Using render props
1402
+ * <NavLink
1403
+ * to="/messages"
1404
+ * className={({ isActive, isPending }) =>
1405
+ * isPending ? "pending" : isActive ? "active" : ""
1406
+ * }
1407
+ * >
1408
+ * Messages
1409
+ * </NavLink>
1410
+ *
1411
+ * @public
1412
+ * @category Components
1413
+ * @param {NavLinkProps.caseSensitive} props.caseSensitive n/a
1414
+ * @param {NavLinkProps.children} props.children n/a
1415
+ * @param {NavLinkProps.className} props.className n/a
1416
+ * @param {NavLinkProps.discover} props.discover [modes: framework] n/a
1417
+ * @param {NavLinkProps.end} props.end n/a
1418
+ * @param {NavLinkProps.prefetch} props.prefetch [modes: framework] n/a
1419
+ * @param {NavLinkProps.preventScrollReset} props.preventScrollReset [modes: framework, data] n/a
1420
+ * @param {NavLinkProps.relative} props.relative n/a
1421
+ * @param {NavLinkProps.reloadDocument} props.reloadDocument n/a
1422
+ * @param {NavLinkProps.replace} props.replace n/a
1423
+ * @param {NavLinkProps.state} props.state n/a
1424
+ * @param {NavLinkProps.style} props.style n/a
1425
+ * @param {NavLinkProps.to} props.to n/a
1426
+ * @param {NavLinkProps.viewTransition} props.viewTransition [modes: framework, data] n/a
1427
+ */
1428
+ declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
1429
+ /**
1430
+ * Form props shared by navigations and fetchers
1431
+ */
1432
+ interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
1433
+ /**
1434
+ * The HTTP verb to use when the form is submitted. Supports "get", "post",
1435
+ * "put", "delete", and "patch".
1436
+ *
1437
+ * Native [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
1438
+ * only supports `get` and `post`, avoid the other verbs if you'd like to
1439
+ * support progressive enhancement
1440
+ */
1441
+ method?: HTMLFormMethod;
1442
+ /**
1443
+ * The encoding type to use for the form submission.
1444
+ *
1445
+ * ```tsx
1446
+ * <Form encType="application/x-www-form-urlencoded"/> // Default
1447
+ * <Form encType="multipart/form-data"/>
1448
+ * <Form encType="text/plain"/>
1449
+ * ```
1450
+ */
1451
+ encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
1452
+ /**
1453
+ * The URL to submit the form data to. If `undefined`, this defaults to the
1454
+ * closest route in context.
1455
+ */
1456
+ action?: string;
1457
+ /**
1458
+ * Determines whether the form action is relative to the route hierarchy or
1459
+ * the pathname. Use this if you want to opt out of navigating the route
1460
+ * hierarchy and want to instead route based on slash-delimited URL segments.
1461
+ * See {@link RelativeRoutingType}.
1462
+ */
1463
+ relative?: RelativeRoutingType;
1464
+ /**
1465
+ * Prevent the scroll position from resetting to the top of the viewport on
1466
+ * completion of the navigation when using the
1467
+ * {@link ScrollRestoration | `<ScrollRestoration>`} component
1468
+ */
1469
+ preventScrollReset?: boolean;
1470
+ /**
1471
+ * A function to call when the form is submitted. If you call
1472
+ * [`event.preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
1473
+ * then this form will not do anything.
1474
+ */
1475
+ onSubmit?: React.FormEventHandler<HTMLFormElement>;
1476
+ }
1477
+ /**
1478
+ * Form props available to fetchers
1479
+ * @category Types
1480
+ */
1481
+ interface FetcherFormProps extends SharedFormProps {
1482
+ }
1483
+ /**
1484
+ * Form props available to navigations
1485
+ * @category Types
1486
+ */
1487
+ interface FormProps extends SharedFormProps {
1488
+ /**
1489
+ * Defines the link discovery behavior. See {@link DiscoverBehavior}.
1490
+ *
1491
+ * ```tsx
1492
+ * <Link /> // default ("render")
1493
+ * <Link discover="render" />
1494
+ * <Link discover="none" />
1495
+ * ```
1496
+ *
1497
+ * - **render** - default, discover the route when the link renders
1498
+ * - **none** - don't eagerly discover, only discover if the link is clicked
1499
+ */
1500
+ discover?: DiscoverBehavior;
1501
+ /**
1502
+ * Indicates a specific fetcherKey to use when using `navigate={false}` so you
1503
+ * can pick up the fetcher's state in a different component in a {@link useFetcher}.
1504
+ */
1505
+ fetcherKey?: string;
1506
+ /**
1507
+ * When `false`, skips the navigation and submits via a fetcher internally.
1508
+ * This is essentially a shorthand for {@link useFetcher} + `<fetcher.Form>` where
1509
+ * you don't care about the resulting data in this component.
1510
+ */
1511
+ navigate?: boolean;
1512
+ /**
1513
+ * Forces a full document navigation instead of client side routing and data
1514
+ * fetch.
1515
+ */
1516
+ reloadDocument?: boolean;
1517
+ /**
1518
+ * Replaces the current entry in the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1519
+ * stack when the form navigates. Use this if you don't want the user to be
1520
+ * able to click "back" to the page with the form on it.
1521
+ */
1522
+ replace?: boolean;
1523
+ /**
1524
+ * State object to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1525
+ * stack entry for this navigation
1526
+ */
1527
+ state?: any;
1528
+ /**
1529
+ * Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1530
+ * for this navigation. To apply specific styles during the transition, see
1531
+ * {@link useViewTransitionState}.
1532
+ */
1533
+ viewTransition?: boolean;
1534
+ }
1535
+ /**
1536
+ * A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
1537
+ * that submits data to actions via [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API),
1538
+ * activating pending states in {@link useNavigation} which enables advanced
1539
+ * user interfaces beyond a basic HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
1540
+ * After a form's `action` completes, all data on the page is automatically
1541
+ * revalidated to keep the UI in sync with the data.
1542
+ *
1543
+ * Because it uses the HTML form API, server rendered pages are interactive at a
1544
+ * basic level before JavaScript loads. Instead of React Router managing the
1545
+ * submission, the browser manages the submission as well as the pending states
1546
+ * (like the spinning favicon). After JavaScript loads, React Router takes over
1547
+ * enabling web application user experiences.
1548
+ *
1549
+ * `Form` is most useful for submissions that should also change the URL or
1550
+ * otherwise add an entry to the browser history stack. For forms that shouldn't
1551
+ * manipulate the browser history stack, use [`<fetcher.Form>`][fetcher_form].
1552
+ *
1553
+ * @example
1554
+ * import { Form } from "react-router";
1555
+ *
1556
+ * function NewEvent() {
1557
+ * return (
1558
+ * <Form action="/events" method="post">
1559
+ * <input name="title" type="text" />
1560
+ * <input name="description" type="text" />
1561
+ * </Form>
1562
+ * );
1563
+ * }
1564
+ *
1565
+ * @public
1566
+ * @category Components
1567
+ * @mode framework
1568
+ * @mode data
1569
+ * @param {FormProps.action} action n/a
1570
+ * @param {FormProps.discover} discover n/a
1571
+ * @param {FormProps.encType} encType n/a
1572
+ * @param {FormProps.fetcherKey} fetcherKey n/a
1573
+ * @param {FormProps.method} method n/a
1574
+ * @param {FormProps.navigate} navigate n/a
1575
+ * @param {FormProps.onSubmit} onSubmit n/a
1576
+ * @param {FormProps.preventScrollReset} preventScrollReset n/a
1577
+ * @param {FormProps.relative} relative n/a
1578
+ * @param {FormProps.reloadDocument} reloadDocument n/a
1579
+ * @param {FormProps.replace} replace n/a
1580
+ * @param {FormProps.state} state n/a
1581
+ * @param {FormProps.viewTransition} viewTransition n/a
1582
+ * @returns A progressively enhanced [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) component
1583
+ */
1584
+ declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
1585
+ type ScrollRestorationProps = ScriptsProps & {
1586
+ /**
1587
+ * A function that returns a key to use for scroll restoration. This is useful
1588
+ * for custom scroll restoration logic, such as using only the pathname so
1589
+ * that subsequent navigations to prior paths will restore the scroll. Defaults
1590
+ * to `location.key`. See {@link GetScrollRestorationKeyFunction}.
1591
+ *
1592
+ * ```tsx
1593
+ * <ScrollRestoration
1594
+ * getKey={(location, matches) => {
1595
+ * // Restore based on a unique location key (default behavior)
1596
+ * return location.key
1597
+ *
1598
+ * // Restore based on pathname
1599
+ * return location.pathname
1600
+ * }}
1601
+ * />
1602
+ * ```
1603
+ */
1604
+ getKey?: GetScrollRestorationKeyFunction;
1605
+ /**
1606
+ * The key to use for storing scroll positions in [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).
1607
+ * Defaults to `"react-router-scroll-positions"`.
1608
+ */
1609
+ storageKey?: string;
1610
+ };
1611
+ /**
1612
+ * Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
1613
+ *
1614
+ * ```tsx
1615
+ * import { ScrollRestoration } from "react-router";
1616
+ *
1617
+ * export default function Root() {
1618
+ * return (
1619
+ * <html>
1620
+ * <body>
1621
+ * <ScrollRestoration />
1622
+ * <Scripts />
1623
+ * </body>
1624
+ * </html>
1625
+ * );
1626
+ * }
1627
+ * ```
1628
+ *
1629
+ * This component renders an inline `<script>` to prevent scroll flashing. The `nonce` prop will be passed down to the script tag to allow CSP nonce usage.
1630
+ *
1631
+ * ```tsx
1632
+ * <ScrollRestoration nonce={cspNonce} />
1633
+ * ```
1634
+ *
1635
+ * @public
1636
+ * @category Components
1637
+ * @mode framework
1638
+ * @mode data
1639
+ * @param props Props
1640
+ * @param {ScrollRestorationProps.getKey} props.getKey n/a
1641
+ * @param {ScriptsProps.nonce} props.nonce n/a
1642
+ * @param {ScrollRestorationProps.storageKey} props.storageKey n/a
1643
+ * @returns A [`script`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
1644
+ * tag that restores scroll positions on navigation.
1645
+ */
1646
+ declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
1647
+ declare namespace ScrollRestoration {
1648
+ var displayName: string;
1649
+ }
1650
+ /**
1651
+ * Handles the click behavior for router {@link Link | `<Link>`} components.This
1652
+ * is useful if you need to create custom {@link Link | `<Link>`} components with
1653
+ * the same click behavior we use in our exported {@link Link | `<Link>`}.
1654
+ *
1655
+ * @public
1656
+ * @category Hooks
1657
+ * @param to The URL to navigate to, can be a string or a partial {@link Path}.
1658
+ * @param options Options
1659
+ * @param options.preventScrollReset Whether to prevent the scroll position from
1660
+ * being reset to the top of the viewport on completion of the navigation when
1661
+ * using the {@link ScrollRestoration} component. Defaults to `false`.
1662
+ * @param options.relative The {@link RelativeRoutingType | relative routing type}
1663
+ * to use for the link. Defaults to `"route"`.
1664
+ * @param options.replace Whether to replace the current [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1665
+ * entry instead of pushing a new one. Defaults to `false`.
1666
+ * @param options.state The state to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1667
+ * entry for this navigation. Defaults to `undefined`.
1668
+ * @param options.target The target attribute for the link. Defaults to `undefined`.
1669
+ * @param options.viewTransition Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1670
+ * for this navigation. To apply specific styles during the transition, see
1671
+ * {@link useViewTransitionState}. Defaults to `false`.
1672
+ * @returns A click handler function that can be used in a custom {@link Link} component.
1673
+ */
1674
+ declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
1675
+ target?: React.HTMLAttributeAnchorTarget;
1676
+ replace?: boolean;
1677
+ state?: any;
1678
+ preventScrollReset?: boolean;
1679
+ relative?: RelativeRoutingType;
1680
+ viewTransition?: boolean;
1681
+ }): (event: React.MouseEvent<E, MouseEvent>) => void;
1682
+ /**
1683
+ * Returns a tuple of the current URL's [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
1684
+ * and a function to update them. Setting the search params causes a navigation.
1685
+ *
1686
+ * ```tsx
1687
+ * import { useSearchParams } from "react-router";
1688
+ *
1689
+ * export function SomeComponent() {
1690
+ * const [searchParams, setSearchParams] = useSearchParams();
1691
+ * // ...
1692
+ * }
1693
+ * ```
1694
+ *
1695
+ * ### `setSearchParams` function
1696
+ *
1697
+ * The second element of the tuple is a function that can be used to update the
1698
+ * search params. It accepts the same types as `defaultInit` and will
1699
+ * cause a navigation to the new URL.
1700
+ *
1701
+ * ```tsx
1702
+ * let [searchParams, setSearchParams] = useSearchParams();
1703
+ *
1704
+ * // a search param string
1705
+ * setSearchParams("?tab=1");
1706
+ *
1707
+ * // a shorthand object
1708
+ * setSearchParams({ tab: "1" });
1709
+ *
1710
+ * // object keys can be arrays for multiple values on the key
1711
+ * setSearchParams({ brand: ["nike", "reebok"] });
1712
+ *
1713
+ * // an array of tuples
1714
+ * setSearchParams([["tab", "1"]]);
1715
+ *
1716
+ * // a `URLSearchParams` object
1717
+ * setSearchParams(new URLSearchParams("?tab=1"));
1718
+ * ```
1719
+ *
1720
+ * It also supports a function callback like React's [`setState`](https://react.dev/reference/react/useState#setstate):
1721
+ *
1722
+ * ```tsx
1723
+ * setSearchParams((searchParams) => {
1724
+ * searchParams.set("tab", "2");
1725
+ * return searchParams;
1726
+ * });
1727
+ * ```
1728
+ *
1729
+ * ### Notes
1730
+ *
1731
+ * Note that `searchParams` is a stable reference, so you can reliably use it
1732
+ * as a dependency in React's [`useEffect`](https://react.dev/reference/react/useEffect)
1733
+ * hooks.
1734
+ *
1735
+ * ```tsx
1736
+ * useEffect(() => {
1737
+ * console.log(searchParams.get("tab"));
1738
+ * }, [searchParams]);
1739
+ * ```
1740
+ *
1741
+ * However, this also means it's mutable. If you change the object without
1742
+ * calling `setSearchParams`, its values will change between renders if some
1743
+ * other state causes the component to re-render and URL will not reflect the
1744
+ * values.
1745
+ *
1746
+ * @public
1747
+ * @category Hooks
1748
+ * @param defaultInit
1749
+ * You can initialize the search params with a default value, though it **will
1750
+ * not** change the URL on the first render.
1751
+ *
1752
+ * ```tsx
1753
+ * // a search param string
1754
+ * useSearchParams("?tab=1");
1755
+ *
1756
+ * // a shorthand object
1757
+ * useSearchParams({ tab: "1" });
1758
+ *
1759
+ * // object keys can be arrays for multiple values on the key
1760
+ * useSearchParams({ brand: ["nike", "reebok"] });
1761
+ *
1762
+ * // an array of tuples
1763
+ * useSearchParams([["tab", "1"]]);
1764
+ *
1765
+ * // a `URLSearchParams` object
1766
+ * useSearchParams(new URLSearchParams("?tab=1"));
1767
+ * ```
1768
+ * @returns A tuple of the current [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
1769
+ * and a function to update them.
1770
+ */
1771
+ declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
1772
+ /**
1773
+ * Sets new search params and causes a navigation when called.
1774
+ *
1775
+ * ```tsx
1776
+ * <button
1777
+ * onClick={() => {
1778
+ * const params = new URLSearchParams();
1779
+ * params.set("someKey", "someValue");
1780
+ * setSearchParams(params, {
1781
+ * preventScrollReset: true,
1782
+ * });
1783
+ * }}
1784
+ * />
1785
+ * ```
1786
+ *
1787
+ * It also supports a function for setting new search params.
1788
+ *
1789
+ * ```tsx
1790
+ * <button
1791
+ * onClick={() => {
1792
+ * setSearchParams((prev) => {
1793
+ * prev.set("someKey", "someValue");
1794
+ * return prev;
1795
+ * });
1796
+ * }}
1797
+ * />
1798
+ * ```
1799
+ */
1800
+ type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
1801
+ /**
1802
+ * Submits a HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
1803
+ * to the server without reloading the page.
1804
+ */
1805
+ interface SubmitFunction {
1806
+ (
1807
+ /**
1808
+ * Can be multiple types of elements and objects
1809
+ *
1810
+ * **[`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)**
1811
+ *
1812
+ * ```tsx
1813
+ * <Form
1814
+ * onSubmit={(event) => {
1815
+ * submit(event.currentTarget);
1816
+ * }}
1817
+ * />
1818
+ * ```
1819
+ *
1820
+ * **[`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
1821
+ *
1822
+ * ```tsx
1823
+ * const formData = new FormData();
1824
+ * formData.append("myKey", "myValue");
1825
+ * submit(formData, { method: "post" });
1826
+ * ```
1827
+ *
1828
+ * **Plain object that will be serialized as [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
1829
+ *
1830
+ * ```tsx
1831
+ * submit({ myKey: "myValue" }, { method: "post" });
1832
+ * ```
1833
+ *
1834
+ * **Plain object that will be serialized as JSON**
1835
+ *
1836
+ * ```tsx
1837
+ * submit(
1838
+ * { myKey: "myValue" },
1839
+ * { method: "post", encType: "application/json" }
1840
+ * );
1841
+ * ```
1842
+ */
1843
+ target: SubmitTarget,
1844
+ /**
1845
+ * Options that override the [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)'s
1846
+ * own attributes. Required when submitting arbitrary data without a backing
1847
+ * [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
1848
+ */
1849
+ options?: SubmitOptions): Promise<void>;
1850
+ }
1851
+ /**
1852
+ * Submits a fetcher [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) to the server without reloading the page.
1853
+ */
1854
+ interface FetcherSubmitFunction {
1855
+ (
1856
+ /**
1857
+ * Can be multiple types of elements and objects
1858
+ *
1859
+ * **[`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)**
1860
+ *
1861
+ * ```tsx
1862
+ * <fetcher.Form
1863
+ * onSubmit={(event) => {
1864
+ * fetcher.submit(event.currentTarget);
1865
+ * }}
1866
+ * />
1867
+ * ```
1868
+ *
1869
+ * **[`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
1870
+ *
1871
+ * ```tsx
1872
+ * const formData = new FormData();
1873
+ * formData.append("myKey", "myValue");
1874
+ * fetcher.submit(formData, { method: "post" });
1875
+ * ```
1876
+ *
1877
+ * **Plain object that will be serialized as [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
1878
+ *
1879
+ * ```tsx
1880
+ * fetcher.submit({ myKey: "myValue" }, { method: "post" });
1881
+ * ```
1882
+ *
1883
+ * **Plain object that will be serialized as JSON**
1884
+ *
1885
+ * ```tsx
1886
+ * fetcher.submit(
1887
+ * { myKey: "myValue" },
1888
+ * { method: "post", encType: "application/json" }
1889
+ * );
1890
+ * ```
1891
+ */
1892
+ target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
1893
+ }
1894
+ /**
1895
+ * The imperative version of {@link Form | `<Form>`} that lets you submit a form
1896
+ * from code instead of a user interaction.
1897
+ *
1898
+ * @example
1899
+ * import { useSubmit } from "react-router";
1900
+ *
1901
+ * function SomeComponent() {
1902
+ * const submit = useSubmit();
1903
+ * return (
1904
+ * <Form onChange={(event) => submit(event.currentTarget)} />
1905
+ * );
1906
+ * }
1907
+ *
1908
+ * @public
1909
+ * @category Hooks
1910
+ * @mode framework
1911
+ * @mode data
1912
+ * @returns A function that can be called to submit a {@link Form} imperatively.
1913
+ */
1914
+ declare function useSubmit(): SubmitFunction;
1915
+ /**
1916
+ * Resolves the URL to the closest route in the component hierarchy instead of
1917
+ * the current URL of the app.
1918
+ *
1919
+ * This is used internally by {@link Form} to resolve the `action` to the closest
1920
+ * route, but can be used generically as well.
1921
+ *
1922
+ * @example
1923
+ * import { useFormAction } from "react-router";
1924
+ *
1925
+ * function SomeComponent() {
1926
+ * // closest route URL
1927
+ * let action = useFormAction();
1928
+ *
1929
+ * // closest route URL + "destroy"
1930
+ * let destroyAction = useFormAction("destroy");
1931
+ * }
1932
+ *
1933
+ * @public
1934
+ * @category Hooks
1935
+ * @mode framework
1936
+ * @mode data
1937
+ * @param action The action to append to the closest route URL. Defaults to the
1938
+ * closest route URL.
1939
+ * @param options Options
1940
+ * @param options.relative The relative routing type to use when resolving the
1941
+ * action. Defaults to `"route"`.
1942
+ * @returns The resolved action URL.
1943
+ */
1944
+ declare function useFormAction(action?: string, { relative }?: {
1945
+ relative?: RelativeRoutingType;
1946
+ }): string;
1947
+ /**
1948
+ * The return value {@link useFetcher} that keeps track of the state of a fetcher.
1949
+ *
1950
+ * ```tsx
1951
+ * let fetcher = useFetcher();
1952
+ * ```
1953
+ */
1954
+ type FetcherWithComponents<TData> = Fetcher<TData> & {
1955
+ /**
1956
+ * Just like {@link Form} except it doesn't cause a navigation.
1957
+ *
1958
+ * ```tsx
1959
+ * function SomeComponent() {
1960
+ * const fetcher = useFetcher()
1961
+ * return (
1962
+ * <fetcher.Form method="post" action="/some/route">
1963
+ * <input type="text" />
1964
+ * </fetcher.Form>
1965
+ * )
1966
+ * }
1967
+ * ```
1968
+ */
1969
+ Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
1970
+ /**
1971
+ * Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
1972
+ *
1973
+ * The `formData` can be multiple types:
1974
+ *
1975
+ * - [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
1976
+ * A `FormData` instance.
1977
+ * - [`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)
1978
+ * A [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) DOM element.
1979
+ * - `Object`
1980
+ * An object of key/value-pairs that will be converted to a [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
1981
+ * instance by default. You can pass a more complex object and serialize it
1982
+ * as JSON by specifying `encType: "application/json"`. See
1983
+ * {@link useSubmit} for more details.
1984
+ *
1985
+ * If the method is `GET`, then the route [`loader`](../../start/framework/route-module#loader)
1986
+ * is being called and with the `formData` serialized to the url as [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
1987
+ * If `DELETE`, `PATCH`, `POST`, or `PUT`, then the route [`action`](../../start/framework/route-module#action)
1988
+ * is being called with `formData` as the body.
1989
+ *
1990
+ * ```tsx
1991
+ * // Submit a FormData instance (GET request)
1992
+ * const formData = new FormData();
1993
+ * fetcher.submit(formData);
1994
+ *
1995
+ * // Submit the HTML form element
1996
+ * fetcher.submit(event.currentTarget.form, {
1997
+ * method: "POST",
1998
+ * });
1999
+ *
2000
+ * // Submit key/value JSON as a FormData instance
2001
+ * fetcher.submit(
2002
+ * { serialized: "values" },
2003
+ * { method: "POST" }
2004
+ * );
2005
+ *
2006
+ * // Submit raw JSON
2007
+ * fetcher.submit(
2008
+ * {
2009
+ * deeply: {
2010
+ * nested: {
2011
+ * json: "values",
2012
+ * },
2013
+ * },
2014
+ * },
2015
+ * {
2016
+ * method: "POST",
2017
+ * encType: "application/json",
2018
+ * }
2019
+ * );
2020
+ * ```
2021
+ */
2022
+ submit: FetcherSubmitFunction;
2023
+ /**
2024
+ * Loads data from a route. Useful for loading data imperatively inside user
2025
+ * events outside a normal button or form, like a combobox or search input.
2026
+ *
2027
+ * ```tsx
2028
+ * let fetcher = useFetcher()
2029
+ *
2030
+ * <input onChange={e => {
2031
+ * fetcher.load(`/search?q=${e.target.value}`)
2032
+ * }} />
2033
+ * ```
2034
+ */
2035
+ load: (href: string, opts?: {
2036
+ /**
2037
+ * Wraps the initial state update for this `fetcher.load` in a
2038
+ * [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
2039
+ * call instead of the default [`React.startTransition`](https://react.dev/reference/react/startTransition).
2040
+ * This allows you to perform synchronous DOM actions immediately after the
2041
+ * update is flushed to the DOM.
2042
+ */
2043
+ flushSync?: boolean;
2044
+ }) => Promise<void>;
2045
+ };
2046
+ /**
2047
+ * Useful for creating complex, dynamic user interfaces that require multiple,
2048
+ * concurrent data interactions without causing a navigation.
2049
+ *
2050
+ * Fetchers track their own, independent state and can be used to load data, submit
2051
+ * forms, and generally interact with [`action`](../../start/framework/route-module#action)
2052
+ * and [`loader`](../../start/framework/route-module#loader) functions.
2053
+ *
2054
+ * @example
2055
+ * import { useFetcher } from "react-router"
2056
+ *
2057
+ * function SomeComponent() {
2058
+ * let fetcher = useFetcher()
2059
+ *
2060
+ * // states are available on the fetcher
2061
+ * fetcher.state // "idle" | "loading" | "submitting"
2062
+ * fetcher.data // the data returned from the action or loader
2063
+ *
2064
+ * // render a form
2065
+ * <fetcher.Form method="post" />
2066
+ *
2067
+ * // load data
2068
+ * fetcher.load("/some/route")
2069
+ *
2070
+ * // submit data
2071
+ * fetcher.submit(someFormRef, { method: "post" })
2072
+ * fetcher.submit(someData, {
2073
+ * method: "post",
2074
+ * encType: "application/json"
2075
+ * })
2076
+ * }
2077
+ *
2078
+ * @public
2079
+ * @category Hooks
2080
+ * @mode framework
2081
+ * @mode data
2082
+ * @param options Options
2083
+ * @param options.key A unique key to identify the fetcher.
2084
+ *
2085
+ * By default, `useFetcher` generates a unique fetcher scoped to that component.
2086
+ * If you want to identify a fetcher with your own key such that you can access
2087
+ * it from elsewhere in your app, you can do that with the `key` option:
2088
+ *
2089
+ * ```tsx
2090
+ * function SomeComp() {
2091
+ * let fetcher = useFetcher({ key: "my-key" })
2092
+ * // ...
2093
+ * }
2094
+ *
2095
+ * // Somewhere else
2096
+ * function AnotherComp() {
2097
+ * // this will be the same fetcher, sharing the state across the app
2098
+ * let fetcher = useFetcher({ key: "my-key" });
2099
+ * // ...
2100
+ * }
2101
+ * ```
2102
+ * @returns A {@link FetcherWithComponents} object that contains the fetcher's state, data, and components for submitting forms and loading data.
2103
+ */
2104
+ declare function useFetcher<T = any>({ key, }?: {
2105
+ key?: string;
2106
+ }): FetcherWithComponents<SerializeFrom<T>>;
2107
+ /**
2108
+ * Returns an array of all in-flight {@link Fetcher}s. This is useful for components
2109
+ * throughout the app that didn't create the fetchers but want to use their submissions
2110
+ * to participate in optimistic UI.
2111
+ *
2112
+ * @example
2113
+ * import { useFetchers } from "react-router";
2114
+ *
2115
+ * function SomeComponent() {
2116
+ * const fetchers = useFetchers();
2117
+ * fetchers[0].formData; // FormData
2118
+ * fetchers[0].state; // etc.
2119
+ * // ...
2120
+ * }
2121
+ *
2122
+ * @public
2123
+ * @category Hooks
2124
+ * @mode framework
2125
+ * @mode data
2126
+ * @returns An array of all in-flight {@link Fetcher}s, each with a unique `key`
2127
+ * property.
2128
+ */
2129
+ declare function useFetchers(): (Fetcher & {
2130
+ key: string;
2131
+ })[];
2132
+ /**
2133
+ * When rendered inside a {@link RouterProvider}, will restore scroll positions
2134
+ * on navigations
2135
+ *
2136
+ * <!--
2137
+ * Not marked `@public` because we only export as UNSAFE_ and therefore we don't
2138
+ * maintain an .md file for this hook
2139
+ * -->
2140
+ *
2141
+ * @name UNSAFE_useScrollRestoration
2142
+ * @category Hooks
2143
+ * @mode framework
2144
+ * @mode data
2145
+ * @param options Options
2146
+ * @param options.getKey A function that returns a key to use for scroll restoration.
2147
+ * This is useful for custom scroll restoration logic, such as using only the pathname
2148
+ * so that subsequent navigations to prior paths will restore the scroll. Defaults
2149
+ * to `location.key`.
2150
+ * @param options.storageKey The key to use for storing scroll positions in
2151
+ * `sessionStorage`. Defaults to `"react-router-scroll-positions"`.
2152
+ * @returns {void}
2153
+ */
2154
+ declare function useScrollRestoration({ getKey, storageKey, }?: {
2155
+ getKey?: GetScrollRestorationKeyFunction;
2156
+ storageKey?: string;
2157
+ }): void;
2158
+ /**
2159
+ * Set up a callback to be fired on [Window's `beforeunload` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event).
2160
+ *
2161
+ * @public
2162
+ * @category Hooks
2163
+ * @param callback The callback to be called when the [`beforeunload` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event)
2164
+ * is fired.
2165
+ * @param options Options
2166
+ * @param options.capture If `true`, the event will be captured during the capture
2167
+ * phase. Defaults to `false`.
2168
+ * @returns {void}
2169
+ */
2170
+ declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
2171
+ capture?: boolean;
2172
+ }): void;
2173
+ /**
2174
+ * Wrapper around {@link useBlocker} to show a [`window.confirm`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm)
2175
+ * prompt to users instead of building a custom UI with {@link useBlocker}.
2176
+ *
2177
+ * The `unstable_` flag will not be removed because this technique has a lot of
2178
+ * rough edges and behaves very differently (and incorrectly sometimes) across
2179
+ * browsers if users click addition back/forward navigations while the
2180
+ * confirmation is open. Use at your own risk.
2181
+ *
2182
+ * @example
2183
+ * function ImportantForm() {
2184
+ * let [value, setValue] = React.useState("");
2185
+ *
2186
+ * // Block navigating elsewhere when data has been entered into the input
2187
+ * unstable_usePrompt({
2188
+ * message: "Are you sure?",
2189
+ * when: ({ currentLocation, nextLocation }) =>
2190
+ * value !== "" &&
2191
+ * currentLocation.pathname !== nextLocation.pathname,
2192
+ * });
2193
+ *
2194
+ * return (
2195
+ * <Form method="post">
2196
+ * <label>
2197
+ * Enter some important data:
2198
+ * <input
2199
+ * name="data"
2200
+ * value={value}
2201
+ * onChange={(e) => setValue(e.target.value)}
2202
+ * />
2203
+ * </label>
2204
+ * <button type="submit">Save</button>
2205
+ * </Form>
2206
+ * );
2207
+ * }
2208
+ *
2209
+ * @name unstable_usePrompt
2210
+ * @public
2211
+ * @category Hooks
2212
+ * @mode framework
2213
+ * @mode data
2214
+ * @param options Options
2215
+ * @param options.message The message to show in the confirmation dialog.
2216
+ * @param options.when A boolean or a function that returns a boolean indicating
2217
+ * whether to block the navigation. If a function is provided, it will receive an
2218
+ * object with `currentLocation` and `nextLocation` properties.
2219
+ * @returns {void}
2220
+ */
2221
+ declare function usePrompt({ when, message, }: {
2222
+ when: boolean | BlockerFunction;
2223
+ message: string;
2224
+ }): void;
2225
+ /**
2226
+ * This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
2227
+ * to the specified location. This can be used to apply finer-grained styles to
2228
+ * elements to further customize the view transition. This requires that view
2229
+ * transitions have been enabled for the given navigation via {@link LinkProps.viewTransition}
2230
+ * (or the `Form`, `submit`, or `navigate` call)
2231
+ *
2232
+ * @public
2233
+ * @category Hooks
2234
+ * @mode framework
2235
+ * @mode data
2236
+ * @param to The {@link To} location to check for an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API).
2237
+ * @param options Options
2238
+ * @param options.relative The relative routing type to use when resolving the
2239
+ * `to` location, defaults to `"route"`. See {@link RelativeRoutingType} for more details.
2240
+ * @returns `true` if there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
2241
+ * to the specified {@link Location}, otherwise `false`.
2242
+ */
2243
+ declare function useViewTransitionState(to: To, { relative }?: {
2244
+ relative?: RelativeRoutingType;
2245
+ }): boolean;
2246
+
2247
+ interface StaticRouterProps {
2248
+ basename?: string;
2249
+ children?: React.ReactNode;
2250
+ location: Partial<Location> | string;
2251
+ }
2252
+ /**
2253
+ * A `<Router>` that may not navigate to any other location. This is useful
2254
+ * on the server where there is no stateful UI.
2255
+ *
2256
+ * @public
2257
+ * @category Declarative Routers
2258
+ * @mode declarative
2259
+ * @param props Props
2260
+ * @param props.basename The base URL for the static router (default: `/`)
2261
+ * @param props.children The child elements to render inside the static router
2262
+ * @param props.location The location to render the static router at (default: `/`)
2263
+ * @returns A React element that renders the static router
2264
+ */
2265
+ declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
2266
+ interface StaticRouterProviderProps {
2267
+ context: StaticHandlerContext;
2268
+ router: Router;
2269
+ hydrate?: boolean;
2270
+ nonce?: string;
2271
+ }
2272
+ /**
2273
+ * A Data Router that may not navigate to any other location. This is useful
2274
+ * on the server where there is no stateful UI.
2275
+ *
2276
+ * @example
2277
+ * export async function handleRequest(request: Request) {
2278
+ * let { query, dataRoutes } = createStaticHandler(routes);
2279
+ * let context = await query(request));
2280
+ *
2281
+ * if (context instanceof Response) {
2282
+ * return context;
2283
+ * }
2284
+ *
2285
+ * let router = createStaticRouter(dataRoutes, context);
2286
+ * return new Response(
2287
+ * ReactDOMServer.renderToString(<StaticRouterProvider ... />),
2288
+ * { headers: { "Content-Type": "text/html" } }
2289
+ * );
2290
+ * }
2291
+ *
2292
+ * @public
2293
+ * @category Data Routers
2294
+ * @mode data
2295
+ * @param props Props
2296
+ * @param props.context The {@link StaticHandlerContext} returned from `staticHandler.query()`
2297
+ * @param props.router The static data router from {@link createStaticRouter}
2298
+ * @param props.hydrate Whether to hydrate the router on the client (default `true`)
2299
+ * @param props.nonce The [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
2300
+ * to use for the hydration `<script>` tag
2301
+ * @returns A React element that renders the static router provider
2302
+ */
2303
+ declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
2304
+ type CreateStaticHandlerOptions = Omit<CreateStaticHandlerOptions$1, "mapRouteProperties">;
2305
+ /**
2306
+ * Create a static handler to perform server-side data loading
2307
+ *
2308
+ * @example
2309
+ * export async function handleRequest(request: Request) {
2310
+ * let { query, dataRoutes } = createStaticHandler(routes);
2311
+ * let context = await query(request));
2312
+ *
2313
+ * if (context instanceof Response) {
2314
+ * return context;
2315
+ * }
2316
+ *
2317
+ * let router = createStaticRouter(dataRoutes, context);
2318
+ * return new Response(
2319
+ * ReactDOMServer.renderToString(<StaticRouterProvider ... />),
2320
+ * { headers: { "Content-Type": "text/html" } }
2321
+ * );
2322
+ * }
2323
+ *
2324
+ * @public
2325
+ * @category Data Routers
2326
+ * @mode data
2327
+ * @param routes The route objects to create a static handler for
2328
+ * @param opts Options
2329
+ * @param opts.basename The base URL for the static handler (default: `/`)
2330
+ * @param opts.future Future flags for the static handler
2331
+ * @returns A static handler that can be used to query data for the provided routes
2332
+ */
2333
+ declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
2334
+ /**
2335
+ * Create a static data router for server-side rendering
2336
+ *
2337
+ * @example
2338
+ * export async function handleRequest(request: Request) {
2339
+ * let { query, dataRoutes } = createStaticHandler(routes);
2340
+ * let context = await query(request));
2341
+ *
2342
+ * if (context instanceof Response) {
2343
+ * return context;
2344
+ * }
2345
+ *
2346
+ * let router = createStaticRouter(dataRoutes, context);
2347
+ * return new Response(
2348
+ * ReactDOMServer.renderToString(<StaticRouterProvider ... />),
2349
+ * { headers: { "Content-Type": "text/html" } }
2350
+ * );
2351
+ * }
2352
+ *
2353
+ * @public
2354
+ * @category Data Routers
2355
+ * @mode data
2356
+ * @param routes The route objects to create a static data router for
2357
+ * @param context The static handler context returned from `staticHandler.query()`
2358
+ * @param opts Options
2359
+ * @param opts.future Future flags for the static data router
2360
+ * @returns A static data router that can be used to render the provided routes
2361
+ */
2362
+ declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
2363
+ future?: Partial<FutureConfig$1>;
2364
+ }): Router;
2365
+
2366
+ export { type PrefetchBehavior as $, type AssetsManifest as A, type BrowserRouterProps as B, useViewTransitionState as C, type DOMRouterOpts as D, type EntryContext as E, type FutureConfig as F, type FetcherSubmitOptions as G, type HashRouterProps as H, type SubmitOptions as I, type SubmitTarget as J, createSearchParams as K, type LinkProps as L, type StaticRouterProps as M, type NavLinkProps as N, type StaticRouterProviderProps as O, type ParamKeyValuePair as P, createStaticHandler as Q, createStaticRouter as R, type ServerBuild as S, StaticRouter as T, type URLSearchParamsInit as U, StaticRouterProvider as V, Meta as W, Links as X, Scripts as Y, PrefetchPageLinks as Z, type ScriptsProps as _, type HistoryRouterProps as a, type DiscoverBehavior as a0, type HandleDataRequestFunction as a1, type HandleDocumentRequestFunction as a2, type HandleErrorFunction as a3, type ServerEntryModule as a4, FrameworkContext as a5, createClientRoutes as a6, createClientRoutesWithHMRRevalidationOptOut as a7, shouldHydrateRouteLoader as a8, useScrollRestoration as a9, type NavLinkRenderProps as b, type FetcherFormProps as c, type FormProps as d, type ScrollRestorationProps as e, type SetURLSearchParams as f, type SubmitFunction as g, type FetcherSubmitFunction as h, type FetcherWithComponents as i, createBrowserRouter as j, createHashRouter as k, BrowserRouter as l, HashRouter as m, Link as n, HistoryRouter as o, NavLink as p, Form as q, ScrollRestoration as r, useSearchParams as s, useSubmit as t, useLinkClickHandler as u, useFormAction as v, useFetcher as w, useFetchers as x, useBeforeUnload as y, usePrompt as z };