react-router 7.0.0-pre.5 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +98 -184
  2. package/dist/{chunk-ICGFMBUV.mjs → development/chunk-U6WQEHBI.mjs} +4 -3
  3. package/dist/development/data-CQbyyGzl.d.mts +11 -0
  4. package/dist/development/data-CQbyyGzl.d.ts +11 -0
  5. package/dist/development/dom-export.d.mts +13 -0
  6. package/dist/{dom-export.d.ts → development/dom-export.d.ts} +2 -2
  7. package/dist/{dom-export.js → development/dom-export.js} +1 -1
  8. package/dist/{dom-export.mjs → development/dom-export.mjs} +2 -2
  9. package/dist/development/fog-of-war-BDQTYoRQ.d.mts +1595 -0
  10. package/dist/{fog-of-war-BijhfqFM.d.ts → development/fog-of-war-CbNQuoo8.d.ts} +2 -2
  11. package/dist/development/index.d.mts +840 -0
  12. package/dist/{index.d.ts → development/index.d.ts} +6 -5
  13. package/dist/{index.js → development/index.js} +4 -3
  14. package/dist/{index.mjs → development/index.mjs} +2 -2
  15. package/dist/development/lib/types/route-module.d.mts +102 -0
  16. package/dist/development/lib/types/route-module.d.ts +102 -0
  17. package/dist/{lib/types.js → development/lib/types/route-module.js} +4 -4
  18. package/dist/{lib/types.mjs → development/lib/types/route-module.mjs} +1 -1
  19. package/dist/{types-BlYP8xpH.d.mts → development/route-data-DuV3tXo2.d.mts} +20 -94
  20. package/dist/{types-BlYP8xpH.d.ts → development/route-data-DuV3tXo2.d.ts} +20 -94
  21. package/dist/production/chunk-L6MGG5FJ.mjs +9618 -0
  22. package/dist/production/data-CQbyyGzl.d.mts +11 -0
  23. package/dist/production/data-CQbyyGzl.d.ts +11 -0
  24. package/dist/production/dom-export.d.mts +13 -0
  25. package/dist/{dom-export.d.mts → production/dom-export.d.ts} +2 -2
  26. package/dist/production/dom-export.js +5502 -0
  27. package/dist/production/dom-export.mjs +199 -0
  28. package/dist/production/fog-of-war-BDQTYoRQ.d.mts +1595 -0
  29. package/dist/{fog-of-war-Bz_EDtxF.d.mts → production/fog-of-war-CbNQuoo8.d.ts} +2 -2
  30. package/dist/production/index.d.mts +840 -0
  31. package/dist/{index.d.mts → production/index.d.ts} +6 -5
  32. package/dist/production/index.js +9764 -0
  33. package/dist/production/index.mjs +235 -0
  34. package/dist/production/lib/types/route-module.d.mts +102 -0
  35. package/dist/production/lib/types/route-module.d.ts +102 -0
  36. package/dist/production/lib/types/route-module.js +28 -0
  37. package/dist/production/lib/types/route-module.mjs +10 -0
  38. package/dist/production/route-data-DuV3tXo2.d.mts +1546 -0
  39. package/dist/production/route-data-DuV3tXo2.d.ts +1546 -0
  40. package/package.json +37 -23
  41. package/dist/lib/types.d.mts +0 -2
  42. package/dist/lib/types.d.ts +0 -2
@@ -0,0 +1,1595 @@
1
+ import * as React from 'react';
2
+ import { n as RouteObject, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, am as PatchRoutesOnNavigationFunction, a as Router$1, T as To, g as RelativeRoutingType, v as NonIndexRouteObject, a0 as LazyRouteFunction, u as IndexRouteObject, h as Location, i as Action, al as Navigator, ao as RouteMatch, r as StaticHandlerContext, d as RouteManifest, R as RouteModules, ak as DataRouteObject, aH as RouteModule, $ as HTMLFormMethod, Z as FormEncType, at as PageLinkDescriptor, aI as History, x as GetScrollRestorationKeyFunction, N as NavigateOptions, y as Fetcher, S as SerializeFrom, B as BlockerFunction } from './route-data-DuV3tXo2.mjs';
3
+
4
+ /**
5
+ * @private
6
+ */
7
+ declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
8
+ hasErrorBoundary: boolean;
9
+ };
10
+ /**
11
+ * @category Routers
12
+ */
13
+ declare function createMemoryRouter(routes: RouteObject[], opts?: {
14
+ basename?: string;
15
+ future?: Partial<FutureConfig$1>;
16
+ hydrationData?: HydrationState;
17
+ initialEntries?: InitialEntry[];
18
+ initialIndex?: number;
19
+ dataStrategy?: DataStrategyFunction;
20
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
21
+ }): Router$1;
22
+ interface RouterProviderProps {
23
+ router: Router$1;
24
+ flushSync?: (fn: () => unknown) => undefined;
25
+ }
26
+ /**
27
+ * Given a Remix Router instance, render the appropriate UI
28
+ */
29
+ declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
30
+ /**
31
+ * @category Types
32
+ */
33
+ interface MemoryRouterProps {
34
+ basename?: string;
35
+ children?: React.ReactNode;
36
+ initialEntries?: InitialEntry[];
37
+ initialIndex?: number;
38
+ }
39
+ /**
40
+ * A `<Router>` that stores all entries in memory.
41
+ *
42
+ * @category Router Components
43
+ */
44
+ declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
45
+ /**
46
+ * @category Types
47
+ */
48
+ interface NavigateProps {
49
+ to: To;
50
+ replace?: boolean;
51
+ state?: any;
52
+ relative?: RelativeRoutingType;
53
+ }
54
+ /**
55
+ * A component-based version of {@link useNavigate} to use in a [`React.Component
56
+ * Class`](https://reactjs.org/docs/react-component.html) where hooks are not
57
+ * able to be used.
58
+ *
59
+ * It's recommended to avoid using this component in favor of {@link useNavigate}
60
+ *
61
+ * @category Components
62
+ */
63
+ declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
64
+ /**
65
+ * @category Types
66
+ */
67
+ interface OutletProps {
68
+ /**
69
+ Provides a context value to the element tree below the outlet. Use when the parent route needs to provide values to child routes.
70
+
71
+ ```tsx
72
+ <Outlet context={myContextValue} />
73
+ ```
74
+
75
+ Access the context with {@link useOutletContext}.
76
+ */
77
+ context?: unknown;
78
+ }
79
+ /**
80
+ Renders the matching child route of a parent route or nothing if no child route matches.
81
+
82
+ ```tsx
83
+ import { Outlet } from "react-router"
84
+
85
+ export default function SomeParent() {
86
+ return (
87
+ <div>
88
+ <h1>Parent Content</h1>
89
+ <Outlet />
90
+ </div>
91
+ );
92
+ }
93
+ ```
94
+
95
+ @category Components
96
+ */
97
+ declare function Outlet(props: OutletProps): React.ReactElement | null;
98
+ /**
99
+ * @category Types
100
+ */
101
+ interface PathRouteProps {
102
+ caseSensitive?: NonIndexRouteObject["caseSensitive"];
103
+ path?: NonIndexRouteObject["path"];
104
+ id?: NonIndexRouteObject["id"];
105
+ lazy?: LazyRouteFunction<NonIndexRouteObject>;
106
+ loader?: NonIndexRouteObject["loader"];
107
+ action?: NonIndexRouteObject["action"];
108
+ hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
109
+ shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
110
+ handle?: NonIndexRouteObject["handle"];
111
+ index?: false;
112
+ children?: React.ReactNode;
113
+ element?: React.ReactNode | null;
114
+ hydrateFallbackElement?: React.ReactNode | null;
115
+ errorElement?: React.ReactNode | null;
116
+ Component?: React.ComponentType | null;
117
+ HydrateFallback?: React.ComponentType | null;
118
+ ErrorBoundary?: React.ComponentType | null;
119
+ }
120
+ /**
121
+ * @category Types
122
+ */
123
+ interface LayoutRouteProps extends PathRouteProps {
124
+ }
125
+ /**
126
+ * @category Types
127
+ */
128
+ interface IndexRouteProps {
129
+ caseSensitive?: IndexRouteObject["caseSensitive"];
130
+ path?: IndexRouteObject["path"];
131
+ id?: IndexRouteObject["id"];
132
+ lazy?: LazyRouteFunction<IndexRouteObject>;
133
+ loader?: IndexRouteObject["loader"];
134
+ action?: IndexRouteObject["action"];
135
+ hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
136
+ shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
137
+ handle?: IndexRouteObject["handle"];
138
+ index: true;
139
+ children?: undefined;
140
+ element?: React.ReactNode | null;
141
+ hydrateFallbackElement?: React.ReactNode | null;
142
+ errorElement?: React.ReactNode | null;
143
+ Component?: React.ComponentType | null;
144
+ HydrateFallback?: React.ComponentType | null;
145
+ ErrorBoundary?: React.ComponentType | null;
146
+ }
147
+ type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
148
+ /**
149
+ * Configures an element to render when a pattern matches the current location.
150
+ * It must be rendered within a {@link Routes} element. Note that these routes
151
+ * do not participate in data loading, actions, code splitting, or any other
152
+ * route module features.
153
+ *
154
+ * @category Components
155
+ */
156
+ declare function Route$1(_props: RouteProps): React.ReactElement | null;
157
+ /**
158
+ * @category Types
159
+ */
160
+ interface RouterProps {
161
+ basename?: string;
162
+ children?: React.ReactNode;
163
+ location: Partial<Location> | string;
164
+ navigationType?: Action;
165
+ navigator: Navigator;
166
+ static?: boolean;
167
+ }
168
+ /**
169
+ * Provides location context for the rest of the app.
170
+ *
171
+ * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
172
+ * router that is more specific to your environment such as a `<BrowserRouter>`
173
+ * in web browsers or a `<StaticRouter>` for server rendering.
174
+ *
175
+ * @category Components
176
+ */
177
+ declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
178
+ /**
179
+ * @category Types
180
+ */
181
+ interface RoutesProps {
182
+ /**
183
+ * Nested {@link Route} elements
184
+ */
185
+ children?: React.ReactNode;
186
+ /**
187
+ * The location to match against. Defaults to the current location.
188
+ */
189
+ location?: Partial<Location> | string;
190
+ }
191
+ /**
192
+ Renders a branch of {@link Route | `<Routes>`} that best matches the current
193
+ location. Note that these routes do not participate in data loading, actions,
194
+ code splitting, or any other route module features.
195
+
196
+ ```tsx
197
+ import { Routes, Route } from "react-router"
198
+
199
+ <Routes>
200
+ <Route index element={<StepOne />} />
201
+ <Route path="step-2" element={<StepTwo />} />
202
+ <Route path="step-3" element={<StepThree />}>
203
+ </Routes>
204
+ ```
205
+
206
+ @category Components
207
+ */
208
+ declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
209
+ interface AwaitResolveRenderFunction<Resolve = any> {
210
+ (data: Awaited<Resolve>): React.ReactNode;
211
+ }
212
+ /**
213
+ * @category Types
214
+ */
215
+ interface AwaitProps<Resolve> {
216
+ /**
217
+ When using a function, the resolved value is provided as the parameter.
218
+
219
+ ```tsx [2]
220
+ <Await resolve={reviewsPromise}>
221
+ {(resolvedReviews) => <Reviews items={resolvedReviews} />}
222
+ </Await>
223
+ ```
224
+
225
+ When using React elements, {@link useAsyncValue} will provide the
226
+ resolved value:
227
+
228
+ ```tsx [2]
229
+ <Await resolve={reviewsPromise}>
230
+ <Reviews />
231
+ </Await>
232
+
233
+ function Reviews() {
234
+ const resolvedReviews = useAsyncValue()
235
+ return <div>...</div>
236
+ }
237
+ ```
238
+ */
239
+ children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
240
+ /**
241
+ The error element renders instead of the children when the promise rejects.
242
+
243
+ ```tsx
244
+ <Await
245
+ errorElement={<div>Oops</div>}
246
+ resolve={reviewsPromise}
247
+ >
248
+ <Reviews />
249
+ </Await>
250
+ ```
251
+
252
+ To provide a more contextual error, you can use the {@link useAsyncError} in a
253
+ child component
254
+
255
+ ```tsx
256
+ <Await
257
+ errorElement={<ReviewsError />}
258
+ resolve={reviewsPromise}
259
+ >
260
+ <Reviews />
261
+ </Await>
262
+
263
+ function ReviewsError() {
264
+ const error = useAsyncError()
265
+ return <div>Error loading reviews: {error.message}</div>
266
+ }
267
+ ```
268
+
269
+ If you do not provide an errorElement, the rejected value will bubble up to
270
+ the nearest route-level {@link NonIndexRouteObject#ErrorBoundary | ErrorBoundary} and be accessible
271
+ via {@link useRouteError} hook.
272
+ */
273
+ errorElement?: React.ReactNode;
274
+ /**
275
+ Takes a promise returned from a {@link LoaderFunction | loader} value to be resolved and rendered.
276
+
277
+ ```jsx
278
+ import { useLoaderData, Await } from "react-router"
279
+
280
+ export async function loader() {
281
+ let reviews = getReviews() // not awaited
282
+ let book = await getBook()
283
+ return {
284
+ book,
285
+ reviews, // this is a promise
286
+ }
287
+ }
288
+
289
+ export default function Book() {
290
+ const {
291
+ book,
292
+ reviews, // this is the same promise
293
+ } = useLoaderData()
294
+
295
+ return (
296
+ <div>
297
+ <h1>{book.title}</h1>
298
+ <p>{book.description}</p>
299
+ <React.Suspense fallback={<ReviewsSkeleton />}>
300
+ <Await
301
+ // and is the promise we pass to Await
302
+ resolve={reviews}
303
+ >
304
+ <Reviews />
305
+ </Await>
306
+ </React.Suspense>
307
+ </div>
308
+ );
309
+ }
310
+ ```
311
+ */
312
+ resolve: Resolve;
313
+ }
314
+ /**
315
+ Used to render promise values with automatic error handling.
316
+
317
+ ```tsx
318
+ import { Await, useLoaderData } from "react-router";
319
+
320
+ export function loader() {
321
+ // not awaited
322
+ const reviews = getReviews()
323
+ // awaited (blocks the transition)
324
+ const book = await fetch("/api/book").then((res) => res.json())
325
+ return { book, reviews }
326
+ }
327
+
328
+ function Book() {
329
+ const { book, reviews } = useLoaderData();
330
+ return (
331
+ <div>
332
+ <h1>{book.title}</h1>
333
+ <p>{book.description}</p>
334
+ <React.Suspense fallback={<ReviewsSkeleton />}>
335
+ <Await
336
+ resolve={reviews}
337
+ errorElement={
338
+ <div>Could not load reviews 😬</div>
339
+ }
340
+ children={(resolvedReviews) => (
341
+ <Reviews items={resolvedReviews} />
342
+ )}
343
+ />
344
+ </React.Suspense>
345
+ </div>
346
+ );
347
+ }
348
+ ```
349
+
350
+ **Note:** `<Await>` expects to be rendered inside of a `<React.Suspense>`
351
+
352
+ @category Components
353
+
354
+ */
355
+ declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
356
+ /**
357
+ * Creates a route config from a React "children" object, which is usually
358
+ * either a `<Route>` element or an array of them. Used internally by
359
+ * `<Routes>` to create a route config from its children.
360
+ *
361
+ * @category Utils
362
+ */
363
+ declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
364
+ /**
365
+ * Renders the result of `matchRoutes()` into a React element.
366
+ *
367
+ * @category Utils
368
+ */
369
+ declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
370
+
371
+ type SerializedError = {
372
+ message: string;
373
+ stack?: string;
374
+ };
375
+ interface FrameworkContextObject {
376
+ manifest: AssetsManifest;
377
+ routeModules: RouteModules;
378
+ criticalCss?: string;
379
+ serverHandoffString?: string;
380
+ future: FutureConfig;
381
+ isSpaMode: boolean;
382
+ abortDelay?: number;
383
+ serializeError?(error: Error): SerializedError;
384
+ renderMeta?: {
385
+ didRenderScripts?: boolean;
386
+ streamCache?: Record<number, Promise<void> & {
387
+ result?: {
388
+ done: boolean;
389
+ value: string;
390
+ };
391
+ error?: unknown;
392
+ }>;
393
+ };
394
+ }
395
+ interface EntryContext extends FrameworkContextObject {
396
+ staticHandlerContext: StaticHandlerContext;
397
+ serverHandoffStream?: ReadableStream<Uint8Array>;
398
+ }
399
+ interface FutureConfig {
400
+ }
401
+ interface AssetsManifest {
402
+ entry: {
403
+ imports: string[];
404
+ module: string;
405
+ };
406
+ routes: RouteManifest<EntryRoute>;
407
+ url: string;
408
+ version: string;
409
+ hmr?: {
410
+ timestamp?: number;
411
+ runtime: string;
412
+ };
413
+ }
414
+
415
+ interface Route {
416
+ index?: boolean;
417
+ caseSensitive?: boolean;
418
+ id: string;
419
+ parentId?: string;
420
+ path?: string;
421
+ }
422
+ interface EntryRoute extends Route {
423
+ hasAction: boolean;
424
+ hasLoader: boolean;
425
+ hasClientAction: boolean;
426
+ hasClientLoader: boolean;
427
+ hasErrorBoundary: boolean;
428
+ imports?: string[];
429
+ css?: string[];
430
+ module: string;
431
+ parentId?: string;
432
+ }
433
+ declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, future: FutureConfig, isSpaMode: boolean): DataRouteObject[];
434
+ declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
435
+ declare function shouldHydrateRouteLoader(route: EntryRoute, routeModule: RouteModule, isSpaMode: boolean): boolean;
436
+
437
+ type ParamKeyValuePair = [string, string];
438
+ type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
439
+ /**
440
+ Creates a URLSearchParams object using the given initializer.
441
+
442
+ This is identical to `new URLSearchParams(init)` except it also
443
+ supports arrays as values in the object form of the initializer
444
+ instead of just strings. This is convenient when you need multiple
445
+ values for a given key, but don't want to use an array initializer.
446
+
447
+ For example, instead of:
448
+
449
+ ```tsx
450
+ let searchParams = new URLSearchParams([
451
+ ['sort', 'name'],
452
+ ['sort', 'price']
453
+ ]);
454
+ ```
455
+ you can do:
456
+
457
+ ```
458
+ let searchParams = createSearchParams({
459
+ sort: ['name', 'price']
460
+ });
461
+ ```
462
+
463
+ @category Utils
464
+ */
465
+ declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
466
+ type JsonObject = {
467
+ [Key in string]: JsonValue;
468
+ } & {
469
+ [Key in string]?: JsonValue | undefined;
470
+ };
471
+ type JsonArray = JsonValue[] | readonly JsonValue[];
472
+ type JsonPrimitive = string | number | boolean | null;
473
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
474
+ type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
475
+ /**
476
+ * Submit options shared by both navigations and fetchers
477
+ */
478
+ interface SharedSubmitOptions {
479
+ /**
480
+ * The HTTP method used to submit the form. Overrides `<form method>`.
481
+ * Defaults to "GET".
482
+ */
483
+ method?: HTMLFormMethod;
484
+ /**
485
+ * The action URL path used to submit the form. Overrides `<form action>`.
486
+ * Defaults to the path of the current route.
487
+ */
488
+ action?: string;
489
+ /**
490
+ * The encoding used to submit the form. Overrides `<form encType>`.
491
+ * Defaults to "application/x-www-form-urlencoded".
492
+ */
493
+ encType?: FormEncType;
494
+ /**
495
+ * Determines whether the form action is relative to the route hierarchy or
496
+ * the pathname. Use this if you want to opt out of navigating the route
497
+ * hierarchy and want to instead route based on /-delimited URL segments
498
+ */
499
+ relative?: RelativeRoutingType;
500
+ /**
501
+ * In browser-based environments, prevent resetting scroll after this
502
+ * navigation when using the <ScrollRestoration> component
503
+ */
504
+ preventScrollReset?: boolean;
505
+ /**
506
+ * Enable flushSync for this submission's state updates
507
+ */
508
+ flushSync?: boolean;
509
+ }
510
+ /**
511
+ * Submit options available to fetchers
512
+ */
513
+ interface FetcherSubmitOptions extends SharedSubmitOptions {
514
+ }
515
+ /**
516
+ * Submit options available to navigations
517
+ */
518
+ interface SubmitOptions extends FetcherSubmitOptions {
519
+ /**
520
+ * Set `true` to replace the current entry in the browser's history stack
521
+ * instead of creating a new one (i.e. stay on "the same page"). Defaults
522
+ * to `false`.
523
+ */
524
+ replace?: boolean;
525
+ /**
526
+ * State object to add to the history stack entry for this navigation
527
+ */
528
+ state?: any;
529
+ /**
530
+ * Indicate a specific fetcherKey to use when using navigate=false
531
+ */
532
+ fetcherKey?: string;
533
+ /**
534
+ * navigate=false will use a fetcher instead of a navigation
535
+ */
536
+ navigate?: boolean;
537
+ /**
538
+ * Enable view transitions on this submission navigation
539
+ */
540
+ viewTransition?: boolean;
541
+ }
542
+
543
+ declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
544
+ /**
545
+ * Defines the discovery behavior of the link:
546
+ *
547
+ * - "render" - default, discover the route when the link renders
548
+ * - "none" - don't eagerly discover, only discover if the link is clicked
549
+ */
550
+ type DiscoverBehavior = "render" | "none";
551
+ /**
552
+ * Defines the prefetching behavior of the link:
553
+ *
554
+ * - "none": Never fetched
555
+ * - "intent": Fetched when the user focuses or hovers the link
556
+ * - "render": Fetched when the link is rendered
557
+ * - "viewport": Fetched when the link is in the viewport
558
+ */
559
+ type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
560
+ /**
561
+ Renders all of the `<link>` tags created by route module {@link LinksFunction} export. You should render it inside the `<head>` of your document.
562
+
563
+ ```tsx
564
+ import { Links } from "react-router";
565
+
566
+ export default function Root() {
567
+ return (
568
+ <html>
569
+ <head>
570
+ <Links />
571
+ </head>
572
+ <body></body>
573
+ </html>
574
+ );
575
+ }
576
+ ```
577
+
578
+ @category Components
579
+ */
580
+ declare function Links(): React.JSX.Element;
581
+ /**
582
+ Renders `<link rel=prefetch|modulepreload>` tags for modules and data of another page to enable an instant navigation to that page. {@link LinkProps.prefetch | `<Link prefetch>`} uses this internally, but you can render it to prefetch a page for any other reason.
583
+
584
+ ```tsx
585
+ import { PrefetchPageLinks } from "react-router"
586
+
587
+ <PrefetchPageLinks page="/absolute/path" />
588
+ ```
589
+
590
+ For example, you may render one of this as the user types into a search field to prefetch search results before they click through to their selection.
591
+
592
+ @category Components
593
+ */
594
+ declare function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor): React.JSX.Element | null;
595
+ /**
596
+ Renders all the `<meta>` tags created by route module {@link MetaFunction} exports. You should render it inside the `<head>` of your HTML.
597
+
598
+ ```tsx
599
+ import { Meta } from "react-router";
600
+
601
+ export default function Root() {
602
+ return (
603
+ <html>
604
+ <head>
605
+ <Meta />
606
+ </head>
607
+ </html>
608
+ );
609
+ }
610
+ ```
611
+
612
+ @category Components
613
+ */
614
+ declare function Meta(): React.JSX.Element;
615
+ /**
616
+ A couple common attributes:
617
+
618
+ - `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
619
+ - `<Scripts nonce>` to support a [content security policy for scripts](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) with [nonce-sources](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources#sources) for your `<script>` tags.
620
+
621
+ You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
622
+
623
+ @category Types
624
+ */
625
+ type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
626
+ /**
627
+ Renders the client runtime of your app. It should be rendered inside the `<body>` of the document.
628
+
629
+ ```tsx
630
+ import { Scripts } from "react-router";
631
+
632
+ export default function Root() {
633
+ return (
634
+ <html>
635
+ <head />
636
+ <body>
637
+ <Scripts />
638
+ </body>
639
+ </html>
640
+ );
641
+ }
642
+ ```
643
+
644
+ If server rendering, you can omit `<Scripts/>` and the app will work as a traditional web app without JavaScript, relying solely on HTML and browser behaviors.
645
+
646
+ @category Components
647
+ */
648
+ declare function Scripts(props: ScriptsProps): React.JSX.Element | null;
649
+
650
+ declare global {
651
+ const REACT_ROUTER_VERSION: string;
652
+ }
653
+ interface DOMRouterOpts {
654
+ basename?: string;
655
+ future?: Partial<FutureConfig$1>;
656
+ hydrationData?: HydrationState;
657
+ dataStrategy?: DataStrategyFunction;
658
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
659
+ window?: Window;
660
+ }
661
+ /**
662
+ * @category Routers
663
+ */
664
+ declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
665
+ /**
666
+ * @category Routers
667
+ */
668
+ declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
669
+ /**
670
+ * @category Types
671
+ */
672
+ interface BrowserRouterProps {
673
+ basename?: string;
674
+ children?: React.ReactNode;
675
+ window?: Window;
676
+ }
677
+ /**
678
+ * A `<Router>` for use in web browsers. Provides the cleanest URLs.
679
+ *
680
+ * @category Router Components
681
+ */
682
+ declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
683
+ /**
684
+ * @category Types
685
+ */
686
+ interface HashRouterProps {
687
+ basename?: string;
688
+ children?: React.ReactNode;
689
+ window?: Window;
690
+ }
691
+ /**
692
+ * A `<Router>` for use in web browsers. Stores the location in the hash
693
+ * portion of the URL so it is not sent to the server.
694
+ *
695
+ * @category Router Components
696
+ */
697
+ declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
698
+ /**
699
+ * @category Types
700
+ */
701
+ interface HistoryRouterProps {
702
+ basename?: string;
703
+ children?: React.ReactNode;
704
+ history: History;
705
+ }
706
+ /**
707
+ * A `<Router>` that accepts a pre-instantiated history object. It's important
708
+ * to note that using your own history object is highly discouraged and may add
709
+ * two versions of the history library to your bundles unless you use the same
710
+ * version of the history library that React Router uses internally.
711
+ *
712
+ * @name unstable_HistoryRouter
713
+ * @category Router Components
714
+ */
715
+ declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
716
+ declare namespace HistoryRouter {
717
+ var displayName: string;
718
+ }
719
+ /**
720
+ * @category Types
721
+ */
722
+ interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
723
+ /**
724
+ Defines the link discovery behavior
725
+
726
+ ```tsx
727
+ <Link /> // default ("render")
728
+ <Link discover="render" />
729
+ <Link discover="none" />
730
+ ```
731
+
732
+ - **render** - default, discover the route when the link renders
733
+ - **none** - don't eagerly discover, only discover if the link is clicked
734
+ */
735
+ discover?: DiscoverBehavior;
736
+ /**
737
+ Defines the data and module prefetching behavior for the link.
738
+
739
+ ```tsx
740
+ <Link /> // default
741
+ <Link prefetch="none" />
742
+ <Link prefetch="intent" />
743
+ <Link prefetch="render" />
744
+ <Link prefetch="viewport" />
745
+ ```
746
+
747
+ - **none** - default, no prefetching
748
+ - **intent** - prefetches when the user hovers or focuses the link
749
+ - **render** - prefetches when the link renders
750
+ - **viewport** - prefetches when the link is in the viewport, very useful for mobile
751
+
752
+ Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted after the link.
753
+
754
+ ```tsx
755
+ <a href="..." />
756
+ <a href="..." />
757
+ <link rel="prefetch" /> // might conditionally render
758
+ ```
759
+
760
+ Because of this, if you are using `nav :last-child` you will need to use `nav :last-of-type` so the styles don't conditionally fall off your last link (and any other similar selectors).
761
+ */
762
+ prefetch?: PrefetchBehavior;
763
+ /**
764
+ Will use document navigation instead of client side routing when the link is clicked: the browser will handle the transition normally (as if it were an `<a href>`).
765
+
766
+ ```tsx
767
+ <Link to="/logout" reloadDocument />
768
+ ```
769
+ */
770
+ reloadDocument?: boolean;
771
+ /**
772
+ Replaces the current entry in the history stack instead of pushing a new one onto it.
773
+
774
+ ```tsx
775
+ <Link replace />
776
+ ```
777
+
778
+ ```
779
+ # with a history stack like this
780
+ A -> B
781
+
782
+ # normal link click pushes a new entry
783
+ A -> B -> C
784
+
785
+ # but with `replace`, B is replaced by C
786
+ A -> C
787
+ ```
788
+ */
789
+ replace?: boolean;
790
+ /**
791
+ Adds persistent client side routing state to the next location.
792
+
793
+ ```tsx
794
+ <Link to="/somewhere/else" state={{ some: "value" }} />
795
+ ```
796
+
797
+ The location state is accessed from the `location`.
798
+
799
+ ```tsx
800
+ function SomeComp() {
801
+ const location = useLocation()
802
+ location.state; // { some: "value" }
803
+ }
804
+ ```
805
+
806
+ This state is inaccessible on the server as it is implemented on top of [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
807
+ */
808
+ state?: any;
809
+ /**
810
+ Prevents the scroll position from being reset to the top of the window when the link is clicked and the app is using {@link ScrollRestoration}. This only prevents new locations reseting scroll to the top, scroll position will be restored for back/forward button navigation.
811
+
812
+ ```tsx
813
+ <Link to="?tab=one" preventScrollReset />
814
+ ```
815
+ */
816
+ preventScrollReset?: boolean;
817
+ /**
818
+ Defines the relative path behavior for the link.
819
+
820
+ ```tsx
821
+ <Link to=".." /> // default: "route"
822
+ <Link relative="route" />
823
+ <Link relative="path" />
824
+ ```
825
+
826
+ Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".
827
+
828
+ - **route** - default, resolves the link relative to the route pattern. In the example above a relative link of `".."` will remove both `:slug/edit` segments back to "/blog".
829
+ - **path** - relative to the path so `..` will only remove one URL segment up to "/blog/:slug"
830
+ */
831
+ relative?: RelativeRoutingType;
832
+ /**
833
+ Can be a string or a partial {@link Path}:
834
+
835
+ ```tsx
836
+ <Link to="/some/path" />
837
+
838
+ <Link
839
+ to={{
840
+ pathname: "/some/path",
841
+ search: "?query=string",
842
+ hash: "#hash",
843
+ }}
844
+ />
845
+ ```
846
+ */
847
+ to: To;
848
+ /**
849
+ Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) for this navigation.
850
+
851
+ ```jsx
852
+ <Link to={to} viewTransition>
853
+ Click me
854
+ </Link>
855
+ ```
856
+
857
+ To apply specific styles for the transition, see {@link useViewTransitionState}
858
+ */
859
+ viewTransition?: boolean;
860
+ }
861
+ /**
862
+ A progressively enhanced `<a href>` wrapper to enable navigation with client-side routing.
863
+
864
+ ```tsx
865
+ import { Link } from "react-router";
866
+
867
+ <Link to="/dashboard">Dashboard</Link>;
868
+
869
+ <Link
870
+ to={{
871
+ pathname: "/some/path",
872
+ search: "?query=string",
873
+ hash: "#hash",
874
+ }}
875
+ />
876
+ ```
877
+
878
+ @category Components
879
+ */
880
+ declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
881
+ /**
882
+ The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
883
+
884
+ ```
885
+ // className
886
+ <NavLink
887
+ to="/messages"
888
+ className={({ isActive, isPending }) =>
889
+ isPending ? "pending" : isActive ? "active" : ""
890
+ }
891
+ >
892
+ Messages
893
+ </NavLink>
894
+
895
+ // style
896
+ <NavLink
897
+ to="/messages"
898
+ style={({ isActive, isPending }) => {
899
+ return {
900
+ fontWeight: isActive ? "bold" : "",
901
+ color: isPending ? "red" : "black",
902
+ }
903
+ )}
904
+ />
905
+
906
+ // children
907
+ <NavLink to="/tasks">
908
+ {({ isActive, isPending }) => (
909
+ <span className={isActive ? "active" : ""}>Tasks</span>
910
+ )}
911
+ </NavLink>
912
+ ```
913
+
914
+ */
915
+ type NavLinkRenderProps = {
916
+ /**
917
+ * Indicates if the link's URL matches the current location.
918
+ */
919
+ isActive: boolean;
920
+ /**
921
+ * Indicates if the pending location matches the link's URL.
922
+ */
923
+ isPending: boolean;
924
+ /**
925
+ * Indicates if a view transition to the link's URL is in progress. See {@link useViewTransitionState}
926
+ */
927
+ isTransitioning: boolean;
928
+ };
929
+ /**
930
+ * @category Types
931
+ */
932
+ interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
933
+ /**
934
+ Can be regular React children or a function that receives an object with the active and pending states of the link.
935
+
936
+ ```tsx
937
+ <NavLink to="/tasks">
938
+ {({ isActive }) => (
939
+ <span className={isActive ? "active" : ""}>Tasks</span>
940
+ )}
941
+ </NavLink>
942
+ ```
943
+ */
944
+ children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
945
+ /**
946
+ Changes the matching logic to make it case-sensitive:
947
+
948
+ | Link | URL | isActive |
949
+ | -------------------------------------------- | ------------- | -------- |
950
+ | `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
951
+ | `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
952
+ */
953
+ caseSensitive?: boolean;
954
+ /**
955
+ Classes are automatically applied to NavLink that correspond to {@link NavLinkRenderProps}.
956
+
957
+ ```css
958
+ a.active { color: red; }
959
+ a.pending { color: blue; }
960
+ a.transitioning {
961
+ view-transition-name: my-transition;
962
+ }
963
+ ```
964
+ */
965
+ className?: string | ((props: NavLinkRenderProps) => string | undefined);
966
+ /**
967
+ Changes the matching logic for the `active` and `pending` states to only match to the "end" of the {@link NavLinkProps.to}. If the URL is longer, it will no longer be considered active.
968
+
969
+ | Link | URL | isActive |
970
+ | ----------------------------- | ------------ | -------- |
971
+ | `<NavLink to="/tasks" />` | `/tasks` | true |
972
+ | `<NavLink to="/tasks" />` | `/tasks/123` | true |
973
+ | `<NavLink to="/tasks" end />` | `/tasks` | true |
974
+ | `<NavLink to="/tasks" end />` | `/tasks/123` | false |
975
+
976
+ `<NavLink to="/">` is an exceptional case because _every_ URL matches `/`. To avoid this matching every single route by default, it effectively ignores the `end` prop and only matches when you're at the root route.
977
+ */
978
+ end?: boolean;
979
+ style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
980
+ }
981
+ /**
982
+ Wraps {@link Link | `<Link>`} with additional props for styling active and pending states.
983
+
984
+ - Automatically applies classes to the link based on its active and pending states, see {@link NavLinkProps.className}.
985
+ - Automatically applies `aria-current="page"` to the link when the link is active. See [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current) on MDN.
986
+
987
+ ```tsx
988
+ import { NavLink } from "react-router"
989
+ <NavLink to="/message" />
990
+ ```
991
+
992
+ States are available through the className, style, and children render props. See {@link NavLinkRenderProps}.
993
+
994
+ ```tsx
995
+ <NavLink
996
+ to="/messages"
997
+ className={({ isActive, isPending }) =>
998
+ isPending ? "pending" : isActive ? "active" : ""
999
+ }
1000
+ >
1001
+ Messages
1002
+ </NavLink>
1003
+ ```
1004
+
1005
+ @category Components
1006
+ */
1007
+ declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
1008
+ /**
1009
+ * Form props shared by navigations and fetchers
1010
+ */
1011
+ interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
1012
+ /**
1013
+ * The HTTP verb to use when the form is submitted. Supports "get", "post",
1014
+ * "put", "delete", and "patch".
1015
+ *
1016
+ * Native `<form>` only supports `get` and `post`, avoid the other verbs if
1017
+ * you'd like to support progressive enhancement
1018
+ */
1019
+ method?: HTMLFormMethod;
1020
+ /**
1021
+ * The encoding type to use for the form submission.
1022
+ */
1023
+ encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
1024
+ /**
1025
+ * The URL to submit the form data to. If `undefined`, this defaults to the closest route in context.
1026
+ */
1027
+ action?: string;
1028
+ /**
1029
+ * Determines whether the form action is relative to the route hierarchy or
1030
+ * the pathname. Use this if you want to opt out of navigating the route
1031
+ * hierarchy and want to instead route based on /-delimited URL segments
1032
+ */
1033
+ relative?: RelativeRoutingType;
1034
+ /**
1035
+ * Prevent the scroll position from resetting to the top of the viewport on
1036
+ * completion of the navigation when using the <ScrollRestoration> component
1037
+ */
1038
+ preventScrollReset?: boolean;
1039
+ /**
1040
+ * A function to call when the form is submitted. If you call
1041
+ * `event.preventDefault()` then this form will not do anything.
1042
+ */
1043
+ onSubmit?: React.FormEventHandler<HTMLFormElement>;
1044
+ }
1045
+ /**
1046
+ * Form props available to fetchers
1047
+ * @category Types
1048
+ */
1049
+ interface FetcherFormProps extends SharedFormProps {
1050
+ }
1051
+ /**
1052
+ * Form props available to navigations
1053
+ * @category Types
1054
+ */
1055
+ interface FormProps extends SharedFormProps {
1056
+ discover?: DiscoverBehavior;
1057
+ /**
1058
+ * Indicates a specific fetcherKey to use when using `navigate={false}` so you
1059
+ * can pick up the fetcher's state in a different component in a {@link
1060
+ * useFetcher}.
1061
+ */
1062
+ fetcherKey?: string;
1063
+ /**
1064
+ * Skips the navigation and uses a {@link useFetcher | fetcher} internally
1065
+ * when `false`. This is essentially a shorthand for `useFetcher()` +
1066
+ * `<fetcher.Form>` where you don't care about the resulting data in this
1067
+ * component.
1068
+ */
1069
+ navigate?: boolean;
1070
+ /**
1071
+ * Forces a full document navigation instead of client side routing + data
1072
+ * fetch.
1073
+ */
1074
+ reloadDocument?: boolean;
1075
+ /**
1076
+ * Replaces the current entry in the browser history stack when the form
1077
+ * navigates. Use this if you don't want the user to be able to click "back"
1078
+ * to the page with the form on it.
1079
+ */
1080
+ replace?: boolean;
1081
+ /**
1082
+ * State object to add to the history stack entry for this navigation
1083
+ */
1084
+ state?: any;
1085
+ /**
1086
+ * Enables a [View
1087
+ * Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1088
+ * for this navigation. To apply specific styles during the transition see
1089
+ * {@link useViewTransitionState}.
1090
+ */
1091
+ viewTransition?: boolean;
1092
+ }
1093
+ /**
1094
+
1095
+ A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) that submits data to actions via `fetch`, activating pending states in `useNavigation` which enables advanced user interfaces beyond a basic HTML form. After a form's action completes, all data on the page is automatically revalidated to keep the UI in sync with the data.
1096
+
1097
+ Because it uses the HTML form API, server rendered pages are interactive at a basic level before JavaScript loads. Instead of React Router managing the submission, the browser manages the submission as well as the pending states (like the spinning favicon). After JavaScript loads, React Router takes over enabling web application user experiences.
1098
+
1099
+ Form is most useful for submissions that should also change the URL or otherwise add an entry to the browser history stack. For forms that shouldn't manipulate the browser history stack, use [`<fetcher.Form>`][fetcher_form].
1100
+
1101
+ ```tsx
1102
+ import { Form } from "react-router";
1103
+
1104
+ function NewEvent() {
1105
+ return (
1106
+ <Form action="/events" method="post">
1107
+ <input name="title" type="text" />
1108
+ <input name="description" type="text" />
1109
+ </Form>
1110
+ )
1111
+ }
1112
+ ```
1113
+
1114
+ @category Components
1115
+ */
1116
+ declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
1117
+ type ScrollRestorationProps = ScriptsProps & {
1118
+ /**
1119
+ Defines the key used to restore scroll positions.
1120
+
1121
+ ```tsx
1122
+ <ScrollRestoration
1123
+ getKey={(location, matches) => {
1124
+ // default behavior
1125
+ return location.key
1126
+ }}
1127
+ />
1128
+ ```
1129
+ */
1130
+ getKey?: GetScrollRestorationKeyFunction;
1131
+ storageKey?: string;
1132
+ };
1133
+ /**
1134
+ Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
1135
+
1136
+ ```tsx
1137
+ import { ScrollRestoration } from "react-router";
1138
+
1139
+ export default function Root() {
1140
+ return (
1141
+ <html>
1142
+ <body>
1143
+ <ScrollRestoration />
1144
+ <Scripts />
1145
+ </body>
1146
+ </html>
1147
+ );
1148
+ }
1149
+ ```
1150
+
1151
+ 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.
1152
+
1153
+ ```tsx
1154
+ <ScrollRestoration nonce={cspNonce} />
1155
+ ```
1156
+
1157
+ @category Components
1158
+ */
1159
+ declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
1160
+ declare namespace ScrollRestoration {
1161
+ var displayName: string;
1162
+ }
1163
+ /**
1164
+ * Handles the click behavior for router `<Link>` components. This is useful if
1165
+ * you need to create custom `<Link>` components with the same click behavior we
1166
+ * use in our exported `<Link>`.
1167
+ *
1168
+ * @category Hooks
1169
+ */
1170
+ declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
1171
+ target?: React.HTMLAttributeAnchorTarget;
1172
+ replace?: boolean;
1173
+ state?: any;
1174
+ preventScrollReset?: boolean;
1175
+ relative?: RelativeRoutingType;
1176
+ viewTransition?: boolean;
1177
+ }): (event: React.MouseEvent<E, MouseEvent>) => void;
1178
+ /**
1179
+ Returns a tuple of the current URL's {@link URLSearchParams} and a function to update them. Setting the search params causes a navigation.
1180
+
1181
+ ```tsx
1182
+ import { useSearchParams } from "react-router";
1183
+
1184
+ export function SomeComponent() {
1185
+ const [searchParams, setSearchParams] = useSearchParams();
1186
+ // ...
1187
+ }
1188
+ ```
1189
+
1190
+ @category Hooks
1191
+ */
1192
+ declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
1193
+ /**
1194
+ Sets new search params and causes a navigation when called.
1195
+
1196
+ ```tsx
1197
+ <button
1198
+ onClick={() => {
1199
+ const params = new URLSearchParams();
1200
+ params.set("someKey", "someValue");
1201
+ setSearchParams(params, {
1202
+ preventScrollReset: true,
1203
+ });
1204
+ }}
1205
+ />
1206
+ ```
1207
+
1208
+ It also supports a function for setting new search params.
1209
+
1210
+ ```tsx
1211
+ <button
1212
+ onClick={() => {
1213
+ setSearchParams((prev) => {
1214
+ prev.set("someKey", "someValue");
1215
+ return prev;
1216
+ });
1217
+ }}
1218
+ />
1219
+ ```
1220
+ */
1221
+ type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
1222
+ /**
1223
+ * Submits a HTML `<form>` to the server without reloading the page.
1224
+ */
1225
+ interface SubmitFunction {
1226
+ (
1227
+ /**
1228
+ Can be multiple types of elements and objects
1229
+
1230
+ **`HTMLFormElement`**
1231
+
1232
+ ```tsx
1233
+ <Form
1234
+ onSubmit={(event) => {
1235
+ submit(event.currentTarget);
1236
+ }}
1237
+ />
1238
+ ```
1239
+
1240
+ **`FormData`**
1241
+
1242
+ ```tsx
1243
+ const formData = new FormData();
1244
+ formData.append("myKey", "myValue");
1245
+ submit(formData, { method: "post" });
1246
+ ```
1247
+
1248
+ **Plain object that will be serialized as `FormData`**
1249
+
1250
+ ```tsx
1251
+ submit({ myKey: "myValue" }, { method: "post" });
1252
+ ```
1253
+
1254
+ **Plain object that will be serialized as JSON**
1255
+
1256
+ ```tsx
1257
+ submit(
1258
+ { myKey: "myValue" },
1259
+ { method: "post", encType: "application/json" }
1260
+ );
1261
+ ```
1262
+ */
1263
+ target: SubmitTarget,
1264
+ /**
1265
+ * Options that override the `<form>`'s own attributes. Required when
1266
+ * submitting arbitrary data without a backing `<form>`.
1267
+ */
1268
+ options?: SubmitOptions): Promise<void>;
1269
+ }
1270
+ /**
1271
+ * Submits a fetcher `<form>` to the server without reloading the page.
1272
+ */
1273
+ interface FetcherSubmitFunction {
1274
+ (
1275
+ /**
1276
+ Can be multiple types of elements and objects
1277
+
1278
+ **`HTMLFormElement`**
1279
+
1280
+ ```tsx
1281
+ <fetcher.Form
1282
+ onSubmit={(event) => {
1283
+ fetcher.submit(event.currentTarget);
1284
+ }}
1285
+ />
1286
+ ```
1287
+
1288
+ **`FormData`**
1289
+
1290
+ ```tsx
1291
+ const formData = new FormData();
1292
+ formData.append("myKey", "myValue");
1293
+ fetcher.submit(formData, { method: "post" });
1294
+ ```
1295
+
1296
+ **Plain object that will be serialized as `FormData`**
1297
+
1298
+ ```tsx
1299
+ fetcher.submit({ myKey: "myValue" }, { method: "post" });
1300
+ ```
1301
+
1302
+ **Plain object that will be serialized as JSON**
1303
+
1304
+ ```tsx
1305
+ fetcher.submit(
1306
+ { myKey: "myValue" },
1307
+ { method: "post", encType: "application/json" }
1308
+ );
1309
+ ```
1310
+
1311
+ */
1312
+ target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
1313
+ }
1314
+ /**
1315
+ The imperative version of {@link Form | `<Form>`} that lets you submit a form from code instead of a user interaction.
1316
+
1317
+ ```tsx
1318
+ import { useSubmit } from "react-router";
1319
+
1320
+ function SomeComponent() {
1321
+ const submit = useSubmit();
1322
+ return (
1323
+ <Form
1324
+ onChange={(event) => {
1325
+ submit(event.currentTarget);
1326
+ }}
1327
+ />
1328
+ );
1329
+ }
1330
+ ```
1331
+
1332
+ @category Hooks
1333
+ */
1334
+ declare function useSubmit(): SubmitFunction;
1335
+ /**
1336
+ Resolves the URL to the closest route in the component hierarchy instead of the current URL of the app.
1337
+
1338
+ This is used internally by {@link Form} resolve the action to the closest route, but can be used generically as well.
1339
+
1340
+ ```tsx
1341
+ import { useFormAction } from "react-router";
1342
+
1343
+ function SomeComponent() {
1344
+ // closest route URL
1345
+ let action = useFormAction();
1346
+
1347
+ // closest route URL + "destroy"
1348
+ let destroyAction = useFormAction("destroy");
1349
+ }
1350
+ ```
1351
+
1352
+ @category Hooks
1353
+ */
1354
+ declare function useFormAction(
1355
+ /**
1356
+ * The action to append to the closest route URL.
1357
+ */
1358
+ action?: string, { relative }?: {
1359
+ relative?: RelativeRoutingType;
1360
+ }): string;
1361
+ /**
1362
+ The return value of `useFetcher` that keeps track of the state of a fetcher.
1363
+
1364
+ ```tsx
1365
+ let fetcher = useFetcher();
1366
+ ```
1367
+ */
1368
+ type FetcherWithComponents<TData> = Fetcher<TData> & {
1369
+ /**
1370
+ Just like {@link Form} except it doesn't cause a navigation.
1371
+
1372
+ ```tsx
1373
+ function SomeComponent() {
1374
+ const fetcher = useFetcher()
1375
+ return (
1376
+ <fetcher.Form method="post" action="/some/route">
1377
+ <input type="text" />
1378
+ </fetcher.Form>
1379
+ )
1380
+ }
1381
+ ```
1382
+ */
1383
+ Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
1384
+ /**
1385
+ Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
1386
+
1387
+ The `formData` can be multiple types:
1388
+
1389
+ - [`FormData`][form_data] - A `FormData` instance.
1390
+ - [`HTMLFormElement`][html_form_element] - A [`<form>`][form_element] DOM element.
1391
+ - `Object` - An object of key/value pairs that will be converted to a `FormData` instance by default. You can pass a more complex object and serialize it as JSON by specifying `encType: "application/json"`. See [`useSubmit`][use-submit] for more details.
1392
+
1393
+ If the method is `GET`, then the route [`loader`][loader] is being called and with the `formData` serialized to the url as [`URLSearchParams`][url_search_params]. If `DELETE`, `PATCH`, `POST`, or `PUT`, then the route [`action`][action] is being called with `formData` as the body.
1394
+
1395
+ ```tsx
1396
+ // Submit a FormData instance (GET request)
1397
+ const formData = new FormData();
1398
+ fetcher.submit(formData);
1399
+
1400
+ // Submit the HTML form element
1401
+ fetcher.submit(event.currentTarget.form, {
1402
+ method: "POST",
1403
+ });
1404
+
1405
+ // Submit key/value JSON as a FormData instance
1406
+ fetcher.submit(
1407
+ { serialized: "values" },
1408
+ { method: "POST" }
1409
+ );
1410
+
1411
+ // Submit raw JSON
1412
+ fetcher.submit(
1413
+ {
1414
+ deeply: {
1415
+ nested: {
1416
+ json: "values",
1417
+ },
1418
+ },
1419
+ },
1420
+ {
1421
+ method: "POST",
1422
+ encType: "application/json",
1423
+ }
1424
+ );
1425
+ ```
1426
+ */
1427
+ submit: FetcherSubmitFunction;
1428
+ /**
1429
+ Loads data from a route. Useful for loading data imperatively inside of user events outside of a normal button or form, like a combobox or search input.
1430
+
1431
+ ```tsx
1432
+ let fetcher = useFetcher()
1433
+
1434
+ <input onChange={e => {
1435
+ fetcher.load(`/search?q=${e.target.value}`)
1436
+ }} />
1437
+ ```
1438
+ */
1439
+ load: (href: string, opts?: {
1440
+ /**
1441
+ * Wraps the initial state update for this `fetcher.load` in a
1442
+ * `ReactDOM.flushSync` call instead of the default `React.startTransition`.
1443
+ * This allows you to perform synchronous DOM actions immediately after the
1444
+ * update is flushed to the DOM.
1445
+ */
1446
+ flushSync?: boolean;
1447
+ }) => Promise<void>;
1448
+ };
1449
+ /**
1450
+ Useful for creating complex, dynamic user interfaces that require multiple, concurrent data interactions without causing a navigation.
1451
+
1452
+ Fetchers track their own, independent state and can be used to load data, submit forms, and generally interact with loaders and actions.
1453
+
1454
+ ```tsx
1455
+ import { useFetcher } from "react-router"
1456
+
1457
+ function SomeComponent() {
1458
+ let fetcher = useFetcher()
1459
+
1460
+ // states are available on the fetcher
1461
+ fetcher.state // "idle" | "loading" | "submitting"
1462
+ fetcher.data // the data returned from the action or loader
1463
+
1464
+ // render a form
1465
+ <fetcher.Form method="post" />
1466
+
1467
+ // load data
1468
+ fetcher.load("/some/route")
1469
+
1470
+ // submit data
1471
+ fetcher.submit(someFormRef, { method: "post" })
1472
+ fetcher.submit(someData, {
1473
+ method: "post",
1474
+ encType: "application/json"
1475
+ })
1476
+ }
1477
+ ```
1478
+
1479
+ @category Hooks
1480
+ */
1481
+ declare function useFetcher<T = any>({ key, }?: {
1482
+ /**
1483
+ By default, `useFetcher` generate a unique fetcher scoped to that component. If you want to identify a fetcher with your own key such that you can access it from elsewhere in your app, you can do that with the `key` option:
1484
+
1485
+ ```tsx
1486
+ function SomeComp() {
1487
+ let fetcher = useFetcher({ key: "my-key" })
1488
+ // ...
1489
+ }
1490
+
1491
+ // Somewhere else
1492
+ function AnotherComp() {
1493
+ // this will be the same fetcher, sharing the state across the app
1494
+ let fetcher = useFetcher({ key: "my-key" });
1495
+ // ...
1496
+ }
1497
+ ```
1498
+ */
1499
+ key?: string;
1500
+ }): FetcherWithComponents<SerializeFrom<T>>;
1501
+ /**
1502
+ Returns an array of all in-flight fetchers. This is useful for components throughout the app that didn't create the fetchers but want to use their submissions to participate in optimistic UI.
1503
+
1504
+ ```tsx
1505
+ import { useFetchers } from "react-router";
1506
+
1507
+ function SomeComponent() {
1508
+ const fetchers = useFetchers();
1509
+ fetchers[0].formData; // FormData
1510
+ fetchers[0].state; // etc.
1511
+ // ...
1512
+ }
1513
+ ```
1514
+
1515
+ @category Hooks
1516
+ */
1517
+ declare function useFetchers(): (Fetcher & {
1518
+ key: string;
1519
+ })[];
1520
+ /**
1521
+ * When rendered inside a RouterProvider, will restore scroll positions on navigations
1522
+ */
1523
+ declare function useScrollRestoration({ getKey, storageKey, }?: {
1524
+ getKey?: GetScrollRestorationKeyFunction;
1525
+ storageKey?: string;
1526
+ }): void;
1527
+ /**
1528
+ * Setup a callback to be fired on the window's `beforeunload` event.
1529
+ *
1530
+ * @category Hooks
1531
+ */
1532
+ declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
1533
+ capture?: boolean;
1534
+ }): void;
1535
+ /**
1536
+ Wrapper around useBlocker to show a window.confirm prompt to users instead of building a custom UI with {@link useBlocker}.
1537
+
1538
+ The `unstable_` flag will not be removed because this technique has a lot of rough edges and behaves very differently (and incorrectly sometimes) across browsers if users click addition back/forward navigations while the confirmation is open. Use at your own risk.
1539
+
1540
+ ```tsx
1541
+ function ImportantForm() {
1542
+ let [value, setValue] = React.useState("");
1543
+
1544
+ // Block navigating elsewhere when data has been entered into the input
1545
+ unstable_usePrompt({
1546
+ message: "Are you sure?",
1547
+ when: ({ currentLocation, nextLocation }) =>
1548
+ value !== "" &&
1549
+ currentLocation.pathname !== nextLocation.pathname,
1550
+ });
1551
+
1552
+ return (
1553
+ <Form method="post">
1554
+ <label>
1555
+ Enter some important data:
1556
+ <input
1557
+ name="data"
1558
+ value={value}
1559
+ onChange={(e) => setValue(e.target.value)}
1560
+ />
1561
+ </label>
1562
+ <button type="submit">Save</button>
1563
+ </Form>
1564
+ );
1565
+ }
1566
+ ```
1567
+
1568
+ @category Hooks
1569
+ @name unstable_usePrompt
1570
+ */
1571
+ declare function usePrompt({ when, message, }: {
1572
+ when: boolean | BlockerFunction;
1573
+ message: string;
1574
+ }): void;
1575
+ /**
1576
+ This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) to the specified location. This can be used to apply finer-grained styles to elements to further customize the view transition. This requires that view transitions have been enabled for the given navigation via {@link LinkProps.viewTransition} (or the `Form`, `submit`, or `navigate` call)
1577
+
1578
+ @category Hooks
1579
+ @name useViewTransitionState
1580
+ */
1581
+ declare function useViewTransitionState(to: To, opts?: {
1582
+ relative?: RelativeRoutingType;
1583
+ }): boolean;
1584
+
1585
+ declare global {
1586
+ interface Navigator {
1587
+ connection?: {
1588
+ saveData: boolean;
1589
+ };
1590
+ }
1591
+ }
1592
+ declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
1593
+ declare function useFogOFWarDiscovery(router: Router$1, manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean): void;
1594
+
1595
+ export { useFetchers as $, type AssetsManifest as A, type BrowserRouterProps as B, createBrowserRouter as C, createHashRouter as D, type EntryContext as E, type FutureConfig as F, BrowserRouter as G, type HashRouterProps as H, type IndexRouteProps as I, HashRouter as J, Link as K, type LayoutRouteProps as L, type MemoryRouterProps as M, type NavigateProps as N, type OutletProps as O, type PathRouteProps as P, HistoryRouter as Q, type RouterProviderProps as R, type ScrollRestorationProps as S, NavLink as T, Form as U, ScrollRestoration as V, useLinkClickHandler as W, useSearchParams as X, useSubmit as Y, useFormAction as Z, useFetcher as _, type Route as a, useBeforeUnload as a0, usePrompt as a1, useViewTransitionState as a2, type FetcherSubmitOptions as a3, type ParamKeyValuePair as a4, type SubmitOptions as a5, type URLSearchParamsInit as a6, type SubmitTarget as a7, createSearchParams as a8, Meta as a9, Links as aa, Scripts as ab, PrefetchPageLinks as ac, type ScriptsProps as ad, mapRouteProperties as ae, FrameworkContext as af, getPatchRoutesOnNavigationFunction as ag, useFogOFWarDiscovery as ah, createClientRoutes as ai, createClientRoutesWithHMRRevalidationOptOut as aj, shouldHydrateRouteLoader as ak, useScrollRestoration as al, type AwaitProps as b, type RouteProps as c, type RouterProps as d, type RoutesProps as e, Await as f, MemoryRouter as g, Navigate as h, Outlet as i, Route$1 as j, Router as k, RouterProvider as l, Routes as m, createMemoryRouter as n, createRoutesFromChildren as o, type HistoryRouterProps as p, type LinkProps as q, renderMatches as r, type NavLinkProps as s, type NavLinkRenderProps as t, type FetcherFormProps as u, type FormProps as v, type SetURLSearchParams as w, type SubmitFunction as x, type FetcherSubmitFunction as y, type FetcherWithComponents as z };