UNPKG

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