react-router 7.7.0 → 7.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +11 -23
  2. package/dist/development/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  3. package/dist/development/{chunk-EF7DTUVF.mjs → chunk-C37GKA54.mjs} +83 -80
  4. package/dist/development/{chunk-V6PEDDZI.js → chunk-K7YFBME3.js} +79 -76
  5. package/dist/{production/chunk-GNZILI6H.mjs → development/chunk-KIUJAIYX.mjs} +3 -5
  6. package/dist/{production/chunk-2TYFPE3B.js → development/chunk-R73PQUJU.js} +132 -132
  7. package/dist/development/components-CjQijYga.d.mts +802 -0
  8. package/dist/development/dom-export.d.mts +13 -6
  9. package/dist/development/dom-export.d.ts +10 -3
  10. package/dist/development/dom-export.js +3 -3
  11. package/dist/development/dom-export.mjs +3 -3
  12. package/dist/development/index-react-server-client-Bi_fx8qz.d.ts +3163 -0
  13. package/dist/development/index-react-server-client-KLg-U4nr.d.mts +2366 -0
  14. package/dist/development/index-react-server-client.d.mts +3 -3
  15. package/dist/development/index-react-server-client.d.ts +2 -2
  16. package/dist/development/index-react-server-client.js +4 -4
  17. package/dist/development/index-react-server-client.mjs +2 -2
  18. package/dist/development/index-react-server.d.mts +109 -2
  19. package/dist/development/index-react-server.d.ts +109 -2
  20. package/dist/development/index-react-server.js +28 -20
  21. package/dist/development/index-react-server.mjs +29 -21
  22. package/dist/development/index.d.mts +918 -287
  23. package/dist/development/index.d.ts +1010 -283
  24. package/dist/development/index.js +98 -100
  25. package/dist/development/index.mjs +3 -3
  26. package/dist/development/lib/types/internal.d.mts +1 -1
  27. package/dist/development/lib/types/internal.d.ts +1 -1
  28. package/dist/development/lib/types/internal.js +1 -1
  29. package/dist/development/lib/types/internal.mjs +1 -1
  30. package/dist/{production/route-data-DjzmHYNR.d.mts → development/route-data-CqEmXQub.d.mts} +48 -2
  31. package/dist/{production/routeModules-g5PTiDfO.d.ts → development/routeModules-BR2FO0ix.d.ts} +48 -2
  32. package/dist/production/{browser-CcxeZJcQ.d.mts → browser-7LYX59NK.d.mts} +97 -1
  33. package/dist/{development/chunk-4ADB4KIO.js → production/chunk-4DGLNKXF.js} +132 -132
  34. package/dist/production/{chunk-5KHO4FML.js → chunk-7OQROU2D.js} +79 -76
  35. package/dist/production/{chunk-WPPIQDYG.mjs → chunk-IZ57JD2V.mjs} +83 -80
  36. package/dist/{development/chunk-T3VM44WY.mjs → production/chunk-K3SBCRK4.mjs} +3 -5
  37. package/dist/production/components-CjQijYga.d.mts +802 -0
  38. package/dist/production/dom-export.d.mts +13 -6
  39. package/dist/production/dom-export.d.ts +10 -3
  40. package/dist/production/dom-export.js +3 -3
  41. package/dist/production/dom-export.mjs +3 -3
  42. package/dist/production/index-react-server-client-Bi_fx8qz.d.ts +3163 -0
  43. package/dist/production/index-react-server-client-KLg-U4nr.d.mts +2366 -0
  44. package/dist/production/index-react-server-client.d.mts +3 -3
  45. package/dist/production/index-react-server-client.d.ts +2 -2
  46. package/dist/production/index-react-server-client.js +4 -4
  47. package/dist/production/index-react-server-client.mjs +2 -2
  48. package/dist/production/index-react-server.d.mts +109 -2
  49. package/dist/production/index-react-server.d.ts +109 -2
  50. package/dist/production/index-react-server.js +28 -20
  51. package/dist/production/index-react-server.mjs +29 -21
  52. package/dist/production/index.d.mts +918 -287
  53. package/dist/production/index.d.ts +1010 -283
  54. package/dist/production/index.js +98 -100
  55. package/dist/production/index.mjs +3 -3
  56. package/dist/production/lib/types/internal.d.mts +1 -1
  57. package/dist/production/lib/types/internal.d.ts +1 -1
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/{development/route-data-DjzmHYNR.d.mts → production/route-data-CqEmXQub.d.mts} +48 -2
  61. package/dist/{development/routeModules-g5PTiDfO.d.ts → production/routeModules-BR2FO0ix.d.ts} +48 -2
  62. package/package.json +1 -1
  63. package/dist/development/components-DzqPLVI1.d.mts +0 -464
  64. package/dist/development/index-react-server-client-CUidsuu_.d.mts +0 -1360
  65. package/dist/development/index-react-server-client-kY8DvDF3.d.ts +0 -1819
  66. package/dist/production/components-DzqPLVI1.d.mts +0 -464
  67. package/dist/production/index-react-server-client-CUidsuu_.d.mts +0 -1360
  68. package/dist/production/index-react-server-client-kY8DvDF3.d.ts +0 -1819
@@ -1,1360 +0,0 @@
1
- import './components-DzqPLVI1.mjs';
2
- import * as React from 'react';
3
- import { a_ as RouteManifest, a$ as ServerRouteModule, Y as MiddlewareEnabled, u as unstable_RouterContextProvider, X as AppLoadContext, ak as LoaderFunctionArgs, ab as ActionFunctionArgs, y as RouteModules, a4 as StaticHandlerContext, H as HydrationState, a0 as DataRouteObject, j as ClientLoaderFunction, aj as HTMLFormMethod, ah as FormEncType, a as RelativeRoutingType, aL as PageLinkDescriptor, T as To, b0 as History, a3 as GetScrollRestorationKeyFunction, e as RouterInit, F as FutureConfig$1, D as DataStrategyFunction, P as PatchRoutesOnNavigationFunction, z as NavigateOptions, a5 as Fetcher, f as RouteObject, R as Router, J as SerializeFrom, B as BlockerFunction, c as Location, b1 as CreateStaticHandlerOptions$1, a1 as StaticHandler } from './route-data-DjzmHYNR.mjs';
4
-
5
- type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
6
- interface ServerRoute extends Route {
7
- children: ServerRoute[];
8
- module: ServerRouteModule;
9
- }
10
-
11
- type OptionalCriticalCss = CriticalCss | undefined;
12
- /**
13
- * The output of the compiler for the server build.
14
- */
15
- interface ServerBuild {
16
- entry: {
17
- module: ServerEntryModule;
18
- };
19
- routes: ServerRouteManifest;
20
- assets: AssetsManifest;
21
- basename?: string;
22
- publicPath: string;
23
- assetsBuildDirectory: string;
24
- future: FutureConfig;
25
- ssr: boolean;
26
- unstable_getCriticalCss?: (args: {
27
- pathname: string;
28
- }) => OptionalCriticalCss | Promise<OptionalCriticalCss>;
29
- /**
30
- * @deprecated This is now done via a custom header during prerendering
31
- */
32
- isSpaMode: boolean;
33
- prerender: string[];
34
- routeDiscovery: {
35
- mode: "lazy" | "initial";
36
- manifestPath: string;
37
- };
38
- }
39
- interface HandleDocumentRequestFunction {
40
- (request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext): Promise<Response> | Response;
41
- }
42
- interface HandleDataRequestFunction {
43
- (response: Response, args: LoaderFunctionArgs | ActionFunctionArgs): Promise<Response> | Response;
44
- }
45
- interface HandleErrorFunction {
46
- (error: unknown, args: LoaderFunctionArgs | ActionFunctionArgs): void;
47
- }
48
- /**
49
- * A module that serves as the entry point for a Remix app during server
50
- * rendering.
51
- */
52
- interface ServerEntryModule {
53
- default: HandleDocumentRequestFunction;
54
- handleDataRequest?: HandleDataRequestFunction;
55
- handleError?: HandleErrorFunction;
56
- streamTimeout?: number;
57
- }
58
-
59
- type SerializedError = {
60
- message: string;
61
- stack?: string;
62
- };
63
- interface FrameworkContextObject {
64
- manifest: AssetsManifest;
65
- routeModules: RouteModules;
66
- criticalCss?: CriticalCss;
67
- serverHandoffString?: string;
68
- future: FutureConfig;
69
- ssr: boolean;
70
- isSpaMode: boolean;
71
- routeDiscovery: ServerBuild["routeDiscovery"];
72
- serializeError?(error: Error): SerializedError;
73
- renderMeta?: {
74
- didRenderScripts?: boolean;
75
- streamCache?: Record<number, Promise<void> & {
76
- result?: {
77
- done: boolean;
78
- value: string;
79
- };
80
- error?: unknown;
81
- }>;
82
- };
83
- }
84
- interface EntryContext extends FrameworkContextObject {
85
- staticHandlerContext: StaticHandlerContext;
86
- serverHandoffStream?: ReadableStream<Uint8Array>;
87
- }
88
- interface FutureConfig {
89
- unstable_subResourceIntegrity: boolean;
90
- unstable_middleware: boolean;
91
- }
92
- type CriticalCss = string | {
93
- rel: "stylesheet";
94
- href: string;
95
- };
96
- interface AssetsManifest {
97
- entry: {
98
- imports: string[];
99
- module: string;
100
- };
101
- routes: RouteManifest<EntryRoute>;
102
- url: string;
103
- version: string;
104
- hmr?: {
105
- timestamp?: number;
106
- runtime: string;
107
- };
108
- sri?: Record<string, string> | true;
109
- }
110
-
111
- interface Route {
112
- index?: boolean;
113
- caseSensitive?: boolean;
114
- id: string;
115
- parentId?: string;
116
- path?: string;
117
- }
118
- interface EntryRoute extends Route {
119
- hasAction: boolean;
120
- hasLoader: boolean;
121
- hasClientAction: boolean;
122
- hasClientLoader: boolean;
123
- hasClientMiddleware: boolean;
124
- hasErrorBoundary: boolean;
125
- imports?: string[];
126
- css?: string[];
127
- module: string;
128
- clientActionModule: string | undefined;
129
- clientLoaderModule: string | undefined;
130
- clientMiddlewareModule: string | undefined;
131
- hydrateFallbackModule: string | undefined;
132
- parentId?: string;
133
- }
134
- declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, ssr: boolean, isSpaMode: boolean): DataRouteObject[];
135
- declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, ssr: boolean, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
136
- declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
137
-
138
- type ParamKeyValuePair = [string, string];
139
- type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
140
- /**
141
- Creates a URLSearchParams object using the given initializer.
142
-
143
- This is identical to `new URLSearchParams(init)` except it also
144
- supports arrays as values in the object form of the initializer
145
- instead of just strings. This is convenient when you need multiple
146
- values for a given key, but don't want to use an array initializer.
147
-
148
- For example, instead of:
149
-
150
- ```tsx
151
- let searchParams = new URLSearchParams([
152
- ['sort', 'name'],
153
- ['sort', 'price']
154
- ]);
155
- ```
156
- you can do:
157
-
158
- ```
159
- let searchParams = createSearchParams({
160
- sort: ['name', 'price']
161
- });
162
- ```
163
-
164
- @category Utils
165
- */
166
- declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
167
- type JsonObject = {
168
- [Key in string]: JsonValue;
169
- } & {
170
- [Key in string]?: JsonValue | undefined;
171
- };
172
- type JsonArray = JsonValue[] | readonly JsonValue[];
173
- type JsonPrimitive = string | number | boolean | null;
174
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
175
- type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
176
- /**
177
- * Submit options shared by both navigations and fetchers
178
- */
179
- interface SharedSubmitOptions {
180
- /**
181
- * The HTTP method used to submit the form. Overrides `<form method>`.
182
- * Defaults to "GET".
183
- */
184
- method?: HTMLFormMethod;
185
- /**
186
- * The action URL path used to submit the form. Overrides `<form action>`.
187
- * Defaults to the path of the current route.
188
- */
189
- action?: string;
190
- /**
191
- * The encoding used to submit the form. Overrides `<form encType>`.
192
- * Defaults to "application/x-www-form-urlencoded".
193
- */
194
- encType?: FormEncType;
195
- /**
196
- * Determines whether the form action is relative to the route hierarchy or
197
- * the pathname. Use this if you want to opt out of navigating the route
198
- * hierarchy and want to instead route based on /-delimited URL segments
199
- */
200
- relative?: RelativeRoutingType;
201
- /**
202
- * In browser-based environments, prevent resetting scroll after this
203
- * navigation when using the <ScrollRestoration> component
204
- */
205
- preventScrollReset?: boolean;
206
- /**
207
- * Enable flushSync for this submission's state updates
208
- */
209
- flushSync?: boolean;
210
- }
211
- /**
212
- * Submit options available to fetchers
213
- */
214
- interface FetcherSubmitOptions extends SharedSubmitOptions {
215
- }
216
- /**
217
- * Submit options available to navigations
218
- */
219
- interface SubmitOptions extends FetcherSubmitOptions {
220
- /**
221
- * Set `true` to replace the current entry in the browser's history stack
222
- * instead of creating a new one (i.e. stay on "the same page"). Defaults
223
- * to `false`.
224
- */
225
- replace?: boolean;
226
- /**
227
- * State object to add to the history stack entry for this navigation
228
- */
229
- state?: any;
230
- /**
231
- * Indicate a specific fetcherKey to use when using navigate=false
232
- */
233
- fetcherKey?: string;
234
- /**
235
- * navigate=false will use a fetcher instead of a navigation
236
- */
237
- navigate?: boolean;
238
- /**
239
- * Enable view transitions on this submission navigation
240
- */
241
- viewTransition?: boolean;
242
- }
243
-
244
- declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
245
- /**
246
- * Defines the discovery behavior of the link:
247
- *
248
- * - "render" - default, discover the route when the link renders
249
- * - "none" - don't eagerly discover, only discover if the link is clicked
250
- */
251
- type DiscoverBehavior = "render" | "none";
252
- /**
253
- * Defines the prefetching behavior of the link:
254
- *
255
- * - "none": Never fetched
256
- * - "intent": Fetched when the user focuses or hovers the link
257
- * - "render": Fetched when the link is rendered
258
- * - "viewport": Fetched when the link is in the viewport
259
- */
260
- type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
261
- /**
262
- Renders all of the `<link>` tags created by route module {@link LinksFunction} export. You should render it inside the `<head>` of your document.
263
-
264
- ```tsx
265
- import { Links } from "react-router";
266
-
267
- export default function Root() {
268
- return (
269
- <html>
270
- <head>
271
- <Links />
272
- </head>
273
- <body></body>
274
- </html>
275
- );
276
- }
277
- ```
278
-
279
- @category Components
280
- */
281
- declare function Links(): React.JSX.Element;
282
- /**
283
- 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.
284
-
285
- ```tsx
286
- import { PrefetchPageLinks } from "react-router"
287
-
288
- <PrefetchPageLinks page="/absolute/path" />
289
- ```
290
-
291
- 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.
292
-
293
- @category Components
294
- */
295
- declare function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor): React.JSX.Element | null;
296
- /**
297
- Renders all the `<meta>` tags created by route module {@link MetaFunction} exports. You should render it inside the `<head>` of your HTML.
298
-
299
- ```tsx
300
- import { Meta } from "react-router";
301
-
302
- export default function Root() {
303
- return (
304
- <html>
305
- <head>
306
- <Meta />
307
- </head>
308
- </html>
309
- );
310
- }
311
- ```
312
-
313
- @category Components
314
- */
315
- declare function Meta(): React.JSX.Element;
316
- /**
317
- A couple common attributes:
318
-
319
- - `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
320
- - `<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.
321
-
322
- You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
323
-
324
- @category Types
325
- */
326
- type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
327
- /**
328
- Renders the client runtime of your app. It should be rendered inside the `<body>` of the document.
329
-
330
- ```tsx
331
- import { Scripts } from "react-router";
332
-
333
- export default function Root() {
334
- return (
335
- <html>
336
- <head />
337
- <body>
338
- <Scripts />
339
- </body>
340
- </html>
341
- );
342
- }
343
- ```
344
-
345
- 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.
346
-
347
- @category Components
348
- */
349
- declare function Scripts(props: ScriptsProps): React.JSX.Element | null;
350
-
351
- /**
352
- * @category Routers
353
- */
354
- interface DOMRouterOpts {
355
- /**
356
- * Basename path for the application.
357
- */
358
- basename?: string;
359
- /**
360
- * Function to provide the initial context values for all client side navigations/fetches
361
- */
362
- unstable_getContext?: RouterInit["unstable_getContext"];
363
- /**
364
- * Future flags to enable for the router.
365
- */
366
- future?: Partial<FutureConfig$1>;
367
- /**
368
- * Hydration data to initialize the router with if you have already performed
369
- * data loading on the server.
370
- */
371
- hydrationData?: HydrationState;
372
- /**
373
- * Override the default data strategy of loading in parallel.
374
- * Only intended for advanced usage.
375
- */
376
- dataStrategy?: DataStrategyFunction;
377
- /**
378
- * Lazily define portions of the route tree on navigations.
379
- */
380
- patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
381
- /**
382
- * Window object override - defaults to the global `window` instance.
383
- */
384
- window?: Window;
385
- }
386
- /**
387
- * Create a new data router that manages the application path via `history.pushState`
388
- * and `history.replaceState`.
389
- *
390
- * @category Data Routers
391
- */
392
- declare function createBrowserRouter(
393
- /**
394
- * Application routes
395
- */
396
- routes: RouteObject[],
397
- /**
398
- * Router options
399
- */
400
- opts?: DOMRouterOpts): Router;
401
- /**
402
- * Create a new data router that manages the application path via the URL hash
403
- *
404
- * @category Data Routers
405
- */
406
- declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
407
- /**
408
- * @category Types
409
- */
410
- interface BrowserRouterProps {
411
- basename?: string;
412
- children?: React.ReactNode;
413
- window?: Window;
414
- }
415
- /**
416
- * A `<Router>` for use in web browsers. Provides the cleanest URLs.
417
- *
418
- * @category Component Routers
419
- */
420
- declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
421
- /**
422
- * @category Types
423
- */
424
- interface HashRouterProps {
425
- basename?: string;
426
- children?: React.ReactNode;
427
- window?: Window;
428
- }
429
- /**
430
- * A `<Router>` for use in web browsers. Stores the location in the hash
431
- * portion of the URL so it is not sent to the server.
432
- *
433
- * @category Component Routers
434
- */
435
- declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
436
- /**
437
- * @category Types
438
- */
439
- interface HistoryRouterProps {
440
- basename?: string;
441
- children?: React.ReactNode;
442
- history: History;
443
- }
444
- /**
445
- * A `<Router>` that accepts a pre-instantiated history object. It's important
446
- * to note that using your own history object is highly discouraged and may add
447
- * two versions of the history library to your bundles unless you use the same
448
- * version of the history library that React Router uses internally.
449
- *
450
- * @name unstable_HistoryRouter
451
- * @category Component Routers
452
- */
453
- declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
454
- declare namespace HistoryRouter {
455
- var displayName: string;
456
- }
457
- /**
458
- * @category Types
459
- */
460
- interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
461
- /**
462
- Defines the link discovery behavior
463
-
464
- ```tsx
465
- <Link /> // default ("render")
466
- <Link discover="render" />
467
- <Link discover="none" />
468
- ```
469
-
470
- - **render** - default, discover the route when the link renders
471
- - **none** - don't eagerly discover, only discover if the link is clicked
472
- */
473
- discover?: DiscoverBehavior;
474
- /**
475
- Defines the data and module prefetching behavior for the link.
476
-
477
- ```tsx
478
- <Link /> // default
479
- <Link prefetch="none" />
480
- <Link prefetch="intent" />
481
- <Link prefetch="render" />
482
- <Link prefetch="viewport" />
483
- ```
484
-
485
- - **none** - default, no prefetching
486
- - **intent** - prefetches when the user hovers or focuses the link
487
- - **render** - prefetches when the link renders
488
- - **viewport** - prefetches when the link is in the viewport, very useful for mobile
489
-
490
- Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted after the link.
491
-
492
- ```tsx
493
- <a href="..." />
494
- <a href="..." />
495
- <link rel="prefetch" /> // might conditionally render
496
- ```
497
-
498
- 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).
499
- */
500
- prefetch?: PrefetchBehavior;
501
- /**
502
- 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>`).
503
-
504
- ```tsx
505
- <Link to="/logout" reloadDocument />
506
- ```
507
- */
508
- reloadDocument?: boolean;
509
- /**
510
- Replaces the current entry in the history stack instead of pushing a new one onto it.
511
-
512
- ```tsx
513
- <Link replace />
514
- ```
515
-
516
- ```
517
- # with a history stack like this
518
- A -> B
519
-
520
- # normal link click pushes a new entry
521
- A -> B -> C
522
-
523
- # but with `replace`, B is replaced by C
524
- A -> C
525
- ```
526
- */
527
- replace?: boolean;
528
- /**
529
- Adds persistent client side routing state to the next location.
530
-
531
- ```tsx
532
- <Link to="/somewhere/else" state={{ some: "value" }} />
533
- ```
534
-
535
- The location state is accessed from the `location`.
536
-
537
- ```tsx
538
- function SomeComp() {
539
- const location = useLocation()
540
- location.state; // { some: "value" }
541
- }
542
- ```
543
-
544
- 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)
545
- */
546
- state?: any;
547
- /**
548
- 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.
549
-
550
- ```tsx
551
- <Link to="?tab=one" preventScrollReset />
552
- ```
553
- */
554
- preventScrollReset?: boolean;
555
- /**
556
- Defines the relative path behavior for the link.
557
-
558
- ```tsx
559
- <Link to=".." /> // default: "route"
560
- <Link relative="route" />
561
- <Link relative="path" />
562
- ```
563
-
564
- Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".
565
-
566
- - **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".
567
- - **path** - relative to the path so `..` will only remove one URL segment up to "/blog/:slug"
568
- */
569
- relative?: RelativeRoutingType;
570
- /**
571
- Can be a string or a partial {@link Path}:
572
-
573
- ```tsx
574
- <Link to="/some/path" />
575
-
576
- <Link
577
- to={{
578
- pathname: "/some/path",
579
- search: "?query=string",
580
- hash: "#hash",
581
- }}
582
- />
583
- ```
584
- */
585
- to: To;
586
- /**
587
- Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) for this navigation.
588
-
589
- ```jsx
590
- <Link to={to} viewTransition>
591
- Click me
592
- </Link>
593
- ```
594
-
595
- To apply specific styles for the transition, see {@link useViewTransitionState}
596
- */
597
- viewTransition?: boolean;
598
- }
599
- /**
600
- A progressively enhanced `<a href>` wrapper to enable navigation with client-side routing.
601
-
602
- ```tsx
603
- import { Link } from "react-router";
604
-
605
- <Link to="/dashboard">Dashboard</Link>;
606
-
607
- <Link
608
- to={{
609
- pathname: "/some/path",
610
- search: "?query=string",
611
- hash: "#hash",
612
- }}
613
- />
614
- ```
615
-
616
- @category Components
617
- */
618
- declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
619
- /**
620
- The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
621
-
622
- ```
623
- // className
624
- <NavLink
625
- to="/messages"
626
- className={({ isActive, isPending }) =>
627
- isPending ? "pending" : isActive ? "active" : ""
628
- }
629
- >
630
- Messages
631
- </NavLink>
632
-
633
- // style
634
- <NavLink
635
- to="/messages"
636
- style={({ isActive, isPending }) => {
637
- return {
638
- fontWeight: isActive ? "bold" : "",
639
- color: isPending ? "red" : "black",
640
- }
641
- )}
642
- />
643
-
644
- // children
645
- <NavLink to="/tasks">
646
- {({ isActive, isPending }) => (
647
- <span className={isActive ? "active" : ""}>Tasks</span>
648
- )}
649
- </NavLink>
650
- ```
651
-
652
- */
653
- type NavLinkRenderProps = {
654
- /**
655
- * Indicates if the link's URL matches the current location.
656
- */
657
- isActive: boolean;
658
- /**
659
- * Indicates if the pending location matches the link's URL.
660
- */
661
- isPending: boolean;
662
- /**
663
- * Indicates if a view transition to the link's URL is in progress. See {@link useViewTransitionState}
664
- */
665
- isTransitioning: boolean;
666
- };
667
- /**
668
- * @category Types
669
- */
670
- interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
671
- /**
672
- Can be regular React children or a function that receives an object with the active and pending states of the link.
673
-
674
- ```tsx
675
- <NavLink to="/tasks">
676
- {({ isActive }) => (
677
- <span className={isActive ? "active" : ""}>Tasks</span>
678
- )}
679
- </NavLink>
680
- ```
681
- */
682
- children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
683
- /**
684
- Changes the matching logic to make it case-sensitive:
685
-
686
- | Link | URL | isActive |
687
- | -------------------------------------------- | ------------- | -------- |
688
- | `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
689
- | `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
690
- */
691
- caseSensitive?: boolean;
692
- /**
693
- Classes are automatically applied to NavLink that correspond to {@link NavLinkRenderProps}.
694
-
695
- ```css
696
- a.active { color: red; }
697
- a.pending { color: blue; }
698
- a.transitioning {
699
- view-transition-name: my-transition;
700
- }
701
- ```
702
- */
703
- className?: string | ((props: NavLinkRenderProps) => string | undefined);
704
- /**
705
- 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.
706
-
707
- | Link | URL | isActive |
708
- | ----------------------------- | ------------ | -------- |
709
- | `<NavLink to="/tasks" />` | `/tasks` | true |
710
- | `<NavLink to="/tasks" />` | `/tasks/123` | true |
711
- | `<NavLink to="/tasks" end />` | `/tasks` | true |
712
- | `<NavLink to="/tasks" end />` | `/tasks/123` | false |
713
-
714
- `<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.
715
- */
716
- end?: boolean;
717
- style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
718
- }
719
- /**
720
- Wraps {@link Link | `<Link>`} with additional props for styling active and pending states.
721
-
722
- - Automatically applies classes to the link based on its active and pending states, see {@link NavLinkProps.className}.
723
- - 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.
724
-
725
- ```tsx
726
- import { NavLink } from "react-router"
727
- <NavLink to="/message" />
728
- ```
729
-
730
- States are available through the className, style, and children render props. See {@link NavLinkRenderProps}.
731
-
732
- ```tsx
733
- <NavLink
734
- to="/messages"
735
- className={({ isActive, isPending }) =>
736
- isPending ? "pending" : isActive ? "active" : ""
737
- }
738
- >
739
- Messages
740
- </NavLink>
741
- ```
742
-
743
- @category Components
744
- */
745
- declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
746
- /**
747
- * Form props shared by navigations and fetchers
748
- */
749
- interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
750
- /**
751
- * The HTTP verb to use when the form is submitted. Supports "get", "post",
752
- * "put", "delete", and "patch".
753
- *
754
- * Native `<form>` only supports `get` and `post`, avoid the other verbs if
755
- * you'd like to support progressive enhancement
756
- */
757
- method?: HTMLFormMethod;
758
- /**
759
- * The encoding type to use for the form submission.
760
- */
761
- encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
762
- /**
763
- * The URL to submit the form data to. If `undefined`, this defaults to the closest route in context.
764
- */
765
- action?: string;
766
- /**
767
- * Determines whether the form action is relative to the route hierarchy or
768
- * the pathname. Use this if you want to opt out of navigating the route
769
- * hierarchy and want to instead route based on /-delimited URL segments
770
- */
771
- relative?: RelativeRoutingType;
772
- /**
773
- * Prevent the scroll position from resetting to the top of the viewport on
774
- * completion of the navigation when using the <ScrollRestoration> component
775
- */
776
- preventScrollReset?: boolean;
777
- /**
778
- * A function to call when the form is submitted. If you call
779
- * `event.preventDefault()` then this form will not do anything.
780
- */
781
- onSubmit?: React.FormEventHandler<HTMLFormElement>;
782
- }
783
- /**
784
- * Form props available to fetchers
785
- * @category Types
786
- */
787
- interface FetcherFormProps extends SharedFormProps {
788
- }
789
- /**
790
- * Form props available to navigations
791
- * @category Types
792
- */
793
- interface FormProps extends SharedFormProps {
794
- discover?: DiscoverBehavior;
795
- /**
796
- * Indicates a specific fetcherKey to use when using `navigate={false}` so you
797
- * can pick up the fetcher's state in a different component in a {@link
798
- * useFetcher}.
799
- */
800
- fetcherKey?: string;
801
- /**
802
- * Skips the navigation and uses a {@link useFetcher | fetcher} internally
803
- * when `false`. This is essentially a shorthand for `useFetcher()` +
804
- * `<fetcher.Form>` where you don't care about the resulting data in this
805
- * component.
806
- */
807
- navigate?: boolean;
808
- /**
809
- * Forces a full document navigation instead of client side routing + data
810
- * fetch.
811
- */
812
- reloadDocument?: boolean;
813
- /**
814
- * Replaces the current entry in the browser history stack when the form
815
- * navigates. Use this if you don't want the user to be able to click "back"
816
- * to the page with the form on it.
817
- */
818
- replace?: boolean;
819
- /**
820
- * State object to add to the history stack entry for this navigation
821
- */
822
- state?: any;
823
- /**
824
- * Enables a [View
825
- * Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
826
- * for this navigation. To apply specific styles during the transition see
827
- * {@link useViewTransitionState}.
828
- */
829
- viewTransition?: boolean;
830
- }
831
- /**
832
-
833
- 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.
834
-
835
- 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.
836
-
837
- 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].
838
-
839
- ```tsx
840
- import { Form } from "react-router";
841
-
842
- function NewEvent() {
843
- return (
844
- <Form action="/events" method="post">
845
- <input name="title" type="text" />
846
- <input name="description" type="text" />
847
- </Form>
848
- )
849
- }
850
- ```
851
-
852
- @category Components
853
- */
854
- declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
855
- type ScrollRestorationProps = ScriptsProps & {
856
- /**
857
- Defines the key used to restore scroll positions.
858
-
859
- ```tsx
860
- <ScrollRestoration
861
- getKey={(location, matches) => {
862
- // default behavior
863
- return location.key
864
- }}
865
- />
866
- ```
867
- */
868
- getKey?: GetScrollRestorationKeyFunction;
869
- storageKey?: string;
870
- };
871
- /**
872
- Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
873
-
874
- ```tsx
875
- import { ScrollRestoration } from "react-router";
876
-
877
- export default function Root() {
878
- return (
879
- <html>
880
- <body>
881
- <ScrollRestoration />
882
- <Scripts />
883
- </body>
884
- </html>
885
- );
886
- }
887
- ```
888
-
889
- 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.
890
-
891
- ```tsx
892
- <ScrollRestoration nonce={cspNonce} />
893
- ```
894
-
895
- @category Components
896
- */
897
- declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
898
- declare namespace ScrollRestoration {
899
- var displayName: string;
900
- }
901
- /**
902
- * Handles the click behavior for router `<Link>` components. This is useful if
903
- * you need to create custom `<Link>` components with the same click behavior we
904
- * use in our exported `<Link>`.
905
- *
906
- * @category Hooks
907
- */
908
- declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
909
- target?: React.HTMLAttributeAnchorTarget;
910
- replace?: boolean;
911
- state?: any;
912
- preventScrollReset?: boolean;
913
- relative?: RelativeRoutingType;
914
- viewTransition?: boolean;
915
- }): (event: React.MouseEvent<E, MouseEvent>) => void;
916
- /**
917
- Returns a tuple of the current URL's {@link URLSearchParams} and a function to update them. Setting the search params causes a navigation.
918
-
919
- ```tsx
920
- import { useSearchParams } from "react-router";
921
-
922
- export function SomeComponent() {
923
- const [searchParams, setSearchParams] = useSearchParams();
924
- // ...
925
- }
926
- ```
927
-
928
- @category Hooks
929
- */
930
- declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
931
- /**
932
- Sets new search params and causes a navigation when called.
933
-
934
- ```tsx
935
- <button
936
- onClick={() => {
937
- const params = new URLSearchParams();
938
- params.set("someKey", "someValue");
939
- setSearchParams(params, {
940
- preventScrollReset: true,
941
- });
942
- }}
943
- />
944
- ```
945
-
946
- It also supports a function for setting new search params.
947
-
948
- ```tsx
949
- <button
950
- onClick={() => {
951
- setSearchParams((prev) => {
952
- prev.set("someKey", "someValue");
953
- return prev;
954
- });
955
- }}
956
- />
957
- ```
958
- */
959
- type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
960
- /**
961
- * Submits a HTML `<form>` to the server without reloading the page.
962
- */
963
- interface SubmitFunction {
964
- (
965
- /**
966
- Can be multiple types of elements and objects
967
-
968
- **`HTMLFormElement`**
969
-
970
- ```tsx
971
- <Form
972
- onSubmit={(event) => {
973
- submit(event.currentTarget);
974
- }}
975
- />
976
- ```
977
-
978
- **`FormData`**
979
-
980
- ```tsx
981
- const formData = new FormData();
982
- formData.append("myKey", "myValue");
983
- submit(formData, { method: "post" });
984
- ```
985
-
986
- **Plain object that will be serialized as `FormData`**
987
-
988
- ```tsx
989
- submit({ myKey: "myValue" }, { method: "post" });
990
- ```
991
-
992
- **Plain object that will be serialized as JSON**
993
-
994
- ```tsx
995
- submit(
996
- { myKey: "myValue" },
997
- { method: "post", encType: "application/json" }
998
- );
999
- ```
1000
- */
1001
- target: SubmitTarget,
1002
- /**
1003
- * Options that override the `<form>`'s own attributes. Required when
1004
- * submitting arbitrary data without a backing `<form>`.
1005
- */
1006
- options?: SubmitOptions): Promise<void>;
1007
- }
1008
- /**
1009
- * Submits a fetcher `<form>` to the server without reloading the page.
1010
- */
1011
- interface FetcherSubmitFunction {
1012
- (
1013
- /**
1014
- Can be multiple types of elements and objects
1015
-
1016
- **`HTMLFormElement`**
1017
-
1018
- ```tsx
1019
- <fetcher.Form
1020
- onSubmit={(event) => {
1021
- fetcher.submit(event.currentTarget);
1022
- }}
1023
- />
1024
- ```
1025
-
1026
- **`FormData`**
1027
-
1028
- ```tsx
1029
- const formData = new FormData();
1030
- formData.append("myKey", "myValue");
1031
- fetcher.submit(formData, { method: "post" });
1032
- ```
1033
-
1034
- **Plain object that will be serialized as `FormData`**
1035
-
1036
- ```tsx
1037
- fetcher.submit({ myKey: "myValue" }, { method: "post" });
1038
- ```
1039
-
1040
- **Plain object that will be serialized as JSON**
1041
-
1042
- ```tsx
1043
- fetcher.submit(
1044
- { myKey: "myValue" },
1045
- { method: "post", encType: "application/json" }
1046
- );
1047
- ```
1048
-
1049
- */
1050
- target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
1051
- }
1052
- /**
1053
- The imperative version of {@link Form | `<Form>`} that lets you submit a form from code instead of a user interaction.
1054
-
1055
- ```tsx
1056
- import { useSubmit } from "react-router";
1057
-
1058
- function SomeComponent() {
1059
- const submit = useSubmit();
1060
- return (
1061
- <Form
1062
- onChange={(event) => {
1063
- submit(event.currentTarget);
1064
- }}
1065
- />
1066
- );
1067
- }
1068
- ```
1069
-
1070
- @category Hooks
1071
- */
1072
- declare function useSubmit(): SubmitFunction;
1073
- /**
1074
- Resolves the URL to the closest route in the component hierarchy instead of the current URL of the app.
1075
-
1076
- This is used internally by {@link Form} resolve the action to the closest route, but can be used generically as well.
1077
-
1078
- ```tsx
1079
- import { useFormAction } from "react-router";
1080
-
1081
- function SomeComponent() {
1082
- // closest route URL
1083
- let action = useFormAction();
1084
-
1085
- // closest route URL + "destroy"
1086
- let destroyAction = useFormAction("destroy");
1087
- }
1088
- ```
1089
-
1090
- @category Hooks
1091
- */
1092
- declare function useFormAction(
1093
- /**
1094
- * The action to append to the closest route URL.
1095
- */
1096
- action?: string, { relative }?: {
1097
- relative?: RelativeRoutingType;
1098
- }): string;
1099
- /**
1100
- The return value of `useFetcher` that keeps track of the state of a fetcher.
1101
-
1102
- ```tsx
1103
- let fetcher = useFetcher();
1104
- ```
1105
- */
1106
- type FetcherWithComponents<TData> = Fetcher<TData> & {
1107
- /**
1108
- Just like {@link Form} except it doesn't cause a navigation.
1109
-
1110
- ```tsx
1111
- function SomeComponent() {
1112
- const fetcher = useFetcher()
1113
- return (
1114
- <fetcher.Form method="post" action="/some/route">
1115
- <input type="text" />
1116
- </fetcher.Form>
1117
- )
1118
- }
1119
- ```
1120
- */
1121
- Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
1122
- /**
1123
- Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
1124
-
1125
- The `formData` can be multiple types:
1126
-
1127
- - [`FormData`][form_data] - A `FormData` instance.
1128
- - [`HTMLFormElement`][html_form_element] - A [`<form>`][form_element] DOM element.
1129
- - `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.
1130
-
1131
- 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.
1132
-
1133
- ```tsx
1134
- // Submit a FormData instance (GET request)
1135
- const formData = new FormData();
1136
- fetcher.submit(formData);
1137
-
1138
- // Submit the HTML form element
1139
- fetcher.submit(event.currentTarget.form, {
1140
- method: "POST",
1141
- });
1142
-
1143
- // Submit key/value JSON as a FormData instance
1144
- fetcher.submit(
1145
- { serialized: "values" },
1146
- { method: "POST" }
1147
- );
1148
-
1149
- // Submit raw JSON
1150
- fetcher.submit(
1151
- {
1152
- deeply: {
1153
- nested: {
1154
- json: "values",
1155
- },
1156
- },
1157
- },
1158
- {
1159
- method: "POST",
1160
- encType: "application/json",
1161
- }
1162
- );
1163
- ```
1164
- */
1165
- submit: FetcherSubmitFunction;
1166
- /**
1167
- 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.
1168
-
1169
- ```tsx
1170
- let fetcher = useFetcher()
1171
-
1172
- <input onChange={e => {
1173
- fetcher.load(`/search?q=${e.target.value}`)
1174
- }} />
1175
- ```
1176
- */
1177
- load: (href: string, opts?: {
1178
- /**
1179
- * Wraps the initial state update for this `fetcher.load` in a
1180
- * `ReactDOM.flushSync` call instead of the default `React.startTransition`.
1181
- * This allows you to perform synchronous DOM actions immediately after the
1182
- * update is flushed to the DOM.
1183
- */
1184
- flushSync?: boolean;
1185
- }) => Promise<void>;
1186
- };
1187
- /**
1188
- Useful for creating complex, dynamic user interfaces that require multiple, concurrent data interactions without causing a navigation.
1189
-
1190
- Fetchers track their own, independent state and can be used to load data, submit forms, and generally interact with loaders and actions.
1191
-
1192
- ```tsx
1193
- import { useFetcher } from "react-router"
1194
-
1195
- function SomeComponent() {
1196
- let fetcher = useFetcher()
1197
-
1198
- // states are available on the fetcher
1199
- fetcher.state // "idle" | "loading" | "submitting"
1200
- fetcher.data // the data returned from the action or loader
1201
-
1202
- // render a form
1203
- <fetcher.Form method="post" />
1204
-
1205
- // load data
1206
- fetcher.load("/some/route")
1207
-
1208
- // submit data
1209
- fetcher.submit(someFormRef, { method: "post" })
1210
- fetcher.submit(someData, {
1211
- method: "post",
1212
- encType: "application/json"
1213
- })
1214
- }
1215
- ```
1216
-
1217
- @category Hooks
1218
- */
1219
- declare function useFetcher<T = any>({ key, }?: {
1220
- /**
1221
- 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:
1222
-
1223
- ```tsx
1224
- function SomeComp() {
1225
- let fetcher = useFetcher({ key: "my-key" })
1226
- // ...
1227
- }
1228
-
1229
- // Somewhere else
1230
- function AnotherComp() {
1231
- // this will be the same fetcher, sharing the state across the app
1232
- let fetcher = useFetcher({ key: "my-key" });
1233
- // ...
1234
- }
1235
- ```
1236
- */
1237
- key?: string;
1238
- }): FetcherWithComponents<SerializeFrom<T>>;
1239
- /**
1240
- 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.
1241
-
1242
- ```tsx
1243
- import { useFetchers } from "react-router";
1244
-
1245
- function SomeComponent() {
1246
- const fetchers = useFetchers();
1247
- fetchers[0].formData; // FormData
1248
- fetchers[0].state; // etc.
1249
- // ...
1250
- }
1251
- ```
1252
-
1253
- @category Hooks
1254
- */
1255
- declare function useFetchers(): (Fetcher & {
1256
- key: string;
1257
- })[];
1258
- /**
1259
- * When rendered inside a RouterProvider, will restore scroll positions on navigations
1260
- */
1261
- declare function useScrollRestoration({ getKey, storageKey, }?: {
1262
- getKey?: GetScrollRestorationKeyFunction;
1263
- storageKey?: string;
1264
- }): void;
1265
- /**
1266
- * Setup a callback to be fired on the window's `beforeunload` event.
1267
- *
1268
- * @category Hooks
1269
- */
1270
- declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
1271
- capture?: boolean;
1272
- }): void;
1273
- /**
1274
- Wrapper around useBlocker to show a window.confirm prompt to users instead of building a custom UI with {@link useBlocker}.
1275
-
1276
- 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.
1277
-
1278
- ```tsx
1279
- function ImportantForm() {
1280
- let [value, setValue] = React.useState("");
1281
-
1282
- // Block navigating elsewhere when data has been entered into the input
1283
- unstable_usePrompt({
1284
- message: "Are you sure?",
1285
- when: ({ currentLocation, nextLocation }) =>
1286
- value !== "" &&
1287
- currentLocation.pathname !== nextLocation.pathname,
1288
- });
1289
-
1290
- return (
1291
- <Form method="post">
1292
- <label>
1293
- Enter some important data:
1294
- <input
1295
- name="data"
1296
- value={value}
1297
- onChange={(e) => setValue(e.target.value)}
1298
- />
1299
- </label>
1300
- <button type="submit">Save</button>
1301
- </Form>
1302
- );
1303
- }
1304
- ```
1305
-
1306
- @category Hooks
1307
- @name unstable_usePrompt
1308
- */
1309
- declare function usePrompt({ when, message, }: {
1310
- when: boolean | BlockerFunction;
1311
- message: string;
1312
- }): void;
1313
- /**
1314
- 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)
1315
-
1316
- @category Hooks
1317
- @name useViewTransitionState
1318
- */
1319
- declare function useViewTransitionState(to: To, opts?: {
1320
- relative?: RelativeRoutingType;
1321
- }): boolean;
1322
-
1323
- interface StaticRouterProps {
1324
- basename?: string;
1325
- children?: React.ReactNode;
1326
- location: Partial<Location> | string;
1327
- }
1328
- /**
1329
- * A `<Router>` that may not navigate to any other location. This is useful
1330
- * on the server where there is no stateful UI.
1331
- *
1332
- * @category Component Routers
1333
- */
1334
- declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
1335
- interface StaticRouterProviderProps {
1336
- context: StaticHandlerContext;
1337
- router: Router;
1338
- hydrate?: boolean;
1339
- nonce?: string;
1340
- }
1341
- /**
1342
- * A Data Router that may not navigate to any other location. This is useful
1343
- * on the server where there is no stateful UI.
1344
- *
1345
- * @category Component Routers
1346
- */
1347
- declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
1348
- type CreateStaticHandlerOptions = Omit<CreateStaticHandlerOptions$1, "mapRouteProperties">;
1349
- /**
1350
- * @category Utils
1351
- */
1352
- declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
1353
- /**
1354
- * @category Data Routers
1355
- */
1356
- declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
1357
- future?: Partial<FutureConfig$1>;
1358
- }): Router;
1359
-
1360
- export { type HandleDataRequestFunction as $, type AssetsManifest as A, type BrowserRouterProps as B, useViewTransitionState as C, type DOMRouterOpts as D, type EntryContext as E, type FutureConfig as F, type FetcherSubmitOptions as G, type HashRouterProps as H, type SubmitOptions as I, type SubmitTarget as J, createSearchParams as K, type LinkProps as L, type StaticRouterProps as M, type NavLinkProps as N, type StaticRouterProviderProps as O, type ParamKeyValuePair as P, createStaticHandler as Q, createStaticRouter as R, type ServerBuild as S, StaticRouter as T, type URLSearchParamsInit as U, StaticRouterProvider as V, Meta as W, Links as X, Scripts as Y, PrefetchPageLinks as Z, type ScriptsProps as _, type HistoryRouterProps as a, type HandleDocumentRequestFunction as a0, type HandleErrorFunction as a1, type ServerEntryModule as a2, FrameworkContext as a3, createClientRoutes as a4, createClientRoutesWithHMRRevalidationOptOut as a5, shouldHydrateRouteLoader as a6, useScrollRestoration as a7, 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 };