react-router 0.0.0-experimental-aecfb0db1 → 0.0.0-experimental-e6fb6e074

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 (51) hide show
  1. package/CHANGELOG.md +18 -753
  2. package/README.md +14 -5
  3. package/dist/index.d.ts +30 -0
  4. package/dist/index.js +1501 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/components.d.ts +157 -0
  7. package/dist/lib/context.d.ts +102 -0
  8. package/dist/lib/deprecations.d.ts +4 -0
  9. package/dist/lib/hooks.d.ts +181 -0
  10. package/dist/main.js +19 -0
  11. package/dist/react-router.development.js +1397 -0
  12. package/dist/react-router.development.js.map +1 -0
  13. package/dist/react-router.production.min.js +12 -0
  14. package/dist/react-router.production.min.js.map +1 -0
  15. package/dist/umd/react-router.development.js +1624 -0
  16. package/dist/umd/react-router.development.js.map +1 -0
  17. package/dist/umd/react-router.production.min.js +12 -0
  18. package/dist/umd/react-router.production.min.js.map +1 -0
  19. package/package.json +9 -82
  20. package/dist/development/chunk-RXFCVJK2.mjs +0 -11495
  21. package/dist/development/dom-export.d.mts +0 -23
  22. package/dist/development/dom-export.d.ts +0 -22
  23. package/dist/development/dom-export.js +0 -246
  24. package/dist/development/dom-export.mjs +0 -225
  25. package/dist/development/index.d.mts +0 -800
  26. package/dist/development/index.d.ts +0 -2530
  27. package/dist/development/index.js +0 -11645
  28. package/dist/development/index.mjs +0 -246
  29. package/dist/development/lib/types/route-module.d.mts +0 -208
  30. package/dist/development/lib/types/route-module.d.ts +0 -208
  31. package/dist/development/lib/types/route-module.js +0 -28
  32. package/dist/development/lib/types/route-module.mjs +0 -10
  33. package/dist/development/lib-BJBhVBWN.d.mts +0 -1736
  34. package/dist/development/route-data-BmDen1H_.d.mts +0 -1749
  35. package/dist/development/route-data-fNWkI-4T.d.ts +0 -1749
  36. package/dist/production/chunk-TLRBG5AD.mjs +0 -11495
  37. package/dist/production/dom-export.d.mts +0 -23
  38. package/dist/production/dom-export.d.ts +0 -22
  39. package/dist/production/dom-export.js +0 -246
  40. package/dist/production/dom-export.mjs +0 -225
  41. package/dist/production/index.d.mts +0 -800
  42. package/dist/production/index.d.ts +0 -2530
  43. package/dist/production/index.js +0 -11645
  44. package/dist/production/index.mjs +0 -246
  45. package/dist/production/lib/types/route-module.d.mts +0 -208
  46. package/dist/production/lib/types/route-module.d.ts +0 -208
  47. package/dist/production/lib/types/route-module.js +0 -28
  48. package/dist/production/lib/types/route-module.mjs +0 -10
  49. package/dist/production/lib-BJBhVBWN.d.mts +0 -1736
  50. package/dist/production/route-data-BmDen1H_.d.mts +0 -1749
  51. package/dist/production/route-data-fNWkI-4T.d.ts +0 -1749
@@ -1,2530 +0,0 @@
1
- import { R as RouteObject, a as RouterInit, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, P as PatchRoutesOnNavigationFunction, b as Router$1, T as To, c as RelativeRoutingType, N as NonIndexRouteObject, L as LazyRouteFunction, d as IndexRouteObject, e as Location, A as Action, f as Navigator, g as RouteMatch, h as RouteManifest, S as ServerRouteModule, M as MiddlewareEnabled, u as unstable_RouterContextProvider, i as AppLoadContext, j as LoaderFunctionArgs, k as ActionFunctionArgs, l as StaticHandlerContext, m as RouteModules, n as DataRouteObject, C as ClientLoaderFunction, o as ParamParseKey, p as Path, q as PathPattern, r as PathMatch, s as NavigateOptions, t as Params$1, v as Navigation, w as RevalidationState, U as UIMatch, x as SerializeFrom, B as BlockerFunction, y as Blocker, z as HTMLFormMethod, E as FormEncType, G as PageLinkDescriptor, J as History, K as GetScrollRestorationKeyFunction, O as Fetcher, Q as StaticHandler, V as CreateStaticHandlerOptions$1, W as unstable_InitialContext, X as LoaderFunction, Y as ActionFunction, Z as MetaFunction, _ as LinksFunction, $ as Equal, a0 as RouterState } from './route-data-fNWkI-4T.js';
2
- export { az as ClientActionFunction, aA as ClientActionFunctionArgs, aB as ClientLoaderFunctionArgs, ax as DataRouteMatch, a6 as DataStrategyFunctionArgs, a7 as DataStrategyMatch, a8 as DataStrategyResult, aa as ErrorResponse, ab as FormMethod, aI as Future, a1 as GetScrollPositionFunction, aC as HeadersArgs, aD as HeadersFunction, aG as HtmlLinkDescriptor, an as IDLE_BLOCKER, am as IDLE_FETCHER, al as IDLE_NAVIGATION, aH as LinkDescriptor, aE as MetaArgs, aF as MetaDescriptor, a2 as NavigationStates, ay as PatchRoutesOnNavigationFunctionArgs, ad as PathParam, ae as RedirectFunction, a5 as RouterFetchOptions, a4 as RouterNavigateOptions, a3 as RouterSubscriber, ag as ShouldRevalidateFunction, ah as ShouldRevalidateFunctionArgs, aO as UNSAFE_DataRouterContext, aP as UNSAFE_DataRouterStateContext, a9 as UNSAFE_DataWithResponseInit, aN as UNSAFE_ErrorResponseImpl, aQ as UNSAFE_FetchersContext, aR as UNSAFE_LocationContext, aS as UNSAFE_NavigationContext, aT as UNSAFE_RouteContext, aU as UNSAFE_ViewTransitionContext, aK as UNSAFE_createBrowserHistory, aM as UNSAFE_createRouter, aL as UNSAFE_invariant, aj as createPath, ao as data, ap as generatePath, aq as isRouteErrorResponse, ar as matchPath, as as matchRoutes, ak as parsePath, at as redirect, au as redirectDocument, av as replace, aw as resolvePath, ac as unstable_MiddlewareFunction, af as unstable_RouterContext, aJ as unstable_SerializesTo, ai as unstable_createContext } from './route-data-fNWkI-4T.js';
3
- import * as React from 'react';
4
- import { ReactElement } from 'react';
5
- import { ParseOptions, SerializeOptions } from 'cookie';
6
- export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
7
-
8
- /**
9
- * @private
10
- */
11
- declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
12
- hasErrorBoundary: boolean;
13
- };
14
- declare const hydrationRouteProperties: (keyof RouteObject)[];
15
- interface MemoryRouterOpts {
16
- /**
17
- * Basename path for the application.
18
- */
19
- basename?: string;
20
- /**
21
- * Function to provide the initial context values for all client side navigations/fetches
22
- */
23
- unstable_getContext?: RouterInit["unstable_getContext"];
24
- /**
25
- * Future flags to enable for the router.
26
- */
27
- future?: Partial<FutureConfig$1>;
28
- /**
29
- * Hydration data to initialize the router with if you have already performed
30
- * data loading on the server.
31
- */
32
- hydrationData?: HydrationState;
33
- /**
34
- * Initial entires in the in-memory history stack
35
- */
36
- initialEntries?: InitialEntry[];
37
- /**
38
- * Index of `initialEntries` the application should initialize to
39
- */
40
- initialIndex?: number;
41
- /**
42
- * Override the default data strategy of loading in parallel.
43
- * Only intended for advanced usage.
44
- */
45
- dataStrategy?: DataStrategyFunction;
46
- /**
47
- * Lazily define portions of the route tree on navigations.
48
- */
49
- patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
50
- }
51
- /**
52
- * Create a new data router that manages the application path using an in-memory
53
- * history stack. Useful for non-browser environments without a DOM API.
54
- *
55
- * @category Data Routers
56
- */
57
- declare function createMemoryRouter(
58
- /**
59
- * Application routes
60
- */
61
- routes: RouteObject[],
62
- /**
63
- * Router options
64
- */
65
- opts?: MemoryRouterOpts): Router$1;
66
- interface RouterProviderProps {
67
- router: Router$1;
68
- flushSync?: (fn: () => unknown) => undefined;
69
- }
70
- /**
71
- * Given a Remix Router instance, render the appropriate UI
72
- */
73
- declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
74
- /**
75
- * @category Types
76
- */
77
- interface MemoryRouterProps {
78
- basename?: string;
79
- children?: React.ReactNode;
80
- initialEntries?: InitialEntry[];
81
- initialIndex?: number;
82
- }
83
- /**
84
- * A `<Router>` that stores all entries in memory.
85
- *
86
- * @category Component Routers
87
- */
88
- declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
89
- /**
90
- * @category Types
91
- */
92
- interface NavigateProps {
93
- to: To;
94
- replace?: boolean;
95
- state?: any;
96
- relative?: RelativeRoutingType;
97
- }
98
- /**
99
- * A component-based version of {@link useNavigate} to use in a [`React.Component
100
- * Class`](https://reactjs.org/docs/react-component.html) where hooks are not
101
- * able to be used.
102
- *
103
- * It's recommended to avoid using this component in favor of {@link useNavigate}
104
- *
105
- * @category Components
106
- */
107
- declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
108
- /**
109
- * @category Types
110
- */
111
- interface OutletProps {
112
- /**
113
- Provides a context value to the element tree below the outlet. Use when the parent route needs to provide values to child routes.
114
-
115
- ```tsx
116
- <Outlet context={myContextValue} />
117
- ```
118
-
119
- Access the context with {@link useOutletContext}.
120
- */
121
- context?: unknown;
122
- }
123
- /**
124
- Renders the matching child route of a parent route or nothing if no child route matches.
125
-
126
- ```tsx
127
- import { Outlet } from "react-router"
128
-
129
- export default function SomeParent() {
130
- return (
131
- <div>
132
- <h1>Parent Content</h1>
133
- <Outlet />
134
- </div>
135
- );
136
- }
137
- ```
138
-
139
- @category Components
140
- */
141
- declare function Outlet(props: OutletProps): React.ReactElement | null;
142
- /**
143
- * @category Types
144
- */
145
- interface PathRouteProps {
146
- caseSensitive?: NonIndexRouteObject["caseSensitive"];
147
- path?: NonIndexRouteObject["path"];
148
- id?: NonIndexRouteObject["id"];
149
- lazy?: LazyRouteFunction<NonIndexRouteObject>;
150
- loader?: NonIndexRouteObject["loader"];
151
- action?: NonIndexRouteObject["action"];
152
- hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
153
- shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
154
- handle?: NonIndexRouteObject["handle"];
155
- index?: false;
156
- children?: React.ReactNode;
157
- element?: React.ReactNode | null;
158
- hydrateFallbackElement?: React.ReactNode | null;
159
- errorElement?: React.ReactNode | null;
160
- Component?: React.ComponentType | null;
161
- HydrateFallback?: React.ComponentType | null;
162
- ErrorBoundary?: React.ComponentType | null;
163
- }
164
- /**
165
- * @category Types
166
- */
167
- interface LayoutRouteProps extends PathRouteProps {
168
- }
169
- /**
170
- * @category Types
171
- */
172
- interface IndexRouteProps {
173
- caseSensitive?: IndexRouteObject["caseSensitive"];
174
- path?: IndexRouteObject["path"];
175
- id?: IndexRouteObject["id"];
176
- lazy?: LazyRouteFunction<IndexRouteObject>;
177
- loader?: IndexRouteObject["loader"];
178
- action?: IndexRouteObject["action"];
179
- hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
180
- shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
181
- handle?: IndexRouteObject["handle"];
182
- index: true;
183
- children?: undefined;
184
- element?: React.ReactNode | null;
185
- hydrateFallbackElement?: React.ReactNode | null;
186
- errorElement?: React.ReactNode | null;
187
- Component?: React.ComponentType | null;
188
- HydrateFallback?: React.ComponentType | null;
189
- ErrorBoundary?: React.ComponentType | null;
190
- }
191
- type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
192
- /**
193
- * Configures an element to render when a pattern matches the current location.
194
- * It must be rendered within a {@link Routes} element. Note that these routes
195
- * do not participate in data loading, actions, code splitting, or any other
196
- * route module features.
197
- *
198
- * @category Components
199
- */
200
- declare function Route$1(_props: RouteProps): React.ReactElement | null;
201
- /**
202
- * @category Types
203
- */
204
- interface RouterProps {
205
- basename?: string;
206
- children?: React.ReactNode;
207
- location: Partial<Location> | string;
208
- navigationType?: Action;
209
- navigator: Navigator;
210
- static?: boolean;
211
- }
212
- /**
213
- * Provides location context for the rest of the app.
214
- *
215
- * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
216
- * router that is more specific to your environment such as a `<BrowserRouter>`
217
- * in web browsers or a `<StaticRouter>` for server rendering.
218
- *
219
- * @category Components
220
- */
221
- declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
222
- /**
223
- * @category Types
224
- */
225
- interface RoutesProps {
226
- /**
227
- * Nested {@link Route} elements
228
- */
229
- children?: React.ReactNode;
230
- /**
231
- * The location to match against. Defaults to the current location.
232
- */
233
- location?: Partial<Location> | string;
234
- }
235
- /**
236
- Renders a branch of {@link Route | `<Routes>`} that best matches the current
237
- location. Note that these routes do not participate in data loading, actions,
238
- code splitting, or any other route module features.
239
-
240
- ```tsx
241
- import { Routes, Route } from "react-router"
242
-
243
- <Routes>
244
- <Route index element={<StepOne />} />
245
- <Route path="step-2" element={<StepTwo />} />
246
- <Route path="step-3" element={<StepThree />}>
247
- </Routes>
248
- ```
249
-
250
- @category Components
251
- */
252
- declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
253
- interface AwaitResolveRenderFunction<Resolve = any> {
254
- (data: Awaited<Resolve>): React.ReactNode;
255
- }
256
- /**
257
- * @category Types
258
- */
259
- interface AwaitProps<Resolve> {
260
- /**
261
- When using a function, the resolved value is provided as the parameter.
262
-
263
- ```tsx [2]
264
- <Await resolve={reviewsPromise}>
265
- {(resolvedReviews) => <Reviews items={resolvedReviews} />}
266
- </Await>
267
- ```
268
-
269
- When using React elements, {@link useAsyncValue} will provide the
270
- resolved value:
271
-
272
- ```tsx [2]
273
- <Await resolve={reviewsPromise}>
274
- <Reviews />
275
- </Await>
276
-
277
- function Reviews() {
278
- const resolvedReviews = useAsyncValue()
279
- return <div>...</div>
280
- }
281
- ```
282
- */
283
- children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
284
- /**
285
- The error element renders instead of the children when the promise rejects.
286
-
287
- ```tsx
288
- <Await
289
- errorElement={<div>Oops</div>}
290
- resolve={reviewsPromise}
291
- >
292
- <Reviews />
293
- </Await>
294
- ```
295
-
296
- To provide a more contextual error, you can use the {@link useAsyncError} in a
297
- child component
298
-
299
- ```tsx
300
- <Await
301
- errorElement={<ReviewsError />}
302
- resolve={reviewsPromise}
303
- >
304
- <Reviews />
305
- </Await>
306
-
307
- function ReviewsError() {
308
- const error = useAsyncError()
309
- return <div>Error loading reviews: {error.message}</div>
310
- }
311
- ```
312
-
313
- If you do not provide an errorElement, the rejected value will bubble up to
314
- the nearest route-level {@link NonIndexRouteObject#ErrorBoundary | ErrorBoundary} and be accessible
315
- via {@link useRouteError} hook.
316
- */
317
- errorElement?: React.ReactNode;
318
- /**
319
- Takes a promise returned from a {@link LoaderFunction | loader} value to be resolved and rendered.
320
-
321
- ```jsx
322
- import { useLoaderData, Await } from "react-router"
323
-
324
- export async function loader() {
325
- let reviews = getReviews() // not awaited
326
- let book = await getBook()
327
- return {
328
- book,
329
- reviews, // this is a promise
330
- }
331
- }
332
-
333
- export default function Book() {
334
- const {
335
- book,
336
- reviews, // this is the same promise
337
- } = useLoaderData()
338
-
339
- return (
340
- <div>
341
- <h1>{book.title}</h1>
342
- <p>{book.description}</p>
343
- <React.Suspense fallback={<ReviewsSkeleton />}>
344
- <Await
345
- // and is the promise we pass to Await
346
- resolve={reviews}
347
- >
348
- <Reviews />
349
- </Await>
350
- </React.Suspense>
351
- </div>
352
- );
353
- }
354
- ```
355
- */
356
- resolve: Resolve;
357
- }
358
- /**
359
- Used to render promise values with automatic error handling.
360
-
361
- ```tsx
362
- import { Await, useLoaderData } from "react-router";
363
-
364
- export function loader() {
365
- // not awaited
366
- const reviews = getReviews()
367
- // awaited (blocks the transition)
368
- const book = await fetch("/api/book").then((res) => res.json())
369
- return { book, reviews }
370
- }
371
-
372
- function Book() {
373
- const { book, reviews } = useLoaderData();
374
- return (
375
- <div>
376
- <h1>{book.title}</h1>
377
- <p>{book.description}</p>
378
- <React.Suspense fallback={<ReviewsSkeleton />}>
379
- <Await
380
- resolve={reviews}
381
- errorElement={
382
- <div>Could not load reviews 😬</div>
383
- }
384
- children={(resolvedReviews) => (
385
- <Reviews items={resolvedReviews} />
386
- )}
387
- />
388
- </React.Suspense>
389
- </div>
390
- );
391
- }
392
- ```
393
-
394
- **Note:** `<Await>` expects to be rendered inside of a `<React.Suspense>`
395
-
396
- @category Components
397
-
398
- */
399
- declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
400
- /**
401
- * Creates a route config from a React "children" object, which is usually
402
- * either a `<Route>` element or an array of them. Used internally by
403
- * `<Routes>` to create a route config from its children.
404
- *
405
- * @category Utils
406
- */
407
- declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
408
- /**
409
- * Create route objects from JSX elements instead of arrays of objects
410
- */
411
- declare let createRoutesFromElements: typeof createRoutesFromChildren;
412
- /**
413
- * Renders the result of `matchRoutes()` into a React element.
414
- *
415
- * @category Utils
416
- */
417
- declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
418
-
419
- type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
420
- interface ServerRoute extends Route {
421
- children: ServerRoute[];
422
- module: ServerRouteModule;
423
- }
424
-
425
- type OptionalCriticalCss = CriticalCss | undefined;
426
- /**
427
- * The output of the compiler for the server build.
428
- */
429
- interface ServerBuild {
430
- entry: {
431
- module: ServerEntryModule;
432
- };
433
- routes: ServerRouteManifest;
434
- assets: AssetsManifest;
435
- basename?: string;
436
- publicPath: string;
437
- assetsBuildDirectory: string;
438
- future: FutureConfig;
439
- ssr: boolean;
440
- unstable_getCriticalCss?: (args: {
441
- pathname: string;
442
- }) => OptionalCriticalCss | Promise<OptionalCriticalCss>;
443
- /**
444
- * @deprecated This is now done via a custom header during prerendering
445
- */
446
- isSpaMode: boolean;
447
- prerender: string[];
448
- routeDiscovery: {
449
- mode: "lazy" | "initial";
450
- manifestPath: string;
451
- };
452
- }
453
- interface HandleDocumentRequestFunction {
454
- (request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext): Promise<Response> | Response;
455
- }
456
- interface HandleDataRequestFunction {
457
- (response: Response, args: LoaderFunctionArgs | ActionFunctionArgs): Promise<Response> | Response;
458
- }
459
- interface HandleErrorFunction {
460
- (error: unknown, args: LoaderFunctionArgs | ActionFunctionArgs): void;
461
- }
462
- /**
463
- * A module that serves as the entry point for a Remix app during server
464
- * rendering.
465
- */
466
- interface ServerEntryModule {
467
- default: HandleDocumentRequestFunction;
468
- handleDataRequest?: HandleDataRequestFunction;
469
- handleError?: HandleErrorFunction;
470
- streamTimeout?: number;
471
- }
472
-
473
- type SerializedError = {
474
- message: string;
475
- stack?: string;
476
- };
477
- interface FrameworkContextObject {
478
- manifest: AssetsManifest;
479
- routeModules: RouteModules;
480
- criticalCss?: CriticalCss;
481
- serverHandoffString?: string;
482
- future: FutureConfig;
483
- ssr: boolean;
484
- isSpaMode: boolean;
485
- routeDiscovery: ServerBuild["routeDiscovery"];
486
- serializeError?(error: Error): SerializedError;
487
- renderMeta?: {
488
- didRenderScripts?: boolean;
489
- streamCache?: Record<number, Promise<void> & {
490
- result?: {
491
- done: boolean;
492
- value: string;
493
- };
494
- error?: unknown;
495
- }>;
496
- };
497
- }
498
- interface EntryContext extends FrameworkContextObject {
499
- staticHandlerContext: StaticHandlerContext;
500
- serverHandoffStream?: ReadableStream<Uint8Array>;
501
- }
502
- interface FutureConfig {
503
- unstable_subResourceIntegrity: boolean;
504
- unstable_middleware: boolean;
505
- }
506
- type CriticalCss = string | {
507
- rel: "stylesheet";
508
- href: string;
509
- };
510
- interface AssetsManifest {
511
- entry: {
512
- imports: string[];
513
- module: string;
514
- };
515
- routes: RouteManifest<EntryRoute>;
516
- url: string;
517
- version: string;
518
- hmr?: {
519
- timestamp?: number;
520
- runtime: string;
521
- };
522
- sri?: Record<string, string> | true;
523
- }
524
-
525
- interface Route {
526
- index?: boolean;
527
- caseSensitive?: boolean;
528
- id: string;
529
- parentId?: string;
530
- path?: string;
531
- }
532
- interface EntryRoute extends Route {
533
- hasAction: boolean;
534
- hasLoader: boolean;
535
- hasClientAction: boolean;
536
- hasClientLoader: boolean;
537
- hasClientMiddleware: boolean;
538
- hasErrorBoundary: boolean;
539
- imports?: string[];
540
- css?: string[];
541
- module: string;
542
- clientActionModule: string | undefined;
543
- clientLoaderModule: string | undefined;
544
- clientMiddlewareModule: string | undefined;
545
- hydrateFallbackModule: string | undefined;
546
- parentId?: string;
547
- }
548
- declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, ssr: boolean, isSpaMode: boolean): DataRouteObject[];
549
- 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[];
550
- declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
551
-
552
- declare const SingleFetchRedirectSymbol: unique symbol;
553
- declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router$1, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined): DataStrategyFunction;
554
- declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
555
- done: Promise<undefined>;
556
- value: unknown;
557
- }>;
558
-
559
- /**
560
- * The mode to use when running the server.
561
- */
562
- declare enum ServerMode {
563
- Development = "development",
564
- Production = "production",
565
- Test = "test"
566
- }
567
-
568
- /**
569
- Resolves a URL against the current location.
570
-
571
- ```tsx
572
- import { useHref } from "react-router"
573
-
574
- function SomeComponent() {
575
- let href = useHref("some/where");
576
- // "/resolved/some/where"
577
- }
578
- ```
579
-
580
- @category Hooks
581
- */
582
- declare function useHref(to: To, { relative }?: {
583
- relative?: RelativeRoutingType;
584
- }): string;
585
- /**
586
- * Returns true if this component is a descendant of a Router, useful to ensure
587
- * a component is used within a Router.
588
- *
589
- * @category Hooks
590
- */
591
- declare function useInRouterContext(): boolean;
592
- /**
593
- Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
594
-
595
- ```tsx
596
- import * as React from 'react'
597
- import { useLocation } from 'react-router'
598
-
599
- function SomeComponent() {
600
- let location = useLocation()
601
-
602
- React.useEffect(() => {
603
- // Google Analytics
604
- ga('send', 'pageview')
605
- }, [location]);
606
-
607
- return (
608
- // ...
609
- );
610
- }
611
- ```
612
-
613
- @category Hooks
614
- */
615
- declare function useLocation(): Location;
616
- /**
617
- * Returns the current navigation action which describes how the router came to
618
- * the current location, either by a pop, push, or replace on the history stack.
619
- *
620
- * @category Hooks
621
- */
622
- declare function useNavigationType(): Action;
623
- /**
624
- * Returns a PathMatch object if the given pattern matches the current URL.
625
- * This is useful for components that need to know "active" state, e.g.
626
- * `<NavLink>`.
627
- *
628
- * @category Hooks
629
- */
630
- declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
631
- /**
632
- * The interface for the navigate() function returned from useNavigate().
633
- */
634
- interface NavigateFunction {
635
- (to: To, options?: NavigateOptions): void | Promise<void>;
636
- (delta: number): void | Promise<void>;
637
- }
638
- /**
639
- Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
640
-
641
- ```tsx
642
- import { useNavigate } from "react-router";
643
-
644
- function SomeComponent() {
645
- let navigate = useNavigate();
646
- return (
647
- <button
648
- onClick={() => {
649
- navigate(-1);
650
- }}
651
- />
652
- );
653
- }
654
- ```
655
-
656
- It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
657
-
658
- @category Hooks
659
- */
660
- declare function useNavigate(): NavigateFunction;
661
- /**
662
- * Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
663
- *
664
- * @category Hooks
665
- */
666
- declare function useOutletContext<Context = unknown>(): Context;
667
- /**
668
- * Returns the element for the child route at this level of the route
669
- * hierarchy. Used internally by `<Outlet>` to render child routes.
670
- *
671
- * @category Hooks
672
- */
673
- declare function useOutlet(context?: unknown): React.ReactElement | null;
674
- /**
675
- Returns an object of key/value pairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.
676
-
677
- ```tsx
678
- import { useParams } from "react-router"
679
-
680
- function SomeComponent() {
681
- let params = useParams()
682
- params.postId
683
- }
684
- ```
685
-
686
- Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
687
-
688
- @category Hooks
689
- */
690
- declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
691
- ParamsOrKey
692
- ] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>;
693
- /**
694
- Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
695
-
696
- ```tsx
697
- import { useResolvedPath } from "react-router"
698
-
699
- function SomeComponent() {
700
- // if the user is at /dashboard/profile
701
- let path = useResolvedPath("../accounts")
702
- path.pathname // "/dashboard/accounts"
703
- path.search // ""
704
- path.hash // ""
705
- }
706
- ```
707
-
708
- @category Hooks
709
- */
710
- declare function useResolvedPath(to: To, { relative }?: {
711
- relative?: RelativeRoutingType;
712
- }): Path;
713
- /**
714
- Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
715
-
716
- The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
717
-
718
- ```tsx
719
- import * as React from "react";
720
- import { useRoutes } from "react-router";
721
-
722
- function App() {
723
- let element = useRoutes([
724
- {
725
- path: "/",
726
- element: <Dashboard />,
727
- children: [
728
- {
729
- path: "messages",
730
- element: <DashboardMessages />,
731
- },
732
- { path: "tasks", element: <DashboardTasks /> },
733
- ],
734
- },
735
- { path: "team", element: <AboutPage /> },
736
- ]);
737
-
738
- return element;
739
- }
740
- ```
741
-
742
- @category Hooks
743
- */
744
- declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
745
- /**
746
- Returns the current navigation, defaulting to an "idle" navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or read FormData from a form navigation.
747
-
748
- ```tsx
749
- import { useNavigation } from "react-router"
750
-
751
- function SomeComponent() {
752
- let navigation = useNavigation();
753
- navigation.state
754
- navigation.formData
755
- // etc.
756
- }
757
- ```
758
-
759
- @category Hooks
760
- */
761
- declare function useNavigation(): Navigation;
762
- /**
763
- Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
764
-
765
- ```tsx
766
- import { useRevalidator } from "react-router";
767
-
768
- function WindowFocusRevalidator() {
769
- const revalidator = useRevalidator();
770
-
771
- useFakeWindowFocus(() => {
772
- revalidator.revalidate();
773
- });
774
-
775
- return (
776
- <div hidden={revalidator.state === "idle"}>
777
- Revalidating...
778
- </div>
779
- );
780
- }
781
- ```
782
-
783
- Note that page data is already revalidated automatically after actions. If you find yourself using this for normal CRUD operations on your data in response to user interactions, you're probably not taking advantage of the other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do this automatically.
784
-
785
- @category Hooks
786
- */
787
- declare function useRevalidator(): {
788
- revalidate(): Promise<void>;
789
- state: RevalidationState;
790
- };
791
- /**
792
- * Returns the active route matches, useful for accessing loaderData for
793
- * parent/child routes or the route "handle" property
794
- *
795
- * @category Hooks
796
- */
797
- declare function useMatches(): UIMatch[];
798
- /**
799
- Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
800
-
801
- ```tsx
802
- import { useLoaderData } from "react-router"
803
-
804
- export async function loader() {
805
- return await fakeDb.invoices.findAll();
806
- }
807
-
808
- export default function Invoices() {
809
- let invoices = useLoaderData<typeof loader>();
810
- // ...
811
- }
812
- ```
813
-
814
- @category Hooks
815
- */
816
- declare function useLoaderData<T = any>(): SerializeFrom<T>;
817
- /**
818
- Returns the loader data for a given route by route ID.
819
-
820
- ```tsx
821
- import { useRouteLoaderData } from "react-router";
822
-
823
- function SomeComponent() {
824
- const { user } = useRouteLoaderData("root");
825
- }
826
- ```
827
-
828
- Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
829
-
830
- | Route Filename | Route ID |
831
- | -------------------------- | -------------------- |
832
- | `app/root.tsx` | `"root"` |
833
- | `app/routes/teams.tsx` | `"routes/teams"` |
834
- | `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
835
-
836
- If you created an ID manually, you can use that instead:
837
-
838
- ```tsx
839
- route("/", "containers/app.tsx", { id: "app" }})
840
- ```
841
-
842
- @category Hooks
843
- */
844
- declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
845
- /**
846
- Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
847
-
848
- ```tsx
849
- import { Form, useActionData } from "react-router"
850
-
851
- export async function action({ request }) {
852
- const body = await request.formData()
853
- const name = body.get("visitorsName")
854
- return { message: `Hello, ${name}` }
855
- }
856
-
857
- export default function Invoices() {
858
- const data = useActionData()
859
- return (
860
- <Form method="post">
861
- <input type="text" name="visitorsName" />
862
- {data ? data.message : "Waiting..."}
863
- </Form>
864
- )
865
- }
866
- ```
867
-
868
- @category Hooks
869
- */
870
- declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
871
- /**
872
- Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
873
-
874
- ```tsx
875
- export function ErrorBoundary() {
876
- const error = useRouteError();
877
- return <div>{error.message}</div>;
878
- }
879
- ```
880
-
881
- @category Hooks
882
- */
883
- declare function useRouteError(): unknown;
884
- /**
885
- Returns the resolved promise value from the closest {@link Await | `<Await>`}.
886
-
887
- ```tsx
888
- function SomeDescendant() {
889
- const value = useAsyncValue();
890
- // ...
891
- }
892
-
893
- // somewhere in your app
894
- <Await resolve={somePromise}>
895
- <SomeDescendant />
896
- </Await>
897
- ```
898
-
899
- @category Hooks
900
- */
901
- declare function useAsyncValue(): unknown;
902
- /**
903
- Returns the rejection value from the closest {@link Await | `<Await>`}.
904
-
905
- ```tsx
906
- import { Await, useAsyncError } from "react-router"
907
-
908
- function ErrorElement() {
909
- const error = useAsyncError();
910
- return (
911
- <p>Uh Oh, something went wrong! {error.message}</p>
912
- );
913
- }
914
-
915
- // somewhere in your app
916
- <Await
917
- resolve={promiseThatRejects}
918
- errorElement={<ErrorElement />}
919
- />
920
- ```
921
-
922
- @category Hooks
923
- */
924
- declare function useAsyncError(): unknown;
925
- /**
926
- * Allow the application to block navigations within the SPA and present the
927
- * user a confirmation dialog to confirm the navigation. Mostly used to avoid
928
- * using half-filled form data. This does not handle hard-reloads or
929
- * cross-origin navigations.
930
- *
931
- * @category Hooks
932
- */
933
- declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
934
-
935
- type ParamKeyValuePair = [string, string];
936
- type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
937
- /**
938
- Creates a URLSearchParams object using the given initializer.
939
-
940
- This is identical to `new URLSearchParams(init)` except it also
941
- supports arrays as values in the object form of the initializer
942
- instead of just strings. This is convenient when you need multiple
943
- values for a given key, but don't want to use an array initializer.
944
-
945
- For example, instead of:
946
-
947
- ```tsx
948
- let searchParams = new URLSearchParams([
949
- ['sort', 'name'],
950
- ['sort', 'price']
951
- ]);
952
- ```
953
- you can do:
954
-
955
- ```
956
- let searchParams = createSearchParams({
957
- sort: ['name', 'price']
958
- });
959
- ```
960
-
961
- @category Utils
962
- */
963
- declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
964
- type JsonObject = {
965
- [Key in string]: JsonValue;
966
- } & {
967
- [Key in string]?: JsonValue | undefined;
968
- };
969
- type JsonArray = JsonValue[] | readonly JsonValue[];
970
- type JsonPrimitive = string | number | boolean | null;
971
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
972
- type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
973
- /**
974
- * Submit options shared by both navigations and fetchers
975
- */
976
- interface SharedSubmitOptions {
977
- /**
978
- * The HTTP method used to submit the form. Overrides `<form method>`.
979
- * Defaults to "GET".
980
- */
981
- method?: HTMLFormMethod;
982
- /**
983
- * The action URL path used to submit the form. Overrides `<form action>`.
984
- * Defaults to the path of the current route.
985
- */
986
- action?: string;
987
- /**
988
- * The encoding used to submit the form. Overrides `<form encType>`.
989
- * Defaults to "application/x-www-form-urlencoded".
990
- */
991
- encType?: FormEncType;
992
- /**
993
- * Determines whether the form action is relative to the route hierarchy or
994
- * the pathname. Use this if you want to opt out of navigating the route
995
- * hierarchy and want to instead route based on /-delimited URL segments
996
- */
997
- relative?: RelativeRoutingType;
998
- /**
999
- * In browser-based environments, prevent resetting scroll after this
1000
- * navigation when using the <ScrollRestoration> component
1001
- */
1002
- preventScrollReset?: boolean;
1003
- /**
1004
- * Enable flushSync for this submission's state updates
1005
- */
1006
- flushSync?: boolean;
1007
- }
1008
- /**
1009
- * Submit options available to fetchers
1010
- */
1011
- interface FetcherSubmitOptions extends SharedSubmitOptions {
1012
- }
1013
- /**
1014
- * Submit options available to navigations
1015
- */
1016
- interface SubmitOptions extends FetcherSubmitOptions {
1017
- /**
1018
- * Set `true` to replace the current entry in the browser's history stack
1019
- * instead of creating a new one (i.e. stay on "the same page"). Defaults
1020
- * to `false`.
1021
- */
1022
- replace?: boolean;
1023
- /**
1024
- * State object to add to the history stack entry for this navigation
1025
- */
1026
- state?: any;
1027
- /**
1028
- * Indicate a specific fetcherKey to use when using navigate=false
1029
- */
1030
- fetcherKey?: string;
1031
- /**
1032
- * navigate=false will use a fetcher instead of a navigation
1033
- */
1034
- navigate?: boolean;
1035
- /**
1036
- * Enable view transitions on this submission navigation
1037
- */
1038
- viewTransition?: boolean;
1039
- }
1040
-
1041
- declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
1042
- /**
1043
- * Defines the discovery behavior of the link:
1044
- *
1045
- * - "render" - default, discover the route when the link renders
1046
- * - "none" - don't eagerly discover, only discover if the link is clicked
1047
- */
1048
- type DiscoverBehavior = "render" | "none";
1049
- /**
1050
- * Defines the prefetching behavior of the link:
1051
- *
1052
- * - "none": Never fetched
1053
- * - "intent": Fetched when the user focuses or hovers the link
1054
- * - "render": Fetched when the link is rendered
1055
- * - "viewport": Fetched when the link is in the viewport
1056
- */
1057
- type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
1058
- /**
1059
- Renders all of the `<link>` tags created by route module {@link LinksFunction} export. You should render it inside the `<head>` of your document.
1060
-
1061
- ```tsx
1062
- import { Links } from "react-router";
1063
-
1064
- export default function Root() {
1065
- return (
1066
- <html>
1067
- <head>
1068
- <Links />
1069
- </head>
1070
- <body></body>
1071
- </html>
1072
- );
1073
- }
1074
- ```
1075
-
1076
- @category Components
1077
- */
1078
- declare function Links(): React.JSX.Element;
1079
- /**
1080
- 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.
1081
-
1082
- ```tsx
1083
- import { PrefetchPageLinks } from "react-router"
1084
-
1085
- <PrefetchPageLinks page="/absolute/path" />
1086
- ```
1087
-
1088
- 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.
1089
-
1090
- @category Components
1091
- */
1092
- declare function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor): React.JSX.Element | null;
1093
- /**
1094
- Renders all the `<meta>` tags created by route module {@link MetaFunction} exports. You should render it inside the `<head>` of your HTML.
1095
-
1096
- ```tsx
1097
- import { Meta } from "react-router";
1098
-
1099
- export default function Root() {
1100
- return (
1101
- <html>
1102
- <head>
1103
- <Meta />
1104
- </head>
1105
- </html>
1106
- );
1107
- }
1108
- ```
1109
-
1110
- @category Components
1111
- */
1112
- declare function Meta(): React.JSX.Element;
1113
- /**
1114
- A couple common attributes:
1115
-
1116
- - `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
1117
- - `<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.
1118
-
1119
- You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
1120
-
1121
- @category Types
1122
- */
1123
- type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
1124
- /**
1125
- Renders the client runtime of your app. It should be rendered inside the `<body>` of the document.
1126
-
1127
- ```tsx
1128
- import { Scripts } from "react-router";
1129
-
1130
- export default function Root() {
1131
- return (
1132
- <html>
1133
- <head />
1134
- <body>
1135
- <Scripts />
1136
- </body>
1137
- </html>
1138
- );
1139
- }
1140
- ```
1141
-
1142
- 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.
1143
-
1144
- @category Components
1145
- */
1146
- declare function Scripts(props: ScriptsProps): React.JSX.Element | null;
1147
-
1148
- declare global {
1149
- const REACT_ROUTER_VERSION: string;
1150
- }
1151
- /**
1152
- * @category Routers
1153
- */
1154
- interface DOMRouterOpts {
1155
- /**
1156
- * Basename path for the application.
1157
- */
1158
- basename?: string;
1159
- /**
1160
- * Function to provide the initial context values for all client side navigations/fetches
1161
- */
1162
- unstable_getContext?: RouterInit["unstable_getContext"];
1163
- /**
1164
- * Future flags to enable for the router.
1165
- */
1166
- future?: Partial<FutureConfig$1>;
1167
- /**
1168
- * Hydration data to initialize the router with if you have already performed
1169
- * data loading on the server.
1170
- */
1171
- hydrationData?: HydrationState;
1172
- /**
1173
- * Override the default data strategy of loading in parallel.
1174
- * Only intended for advanced usage.
1175
- */
1176
- dataStrategy?: DataStrategyFunction;
1177
- /**
1178
- * Lazily define portions of the route tree on navigations.
1179
- */
1180
- patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
1181
- /**
1182
- * Window object override - defaults to the global `window` instance.
1183
- */
1184
- window?: Window;
1185
- }
1186
- /**
1187
- * Create a new data router that manages the application path via `history.pushState`
1188
- * and `history.replaceState`.
1189
- *
1190
- * @category Data Routers
1191
- */
1192
- declare function createBrowserRouter(
1193
- /**
1194
- * Application routes
1195
- */
1196
- routes: RouteObject[],
1197
- /**
1198
- * Router options
1199
- */
1200
- opts?: DOMRouterOpts): Router$1;
1201
- /**
1202
- * Create a new data router that manages the application path via the URL hash
1203
- *
1204
- * @category Data Routers
1205
- */
1206
- declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
1207
- /**
1208
- * @category Types
1209
- */
1210
- interface BrowserRouterProps {
1211
- basename?: string;
1212
- children?: React.ReactNode;
1213
- window?: Window;
1214
- }
1215
- /**
1216
- * A `<Router>` for use in web browsers. Provides the cleanest URLs.
1217
- *
1218
- * @category Component Routers
1219
- */
1220
- declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
1221
- /**
1222
- * @category Types
1223
- */
1224
- interface HashRouterProps {
1225
- basename?: string;
1226
- children?: React.ReactNode;
1227
- window?: Window;
1228
- }
1229
- /**
1230
- * A `<Router>` for use in web browsers. Stores the location in the hash
1231
- * portion of the URL so it is not sent to the server.
1232
- *
1233
- * @category Component Routers
1234
- */
1235
- declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
1236
- /**
1237
- * @category Types
1238
- */
1239
- interface HistoryRouterProps {
1240
- basename?: string;
1241
- children?: React.ReactNode;
1242
- history: History;
1243
- }
1244
- /**
1245
- * A `<Router>` that accepts a pre-instantiated history object. It's important
1246
- * to note that using your own history object is highly discouraged and may add
1247
- * two versions of the history library to your bundles unless you use the same
1248
- * version of the history library that React Router uses internally.
1249
- *
1250
- * @name unstable_HistoryRouter
1251
- * @category Component Routers
1252
- */
1253
- declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
1254
- declare namespace HistoryRouter {
1255
- var displayName: string;
1256
- }
1257
- /**
1258
- * @category Types
1259
- */
1260
- interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
1261
- /**
1262
- Defines the link discovery behavior
1263
-
1264
- ```tsx
1265
- <Link /> // default ("render")
1266
- <Link discover="render" />
1267
- <Link discover="none" />
1268
- ```
1269
-
1270
- - **render** - default, discover the route when the link renders
1271
- - **none** - don't eagerly discover, only discover if the link is clicked
1272
- */
1273
- discover?: DiscoverBehavior;
1274
- /**
1275
- Defines the data and module prefetching behavior for the link.
1276
-
1277
- ```tsx
1278
- <Link /> // default
1279
- <Link prefetch="none" />
1280
- <Link prefetch="intent" />
1281
- <Link prefetch="render" />
1282
- <Link prefetch="viewport" />
1283
- ```
1284
-
1285
- - **none** - default, no prefetching
1286
- - **intent** - prefetches when the user hovers or focuses the link
1287
- - **render** - prefetches when the link renders
1288
- - **viewport** - prefetches when the link is in the viewport, very useful for mobile
1289
-
1290
- Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted after the link.
1291
-
1292
- ```tsx
1293
- <a href="..." />
1294
- <a href="..." />
1295
- <link rel="prefetch" /> // might conditionally render
1296
- ```
1297
-
1298
- 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).
1299
- */
1300
- prefetch?: PrefetchBehavior;
1301
- /**
1302
- 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>`).
1303
-
1304
- ```tsx
1305
- <Link to="/logout" reloadDocument />
1306
- ```
1307
- */
1308
- reloadDocument?: boolean;
1309
- /**
1310
- Replaces the current entry in the history stack instead of pushing a new one onto it.
1311
-
1312
- ```tsx
1313
- <Link replace />
1314
- ```
1315
-
1316
- ```
1317
- # with a history stack like this
1318
- A -> B
1319
-
1320
- # normal link click pushes a new entry
1321
- A -> B -> C
1322
-
1323
- # but with `replace`, B is replaced by C
1324
- A -> C
1325
- ```
1326
- */
1327
- replace?: boolean;
1328
- /**
1329
- Adds persistent client side routing state to the next location.
1330
-
1331
- ```tsx
1332
- <Link to="/somewhere/else" state={{ some: "value" }} />
1333
- ```
1334
-
1335
- The location state is accessed from the `location`.
1336
-
1337
- ```tsx
1338
- function SomeComp() {
1339
- const location = useLocation()
1340
- location.state; // { some: "value" }
1341
- }
1342
- ```
1343
-
1344
- 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)
1345
- */
1346
- state?: any;
1347
- /**
1348
- 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.
1349
-
1350
- ```tsx
1351
- <Link to="?tab=one" preventScrollReset />
1352
- ```
1353
- */
1354
- preventScrollReset?: boolean;
1355
- /**
1356
- Defines the relative path behavior for the link.
1357
-
1358
- ```tsx
1359
- <Link to=".." /> // default: "route"
1360
- <Link relative="route" />
1361
- <Link relative="path" />
1362
- ```
1363
-
1364
- Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".
1365
-
1366
- - **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".
1367
- - **path** - relative to the path so `..` will only remove one URL segment up to "/blog/:slug"
1368
- */
1369
- relative?: RelativeRoutingType;
1370
- /**
1371
- Can be a string or a partial {@link Path}:
1372
-
1373
- ```tsx
1374
- <Link to="/some/path" />
1375
-
1376
- <Link
1377
- to={{
1378
- pathname: "/some/path",
1379
- search: "?query=string",
1380
- hash: "#hash",
1381
- }}
1382
- />
1383
- ```
1384
- */
1385
- to: To;
1386
- /**
1387
- Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) for this navigation.
1388
-
1389
- ```jsx
1390
- <Link to={to} viewTransition>
1391
- Click me
1392
- </Link>
1393
- ```
1394
-
1395
- To apply specific styles for the transition, see {@link useViewTransitionState}
1396
- */
1397
- viewTransition?: boolean;
1398
- }
1399
- /**
1400
- A progressively enhanced `<a href>` wrapper to enable navigation with client-side routing.
1401
-
1402
- ```tsx
1403
- import { Link } from "react-router";
1404
-
1405
- <Link to="/dashboard">Dashboard</Link>;
1406
-
1407
- <Link
1408
- to={{
1409
- pathname: "/some/path",
1410
- search: "?query=string",
1411
- hash: "#hash",
1412
- }}
1413
- />
1414
- ```
1415
-
1416
- @category Components
1417
- */
1418
- declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
1419
- /**
1420
- The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
1421
-
1422
- ```
1423
- // className
1424
- <NavLink
1425
- to="/messages"
1426
- className={({ isActive, isPending }) =>
1427
- isPending ? "pending" : isActive ? "active" : ""
1428
- }
1429
- >
1430
- Messages
1431
- </NavLink>
1432
-
1433
- // style
1434
- <NavLink
1435
- to="/messages"
1436
- style={({ isActive, isPending }) => {
1437
- return {
1438
- fontWeight: isActive ? "bold" : "",
1439
- color: isPending ? "red" : "black",
1440
- }
1441
- )}
1442
- />
1443
-
1444
- // children
1445
- <NavLink to="/tasks">
1446
- {({ isActive, isPending }) => (
1447
- <span className={isActive ? "active" : ""}>Tasks</span>
1448
- )}
1449
- </NavLink>
1450
- ```
1451
-
1452
- */
1453
- type NavLinkRenderProps = {
1454
- /**
1455
- * Indicates if the link's URL matches the current location.
1456
- */
1457
- isActive: boolean;
1458
- /**
1459
- * Indicates if the pending location matches the link's URL.
1460
- */
1461
- isPending: boolean;
1462
- /**
1463
- * Indicates if a view transition to the link's URL is in progress. See {@link useViewTransitionState}
1464
- */
1465
- isTransitioning: boolean;
1466
- };
1467
- /**
1468
- * @category Types
1469
- */
1470
- interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
1471
- /**
1472
- Can be regular React children or a function that receives an object with the active and pending states of the link.
1473
-
1474
- ```tsx
1475
- <NavLink to="/tasks">
1476
- {({ isActive }) => (
1477
- <span className={isActive ? "active" : ""}>Tasks</span>
1478
- )}
1479
- </NavLink>
1480
- ```
1481
- */
1482
- children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
1483
- /**
1484
- Changes the matching logic to make it case-sensitive:
1485
-
1486
- | Link | URL | isActive |
1487
- | -------------------------------------------- | ------------- | -------- |
1488
- | `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
1489
- | `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
1490
- */
1491
- caseSensitive?: boolean;
1492
- /**
1493
- Classes are automatically applied to NavLink that correspond to {@link NavLinkRenderProps}.
1494
-
1495
- ```css
1496
- a.active { color: red; }
1497
- a.pending { color: blue; }
1498
- a.transitioning {
1499
- view-transition-name: my-transition;
1500
- }
1501
- ```
1502
- */
1503
- className?: string | ((props: NavLinkRenderProps) => string | undefined);
1504
- /**
1505
- 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.
1506
-
1507
- | Link | URL | isActive |
1508
- | ----------------------------- | ------------ | -------- |
1509
- | `<NavLink to="/tasks" />` | `/tasks` | true |
1510
- | `<NavLink to="/tasks" />` | `/tasks/123` | true |
1511
- | `<NavLink to="/tasks" end />` | `/tasks` | true |
1512
- | `<NavLink to="/tasks" end />` | `/tasks/123` | false |
1513
-
1514
- `<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.
1515
- */
1516
- end?: boolean;
1517
- style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
1518
- }
1519
- /**
1520
- Wraps {@link Link | `<Link>`} with additional props for styling active and pending states.
1521
-
1522
- - Automatically applies classes to the link based on its active and pending states, see {@link NavLinkProps.className}.
1523
- - 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.
1524
-
1525
- ```tsx
1526
- import { NavLink } from "react-router"
1527
- <NavLink to="/message" />
1528
- ```
1529
-
1530
- States are available through the className, style, and children render props. See {@link NavLinkRenderProps}.
1531
-
1532
- ```tsx
1533
- <NavLink
1534
- to="/messages"
1535
- className={({ isActive, isPending }) =>
1536
- isPending ? "pending" : isActive ? "active" : ""
1537
- }
1538
- >
1539
- Messages
1540
- </NavLink>
1541
- ```
1542
-
1543
- @category Components
1544
- */
1545
- declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
1546
- /**
1547
- * Form props shared by navigations and fetchers
1548
- */
1549
- interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
1550
- /**
1551
- * The HTTP verb to use when the form is submitted. Supports "get", "post",
1552
- * "put", "delete", and "patch".
1553
- *
1554
- * Native `<form>` only supports `get` and `post`, avoid the other verbs if
1555
- * you'd like to support progressive enhancement
1556
- */
1557
- method?: HTMLFormMethod;
1558
- /**
1559
- * The encoding type to use for the form submission.
1560
- */
1561
- encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
1562
- /**
1563
- * The URL to submit the form data to. If `undefined`, this defaults to the closest route in context.
1564
- */
1565
- action?: string;
1566
- /**
1567
- * Determines whether the form action is relative to the route hierarchy or
1568
- * the pathname. Use this if you want to opt out of navigating the route
1569
- * hierarchy and want to instead route based on /-delimited URL segments
1570
- */
1571
- relative?: RelativeRoutingType;
1572
- /**
1573
- * Prevent the scroll position from resetting to the top of the viewport on
1574
- * completion of the navigation when using the <ScrollRestoration> component
1575
- */
1576
- preventScrollReset?: boolean;
1577
- /**
1578
- * A function to call when the form is submitted. If you call
1579
- * `event.preventDefault()` then this form will not do anything.
1580
- */
1581
- onSubmit?: React.FormEventHandler<HTMLFormElement>;
1582
- }
1583
- /**
1584
- * Form props available to fetchers
1585
- * @category Types
1586
- */
1587
- interface FetcherFormProps extends SharedFormProps {
1588
- }
1589
- /**
1590
- * Form props available to navigations
1591
- * @category Types
1592
- */
1593
- interface FormProps extends SharedFormProps {
1594
- discover?: DiscoverBehavior;
1595
- /**
1596
- * Indicates a specific fetcherKey to use when using `navigate={false}` so you
1597
- * can pick up the fetcher's state in a different component in a {@link
1598
- * useFetcher}.
1599
- */
1600
- fetcherKey?: string;
1601
- /**
1602
- * Skips the navigation and uses a {@link useFetcher | fetcher} internally
1603
- * when `false`. This is essentially a shorthand for `useFetcher()` +
1604
- * `<fetcher.Form>` where you don't care about the resulting data in this
1605
- * component.
1606
- */
1607
- navigate?: boolean;
1608
- /**
1609
- * Forces a full document navigation instead of client side routing + data
1610
- * fetch.
1611
- */
1612
- reloadDocument?: boolean;
1613
- /**
1614
- * Replaces the current entry in the browser history stack when the form
1615
- * navigates. Use this if you don't want the user to be able to click "back"
1616
- * to the page with the form on it.
1617
- */
1618
- replace?: boolean;
1619
- /**
1620
- * State object to add to the history stack entry for this navigation
1621
- */
1622
- state?: any;
1623
- /**
1624
- * Enables a [View
1625
- * Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1626
- * for this navigation. To apply specific styles during the transition see
1627
- * {@link useViewTransitionState}.
1628
- */
1629
- viewTransition?: boolean;
1630
- }
1631
- /**
1632
-
1633
- 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.
1634
-
1635
- 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.
1636
-
1637
- 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].
1638
-
1639
- ```tsx
1640
- import { Form } from "react-router";
1641
-
1642
- function NewEvent() {
1643
- return (
1644
- <Form action="/events" method="post">
1645
- <input name="title" type="text" />
1646
- <input name="description" type="text" />
1647
- </Form>
1648
- )
1649
- }
1650
- ```
1651
-
1652
- @category Components
1653
- */
1654
- declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
1655
- type ScrollRestorationProps = ScriptsProps & {
1656
- /**
1657
- Defines the key used to restore scroll positions.
1658
-
1659
- ```tsx
1660
- <ScrollRestoration
1661
- getKey={(location, matches) => {
1662
- // default behavior
1663
- return location.key
1664
- }}
1665
- />
1666
- ```
1667
- */
1668
- getKey?: GetScrollRestorationKeyFunction;
1669
- storageKey?: string;
1670
- };
1671
- /**
1672
- Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
1673
-
1674
- ```tsx
1675
- import { ScrollRestoration } from "react-router";
1676
-
1677
- export default function Root() {
1678
- return (
1679
- <html>
1680
- <body>
1681
- <ScrollRestoration />
1682
- <Scripts />
1683
- </body>
1684
- </html>
1685
- );
1686
- }
1687
- ```
1688
-
1689
- 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.
1690
-
1691
- ```tsx
1692
- <ScrollRestoration nonce={cspNonce} />
1693
- ```
1694
-
1695
- @category Components
1696
- */
1697
- declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
1698
- declare namespace ScrollRestoration {
1699
- var displayName: string;
1700
- }
1701
- /**
1702
- * Handles the click behavior for router `<Link>` components. This is useful if
1703
- * you need to create custom `<Link>` components with the same click behavior we
1704
- * use in our exported `<Link>`.
1705
- *
1706
- * @category Hooks
1707
- */
1708
- declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
1709
- target?: React.HTMLAttributeAnchorTarget;
1710
- replace?: boolean;
1711
- state?: any;
1712
- preventScrollReset?: boolean;
1713
- relative?: RelativeRoutingType;
1714
- viewTransition?: boolean;
1715
- }): (event: React.MouseEvent<E, MouseEvent>) => void;
1716
- /**
1717
- Returns a tuple of the current URL's {@link URLSearchParams} and a function to update them. Setting the search params causes a navigation.
1718
-
1719
- ```tsx
1720
- import { useSearchParams } from "react-router";
1721
-
1722
- export function SomeComponent() {
1723
- const [searchParams, setSearchParams] = useSearchParams();
1724
- // ...
1725
- }
1726
- ```
1727
-
1728
- @category Hooks
1729
- */
1730
- declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
1731
- /**
1732
- Sets new search params and causes a navigation when called.
1733
-
1734
- ```tsx
1735
- <button
1736
- onClick={() => {
1737
- const params = new URLSearchParams();
1738
- params.set("someKey", "someValue");
1739
- setSearchParams(params, {
1740
- preventScrollReset: true,
1741
- });
1742
- }}
1743
- />
1744
- ```
1745
-
1746
- It also supports a function for setting new search params.
1747
-
1748
- ```tsx
1749
- <button
1750
- onClick={() => {
1751
- setSearchParams((prev) => {
1752
- prev.set("someKey", "someValue");
1753
- return prev;
1754
- });
1755
- }}
1756
- />
1757
- ```
1758
- */
1759
- type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
1760
- /**
1761
- * Submits a HTML `<form>` to the server without reloading the page.
1762
- */
1763
- interface SubmitFunction {
1764
- (
1765
- /**
1766
- Can be multiple types of elements and objects
1767
-
1768
- **`HTMLFormElement`**
1769
-
1770
- ```tsx
1771
- <Form
1772
- onSubmit={(event) => {
1773
- submit(event.currentTarget);
1774
- }}
1775
- />
1776
- ```
1777
-
1778
- **`FormData`**
1779
-
1780
- ```tsx
1781
- const formData = new FormData();
1782
- formData.append("myKey", "myValue");
1783
- submit(formData, { method: "post" });
1784
- ```
1785
-
1786
- **Plain object that will be serialized as `FormData`**
1787
-
1788
- ```tsx
1789
- submit({ myKey: "myValue" }, { method: "post" });
1790
- ```
1791
-
1792
- **Plain object that will be serialized as JSON**
1793
-
1794
- ```tsx
1795
- submit(
1796
- { myKey: "myValue" },
1797
- { method: "post", encType: "application/json" }
1798
- );
1799
- ```
1800
- */
1801
- target: SubmitTarget,
1802
- /**
1803
- * Options that override the `<form>`'s own attributes. Required when
1804
- * submitting arbitrary data without a backing `<form>`.
1805
- */
1806
- options?: SubmitOptions): Promise<void>;
1807
- }
1808
- /**
1809
- * Submits a fetcher `<form>` to the server without reloading the page.
1810
- */
1811
- interface FetcherSubmitFunction {
1812
- (
1813
- /**
1814
- Can be multiple types of elements and objects
1815
-
1816
- **`HTMLFormElement`**
1817
-
1818
- ```tsx
1819
- <fetcher.Form
1820
- onSubmit={(event) => {
1821
- fetcher.submit(event.currentTarget);
1822
- }}
1823
- />
1824
- ```
1825
-
1826
- **`FormData`**
1827
-
1828
- ```tsx
1829
- const formData = new FormData();
1830
- formData.append("myKey", "myValue");
1831
- fetcher.submit(formData, { method: "post" });
1832
- ```
1833
-
1834
- **Plain object that will be serialized as `FormData`**
1835
-
1836
- ```tsx
1837
- fetcher.submit({ myKey: "myValue" }, { method: "post" });
1838
- ```
1839
-
1840
- **Plain object that will be serialized as JSON**
1841
-
1842
- ```tsx
1843
- fetcher.submit(
1844
- { myKey: "myValue" },
1845
- { method: "post", encType: "application/json" }
1846
- );
1847
- ```
1848
-
1849
- */
1850
- target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
1851
- }
1852
- /**
1853
- The imperative version of {@link Form | `<Form>`} that lets you submit a form from code instead of a user interaction.
1854
-
1855
- ```tsx
1856
- import { useSubmit } from "react-router";
1857
-
1858
- function SomeComponent() {
1859
- const submit = useSubmit();
1860
- return (
1861
- <Form
1862
- onChange={(event) => {
1863
- submit(event.currentTarget);
1864
- }}
1865
- />
1866
- );
1867
- }
1868
- ```
1869
-
1870
- @category Hooks
1871
- */
1872
- declare function useSubmit(): SubmitFunction;
1873
- /**
1874
- Resolves the URL to the closest route in the component hierarchy instead of the current URL of the app.
1875
-
1876
- This is used internally by {@link Form} resolve the action to the closest route, but can be used generically as well.
1877
-
1878
- ```tsx
1879
- import { useFormAction } from "react-router";
1880
-
1881
- function SomeComponent() {
1882
- // closest route URL
1883
- let action = useFormAction();
1884
-
1885
- // closest route URL + "destroy"
1886
- let destroyAction = useFormAction("destroy");
1887
- }
1888
- ```
1889
-
1890
- @category Hooks
1891
- */
1892
- declare function useFormAction(
1893
- /**
1894
- * The action to append to the closest route URL.
1895
- */
1896
- action?: string, { relative }?: {
1897
- relative?: RelativeRoutingType;
1898
- }): string;
1899
- /**
1900
- The return value of `useFetcher` that keeps track of the state of a fetcher.
1901
-
1902
- ```tsx
1903
- let fetcher = useFetcher();
1904
- ```
1905
- */
1906
- type FetcherWithComponents<TData> = Fetcher<TData> & {
1907
- /**
1908
- Just like {@link Form} except it doesn't cause a navigation.
1909
-
1910
- ```tsx
1911
- function SomeComponent() {
1912
- const fetcher = useFetcher()
1913
- return (
1914
- <fetcher.Form method="post" action="/some/route">
1915
- <input type="text" />
1916
- </fetcher.Form>
1917
- )
1918
- }
1919
- ```
1920
- */
1921
- Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
1922
- /**
1923
- Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
1924
-
1925
- The `formData` can be multiple types:
1926
-
1927
- - [`FormData`][form_data] - A `FormData` instance.
1928
- - [`HTMLFormElement`][html_form_element] - A [`<form>`][form_element] DOM element.
1929
- - `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.
1930
-
1931
- 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.
1932
-
1933
- ```tsx
1934
- // Submit a FormData instance (GET request)
1935
- const formData = new FormData();
1936
- fetcher.submit(formData);
1937
-
1938
- // Submit the HTML form element
1939
- fetcher.submit(event.currentTarget.form, {
1940
- method: "POST",
1941
- });
1942
-
1943
- // Submit key/value JSON as a FormData instance
1944
- fetcher.submit(
1945
- { serialized: "values" },
1946
- { method: "POST" }
1947
- );
1948
-
1949
- // Submit raw JSON
1950
- fetcher.submit(
1951
- {
1952
- deeply: {
1953
- nested: {
1954
- json: "values",
1955
- },
1956
- },
1957
- },
1958
- {
1959
- method: "POST",
1960
- encType: "application/json",
1961
- }
1962
- );
1963
- ```
1964
- */
1965
- submit: FetcherSubmitFunction;
1966
- /**
1967
- 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.
1968
-
1969
- ```tsx
1970
- let fetcher = useFetcher()
1971
-
1972
- <input onChange={e => {
1973
- fetcher.load(`/search?q=${e.target.value}`)
1974
- }} />
1975
- ```
1976
- */
1977
- load: (href: string, opts?: {
1978
- /**
1979
- * Wraps the initial state update for this `fetcher.load` in a
1980
- * `ReactDOM.flushSync` call instead of the default `React.startTransition`.
1981
- * This allows you to perform synchronous DOM actions immediately after the
1982
- * update is flushed to the DOM.
1983
- */
1984
- flushSync?: boolean;
1985
- }) => Promise<void>;
1986
- };
1987
- /**
1988
- Useful for creating complex, dynamic user interfaces that require multiple, concurrent data interactions without causing a navigation.
1989
-
1990
- Fetchers track their own, independent state and can be used to load data, submit forms, and generally interact with loaders and actions.
1991
-
1992
- ```tsx
1993
- import { useFetcher } from "react-router"
1994
-
1995
- function SomeComponent() {
1996
- let fetcher = useFetcher()
1997
-
1998
- // states are available on the fetcher
1999
- fetcher.state // "idle" | "loading" | "submitting"
2000
- fetcher.data // the data returned from the action or loader
2001
-
2002
- // render a form
2003
- <fetcher.Form method="post" />
2004
-
2005
- // load data
2006
- fetcher.load("/some/route")
2007
-
2008
- // submit data
2009
- fetcher.submit(someFormRef, { method: "post" })
2010
- fetcher.submit(someData, {
2011
- method: "post",
2012
- encType: "application/json"
2013
- })
2014
- }
2015
- ```
2016
-
2017
- @category Hooks
2018
- */
2019
- declare function useFetcher<T = any>({ key, }?: {
2020
- /**
2021
- 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:
2022
-
2023
- ```tsx
2024
- function SomeComp() {
2025
- let fetcher = useFetcher({ key: "my-key" })
2026
- // ...
2027
- }
2028
-
2029
- // Somewhere else
2030
- function AnotherComp() {
2031
- // this will be the same fetcher, sharing the state across the app
2032
- let fetcher = useFetcher({ key: "my-key" });
2033
- // ...
2034
- }
2035
- ```
2036
- */
2037
- key?: string;
2038
- }): FetcherWithComponents<SerializeFrom<T>>;
2039
- /**
2040
- 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.
2041
-
2042
- ```tsx
2043
- import { useFetchers } from "react-router";
2044
-
2045
- function SomeComponent() {
2046
- const fetchers = useFetchers();
2047
- fetchers[0].formData; // FormData
2048
- fetchers[0].state; // etc.
2049
- // ...
2050
- }
2051
- ```
2052
-
2053
- @category Hooks
2054
- */
2055
- declare function useFetchers(): (Fetcher & {
2056
- key: string;
2057
- })[];
2058
- /**
2059
- * When rendered inside a RouterProvider, will restore scroll positions on navigations
2060
- */
2061
- declare function useScrollRestoration({ getKey, storageKey, }?: {
2062
- getKey?: GetScrollRestorationKeyFunction;
2063
- storageKey?: string;
2064
- }): void;
2065
- /**
2066
- * Setup a callback to be fired on the window's `beforeunload` event.
2067
- *
2068
- * @category Hooks
2069
- */
2070
- declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
2071
- capture?: boolean;
2072
- }): void;
2073
- /**
2074
- Wrapper around useBlocker to show a window.confirm prompt to users instead of building a custom UI with {@link useBlocker}.
2075
-
2076
- 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.
2077
-
2078
- ```tsx
2079
- function ImportantForm() {
2080
- let [value, setValue] = React.useState("");
2081
-
2082
- // Block navigating elsewhere when data has been entered into the input
2083
- unstable_usePrompt({
2084
- message: "Are you sure?",
2085
- when: ({ currentLocation, nextLocation }) =>
2086
- value !== "" &&
2087
- currentLocation.pathname !== nextLocation.pathname,
2088
- });
2089
-
2090
- return (
2091
- <Form method="post">
2092
- <label>
2093
- Enter some important data:
2094
- <input
2095
- name="data"
2096
- value={value}
2097
- onChange={(e) => setValue(e.target.value)}
2098
- />
2099
- </label>
2100
- <button type="submit">Save</button>
2101
- </Form>
2102
- );
2103
- }
2104
- ```
2105
-
2106
- @category Hooks
2107
- @name unstable_usePrompt
2108
- */
2109
- declare function usePrompt({ when, message, }: {
2110
- when: boolean | BlockerFunction;
2111
- message: string;
2112
- }): void;
2113
- /**
2114
- 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)
2115
-
2116
- @category Hooks
2117
- @name useViewTransitionState
2118
- */
2119
- declare function useViewTransitionState(to: To, opts?: {
2120
- relative?: RelativeRoutingType;
2121
- }): boolean;
2122
-
2123
- interface StaticRouterProps {
2124
- basename?: string;
2125
- children?: React.ReactNode;
2126
- location: Partial<Location> | string;
2127
- }
2128
- /**
2129
- * A `<Router>` that may not navigate to any other location. This is useful
2130
- * on the server where there is no stateful UI.
2131
- *
2132
- * @category Component Routers
2133
- */
2134
- declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
2135
- interface StaticRouterProviderProps {
2136
- context: StaticHandlerContext;
2137
- router: Router$1;
2138
- hydrate?: boolean;
2139
- nonce?: string;
2140
- }
2141
- /**
2142
- * A Data Router that may not navigate to any other location. This is useful
2143
- * on the server where there is no stateful UI.
2144
- *
2145
- * @category Component Routers
2146
- */
2147
- declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
2148
- type CreateStaticHandlerOptions = Omit<CreateStaticHandlerOptions$1, "mapRouteProperties">;
2149
- /**
2150
- * @category Utils
2151
- */
2152
- declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
2153
- /**
2154
- * @category Data Routers
2155
- */
2156
- declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
2157
- future?: Partial<FutureConfig$1>;
2158
- }): Router$1;
2159
-
2160
- interface ServerRouterProps {
2161
- context: EntryContext;
2162
- url: string | URL;
2163
- nonce?: string;
2164
- }
2165
- /**
2166
- * The entry point for a Remix app when it is rendered on the server (in
2167
- * `app/entry.server.js`). This component is used to generate the HTML in the
2168
- * response from the server.
2169
- *
2170
- * @category Components
2171
- */
2172
- declare function ServerRouter({ context, url, nonce, }: ServerRouterProps): ReactElement;
2173
-
2174
- interface StubIndexRouteObject extends Omit<IndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
2175
- loader?: LoaderFunction;
2176
- action?: ActionFunction;
2177
- children?: StubRouteObject[];
2178
- meta?: MetaFunction;
2179
- links?: LinksFunction;
2180
- }
2181
- interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
2182
- loader?: LoaderFunction;
2183
- action?: ActionFunction;
2184
- children?: StubRouteObject[];
2185
- meta?: MetaFunction;
2186
- links?: LinksFunction;
2187
- }
2188
- type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
2189
- interface RoutesTestStubProps {
2190
- /**
2191
- * The initial entries in the history stack. This allows you to start a test with
2192
- * multiple locations already in the history stack (for testing a back navigation, etc.)
2193
- * The test will default to the last entry in initialEntries if no initialIndex is provided.
2194
- * e.g. initialEntries={["/home", "/about", "/contact"]}
2195
- */
2196
- initialEntries?: InitialEntry[];
2197
- /**
2198
- * The initial index in the history stack to render. This allows you to start a test at a specific entry.
2199
- * It defaults to the last entry in initialEntries.
2200
- * e.g.
2201
- * initialEntries: ["/", "/events/123"]
2202
- * initialIndex: 1 // start at "/events/123"
2203
- */
2204
- initialIndex?: number;
2205
- /**
2206
- * Used to set the route's initial loader and action data.
2207
- * e.g. hydrationData={{
2208
- * loaderData: { "/contact": { locale: "en-US" } },
2209
- * actionData: { "/login": { errors: { email: "invalid email" } }}
2210
- * }}
2211
- */
2212
- hydrationData?: HydrationState;
2213
- /**
2214
- * Future flags mimicking the settings in react-router.config.ts
2215
- */
2216
- future?: Partial<FutureConfig>;
2217
- }
2218
- /**
2219
- * @category Utils
2220
- */
2221
- declare function createRoutesStub(routes: StubRouteObject[], unstable_getContext?: () => unstable_InitialContext): ({ initialEntries, initialIndex, hydrationData, future, }: RoutesTestStubProps) => React.JSX.Element;
2222
-
2223
- interface CookieSignatureOptions {
2224
- /**
2225
- * An array of secrets that may be used to sign/unsign the value of a cookie.
2226
- *
2227
- * The array makes it easy to rotate secrets. New secrets should be added to
2228
- * the beginning of the array. `cookie.serialize()` will always use the first
2229
- * value in the array, but `cookie.parse()` may use any of them so that
2230
- * cookies that were signed with older secrets still work.
2231
- */
2232
- secrets?: string[];
2233
- }
2234
- type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
2235
- /**
2236
- * A HTTP cookie.
2237
- *
2238
- * A Cookie is a logical container for metadata about a HTTP cookie; its name
2239
- * and options. But it doesn't contain a value. Instead, it has `parse()` and
2240
- * `serialize()` methods that allow a single instance to be reused for
2241
- * parsing/encoding multiple different values.
2242
- *
2243
- * @see https://remix.run/utils/cookies#cookie-api
2244
- */
2245
- interface Cookie {
2246
- /**
2247
- * The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
2248
- */
2249
- readonly name: string;
2250
- /**
2251
- * True if this cookie uses one or more secrets for verification.
2252
- */
2253
- readonly isSigned: boolean;
2254
- /**
2255
- * The Date this cookie expires.
2256
- *
2257
- * Note: This is calculated at access time using `maxAge` when no `expires`
2258
- * option is provided to `createCookie()`.
2259
- */
2260
- readonly expires?: Date;
2261
- /**
2262
- * Parses a raw `Cookie` header and returns the value of this cookie or
2263
- * `null` if it's not present.
2264
- */
2265
- parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;
2266
- /**
2267
- * Serializes the given value to a string and returns the `Set-Cookie`
2268
- * header.
2269
- */
2270
- serialize(value: any, options?: SerializeOptions): Promise<string>;
2271
- }
2272
- /**
2273
- * Creates a logical container for managing a browser cookie from the server.
2274
- */
2275
- declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
2276
- type IsCookieFunction = (object: any) => object is Cookie;
2277
- /**
2278
- * Returns true if an object is a Remix cookie container.
2279
- *
2280
- * @see https://remix.run/utils/cookies#iscookie
2281
- */
2282
- declare const isCookie: IsCookieFunction;
2283
-
2284
- type RequestHandler = (request: Request, loadContext?: MiddlewareEnabled extends true ? unstable_InitialContext : AppLoadContext) => Promise<Response>;
2285
- type CreateRequestHandlerFunction = (build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>), mode?: string) => RequestHandler;
2286
- declare const createRequestHandler: CreateRequestHandlerFunction;
2287
-
2288
- /**
2289
- * An object of name/value pairs to be used in the session.
2290
- */
2291
- interface SessionData {
2292
- [name: string]: any;
2293
- }
2294
- /**
2295
- * Session persists data across HTTP requests.
2296
- *
2297
- * @see https://reactrouter.com/explanation/sessions-and-cookies#sessions
2298
- */
2299
- interface Session<Data = SessionData, FlashData = Data> {
2300
- /**
2301
- * A unique identifier for this session.
2302
- *
2303
- * Note: This will be the empty string for newly created sessions and
2304
- * sessions that are not backed by a database (i.e. cookie-based sessions).
2305
- */
2306
- readonly id: string;
2307
- /**
2308
- * The raw data contained in this session.
2309
- *
2310
- * This is useful mostly for SessionStorage internally to access the raw
2311
- * session data to persist.
2312
- */
2313
- readonly data: FlashSessionData<Data, FlashData>;
2314
- /**
2315
- * Returns `true` if the session has a value for the given `name`, `false`
2316
- * otherwise.
2317
- */
2318
- has(name: (keyof Data | keyof FlashData) & string): boolean;
2319
- /**
2320
- * Returns the value for the given `name` in this session.
2321
- */
2322
- get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
2323
- /**
2324
- * Sets a value in the session for the given `name`.
2325
- */
2326
- set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
2327
- /**
2328
- * Sets a value in the session that is only valid until the next `get()`.
2329
- * This can be useful for temporary values, like error messages.
2330
- */
2331
- flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
2332
- /**
2333
- * Removes a value from the session.
2334
- */
2335
- unset(name: keyof Data & string): void;
2336
- }
2337
- type FlashSessionData<Data, FlashData> = Partial<Data & {
2338
- [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
2339
- }>;
2340
- type FlashDataKey<Key extends string> = `__flash_${Key}__`;
2341
- type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
2342
- /**
2343
- * Creates a new Session object.
2344
- *
2345
- * Note: This function is typically not invoked directly by application code.
2346
- * Instead, use a `SessionStorage` object's `getSession` method.
2347
- */
2348
- declare const createSession: CreateSessionFunction;
2349
- type IsSessionFunction = (object: any) => object is Session;
2350
- /**
2351
- * Returns true if an object is a React Router session.
2352
- *
2353
- * @see https://reactrouter.com/api/utils/isSession
2354
- */
2355
- declare const isSession: IsSessionFunction;
2356
- /**
2357
- * SessionStorage stores session data between HTTP requests and knows how to
2358
- * parse and create cookies.
2359
- *
2360
- * A SessionStorage creates Session objects using a `Cookie` header as input.
2361
- * Then, later it generates the `Set-Cookie` header to be used in the response.
2362
- */
2363
- interface SessionStorage<Data = SessionData, FlashData = Data> {
2364
- /**
2365
- * Parses a Cookie header from a HTTP request and returns the associated
2366
- * Session. If there is no session associated with the cookie, this will
2367
- * return a new Session with no data.
2368
- */
2369
- getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>;
2370
- /**
2371
- * Stores all data in the Session and returns the Set-Cookie header to be
2372
- * used in the HTTP response.
2373
- */
2374
- commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
2375
- /**
2376
- * Deletes all data associated with the Session and returns the Set-Cookie
2377
- * header to be used in the HTTP response.
2378
- */
2379
- destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
2380
- }
2381
- /**
2382
- * SessionIdStorageStrategy is designed to allow anyone to easily build their
2383
- * own SessionStorage using `createSessionStorage(strategy)`.
2384
- *
2385
- * This strategy describes a common scenario where the session id is stored in
2386
- * a cookie but the actual session data is stored elsewhere, usually in a
2387
- * database or on disk. A set of create, read, update, and delete operations
2388
- * are provided for managing the session data.
2389
- */
2390
- interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
2391
- /**
2392
- * The Cookie used to store the session id, or options used to automatically
2393
- * create one.
2394
- */
2395
- cookie?: Cookie | (CookieOptions & {
2396
- name?: string;
2397
- });
2398
- /**
2399
- * Creates a new record with the given data and returns the session id.
2400
- */
2401
- createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
2402
- /**
2403
- * Returns data for a given session id, or `null` if there isn't any.
2404
- */
2405
- readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
2406
- /**
2407
- * Updates data for the given session id.
2408
- */
2409
- updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
2410
- /**
2411
- * Deletes data for a given session id from the data store.
2412
- */
2413
- deleteData: (id: string) => Promise<void>;
2414
- }
2415
- /**
2416
- * Creates a SessionStorage object using a SessionIdStorageStrategy.
2417
- *
2418
- * Note: This is a low-level API that should only be used if none of the
2419
- * existing session storage options meet your requirements.
2420
- */
2421
- declare function createSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg, createData, readData, updateData, deleteData, }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
2422
-
2423
- interface CookieSessionStorageOptions {
2424
- /**
2425
- * The Cookie used to store the session data on the client, or options used
2426
- * to automatically create one.
2427
- */
2428
- cookie?: SessionIdStorageStrategy["cookie"];
2429
- }
2430
- /**
2431
- * Creates and returns a SessionStorage object that stores all session data
2432
- * directly in the session cookie itself.
2433
- *
2434
- * This has the advantage that no database or other backend services are
2435
- * needed, and can help to simplify some load-balanced scenarios. However, it
2436
- * also has the limitation that serialized session data may not exceed the
2437
- * browser's maximum cookie size. Trade-offs!
2438
- */
2439
- declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
2440
-
2441
- interface MemorySessionStorageOptions {
2442
- /**
2443
- * The Cookie used to store the session id on the client, or options used
2444
- * to automatically create one.
2445
- */
2446
- cookie?: SessionIdStorageStrategy["cookie"];
2447
- }
2448
- /**
2449
- * Creates and returns a simple in-memory SessionStorage object, mostly useful
2450
- * for testing and as a reference implementation.
2451
- *
2452
- * Note: This storage does not scale beyond a single process, so it is not
2453
- * suitable for most production scenarios.
2454
- */
2455
- declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
2456
-
2457
- type DevServerHooks = {
2458
- getCriticalCss?: (pathname: string) => Promise<string | undefined>;
2459
- processRequestError?: (error: unknown) => void;
2460
- };
2461
- declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
2462
-
2463
- /**
2464
- * Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
2465
- * React Router should handle this for you via type generation.
2466
- *
2467
- * For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
2468
- */
2469
- interface Register {
2470
- }
2471
-
2472
- type AnyParams = Record<string, Record<string, string | undefined>>;
2473
- type Params = Register extends {
2474
- params: infer RegisteredParams extends AnyParams;
2475
- } ? RegisteredParams : AnyParams;
2476
- type Args = {
2477
- [K in keyof Params]: ToArgs<Params[K]>;
2478
- };
2479
- type ToArgs<T> = Equal<T, {}> extends true ? [] : Partial<T> extends T ? [T] | [] : [
2480
- T
2481
- ];
2482
- /**
2483
- Returns a resolved URL path for the specified route.
2484
-
2485
- ```tsx
2486
- const h = href("/:lang?/about", { lang: "en" })
2487
- // -> `/en/about`
2488
-
2489
- <Link to={href("/products/:id", { id: "abc123" })} />
2490
- ```
2491
- */
2492
- declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
2493
-
2494
- declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
2495
-
2496
- type RemixErrorBoundaryProps = React.PropsWithChildren<{
2497
- location: Location;
2498
- isOutsideRemixApp?: boolean;
2499
- error?: Error;
2500
- }>;
2501
- type RemixErrorBoundaryState = {
2502
- error: null | Error;
2503
- location: Location;
2504
- };
2505
- declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps, RemixErrorBoundaryState> {
2506
- constructor(props: RemixErrorBoundaryProps);
2507
- static getDerivedStateFromError(error: Error): {
2508
- error: Error;
2509
- };
2510
- static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): {
2511
- error: Error | null;
2512
- location: Location<any>;
2513
- };
2514
- render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
2515
- }
2516
-
2517
- declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
2518
- declare function useFogOFWarDiscovery(router: Router$1, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean): void;
2519
-
2520
- declare function getHydrationData(state: {
2521
- loaderData?: Router$1["state"]["loaderData"];
2522
- actionData?: Router$1["state"]["actionData"];
2523
- errors?: Router$1["state"]["errors"];
2524
- }, routes: DataRouteObject[], getRouteInfo: (routeId: string) => {
2525
- clientLoader: ClientLoaderFunction | undefined;
2526
- hasLoader: boolean;
2527
- hasHydrateFallback: boolean;
2528
- }, location: Path, basename: string | undefined, isSpaMode: boolean): HydrationState;
2529
-
2530
- export { ActionFunction, ActionFunctionArgs, AppLoadContext, Await, type AwaitProps, Blocker, BlockerFunction, BrowserRouter, type BrowserRouterProps, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, DataRouteObject, Router$1 as DataRouter, DataStrategyFunction, type EntryContext, Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, FormEncType, type FormProps, GetScrollRestorationKeyFunction, HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HistoryRouterProps, HydrationState, IndexRouteObject, type IndexRouteProps, InitialEntry, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, LazyRouteFunction, Link, type LinkProps, Links, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, MetaFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, NavigateOptions, type NavigateProps, Navigation, Action as NavigationType, Navigator, NonIndexRouteObject, Outlet, type OutletProps, PageLinkDescriptor, type ParamKeyValuePair, ParamParseKey, Params$1 as Params, PatchRoutesOnNavigationFunction, Path, PathMatch, PathPattern, type PathRouteProps, PrefetchPageLinks, type Register, RelativeRoutingType, type RequestHandler, RevalidationState, Route$1 as Route, RouteMatch, RouteObject, type RouteProps, Router, RouterInit, type RouterProps, RouterProvider, type RouterProviderProps, RouterState, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, To, UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, FrameworkContext as UNSAFE_FrameworkContext, MiddlewareEnabled as UNSAFE_MiddlewareEnabled, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, mapRouteProperties as UNSAFE_mapRouteProperties, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, type URLSearchParamsInit, createBrowserRouter, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, renderMatches, HistoryRouter as unstable_HistoryRouter, unstable_InitialContext, unstable_RouterContextProvider, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };