react-router 7.6.0 → 7.6.1-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/dist/development/dom-export.d.mts +1 -2
  3. package/dist/development/dom-export.js +1 -1
  4. package/dist/development/dom-export.mjs +23 -23
  5. package/dist/development/index.d.mts +3740 -260
  6. package/dist/development/index.d.ts +1762 -12
  7. package/dist/development/index.js +16 -7
  8. package/dist/development/index.mjs +11439 -121
  9. package/dist/development/internal-export.d.mts +504 -0
  10. package/dist/development/internal-export.d.ts +504 -0
  11. package/dist/development/{lib/types/route-module.js → internal-export.js} +4 -4
  12. package/dist/development/{lib/types/route-module.mjs → internal-export.mjs} +1 -1
  13. package/dist/production/dom-export.d.mts +1 -2
  14. package/dist/production/dom-export.js +1 -1
  15. package/dist/production/dom-export.mjs +23 -23
  16. package/dist/production/index.d.mts +3740 -260
  17. package/dist/production/index.d.ts +1762 -12
  18. package/dist/production/index.js +16 -7
  19. package/dist/production/index.mjs +11439 -121
  20. package/dist/production/internal-export.d.mts +504 -0
  21. package/dist/production/internal-export.d.ts +504 -0
  22. package/dist/production/{lib/types/route-module.js → internal-export.js} +4 -4
  23. package/dist/production/{lib/types/route-module.mjs → internal-export.mjs} +1 -1
  24. package/package.json +7 -7
  25. package/dist/development/chunk-D4RADZKF.mjs +0 -11556
  26. package/dist/development/lib/types/route-module.d.mts +0 -208
  27. package/dist/development/lib/types/route-module.d.ts +0 -208
  28. package/dist/development/lib-CCSAGgcP.d.mts +0 -1736
  29. package/dist/development/route-data-B9_30zbP.d.ts +0 -1749
  30. package/dist/development/route-data-C6QaL0wu.d.mts +0 -1749
  31. package/dist/production/chunk-CVXGOGHQ.mjs +0 -11556
  32. package/dist/production/lib/types/route-module.d.mts +0 -208
  33. package/dist/production/lib/types/route-module.d.ts +0 -208
  34. package/dist/production/lib-CCSAGgcP.d.mts +0 -1736
  35. package/dist/production/route-data-B9_30zbP.d.ts +0 -1749
  36. package/dist/production/route-data-C6QaL0wu.d.mts +0 -1749
@@ -1,394 +1,3864 @@
1
- import { a as Router, b as RouteModules, D as DataStrategyFunction, T as To, c as RelativeRoutingType, L as Location, A as Action, P as ParamParseKey, d as Path, e as PathPattern, f as PathMatch, N as NavigateOptions, g as Params$1, h as RouteObject, i as Navigation, U as UIMatch, S as SerializeFrom, B as BlockerFunction, j as Blocker, k as StaticHandlerContext, l as StaticHandler, F as FutureConfig, C as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, u as unstable_InitialContext, m as IndexRouteObject, n as NonIndexRouteObject, o as LoaderFunction, p as ActionFunction, M as MetaFunction, q as LinksFunction, r as MiddlewareEnabled, s as AppLoadContext, E as Equal, t as RouterState, v as PatchRoutesOnNavigationFunction, w as DataRouteObject, x as ClientLoaderFunction } from './route-data-C6QaL0wu.mjs';
2
- export { W as ActionFunctionArgs, av as ClientActionFunction, aw as ClientActionFunctionArgs, ax as ClientLoaderFunctionArgs, ar as DataRouteMatch, X as DataStrategyFunctionArgs, Y as DataStrategyMatch, Z as DataStrategyResult, $ as ErrorResponse, z as Fetcher, a0 as FormEncType, a1 as FormMethod, aF as Future, G as GetScrollPositionFunction, y as GetScrollRestorationKeyFunction, a2 as HTMLFormMethod, ay as HeadersArgs, az as HeadersFunction, aD as HtmlLinkDescriptor, ah as IDLE_BLOCKER, ag as IDLE_FETCHER, af as IDLE_NAVIGATION, a3 as LazyRouteFunction, aE as LinkDescriptor, a4 as LoaderFunctionArgs, aA as MetaArgs, aB as MetaDescriptor, J as NavigationStates, as as Navigator, aC as PageLinkDescriptor, at as PatchRoutesOnNavigationFunctionArgs, a6 as PathParam, a7 as RedirectFunction, V as RevalidationState, au as RouteMatch, Q as RouterFetchOptions, R as RouterInit, O as RouterNavigateOptions, K as RouterSubscriber, a9 as ShouldRevalidateFunction, aa as ShouldRevalidateFunctionArgs, aL as UNSAFE_DataRouterContext, aM as UNSAFE_DataRouterStateContext, _ as UNSAFE_DataWithResponseInit, aK as UNSAFE_ErrorResponseImpl, aN as UNSAFE_FetchersContext, aO as UNSAFE_LocationContext, aP as UNSAFE_NavigationContext, aQ as UNSAFE_RouteContext, aR as UNSAFE_ViewTransitionContext, aH as UNSAFE_createBrowserHistory, aJ as UNSAFE_createRouter, aI as UNSAFE_invariant, ad as createPath, ai as data, aj as generatePath, ak as isRouteErrorResponse, al as matchPath, am as matchRoutes, ae as parsePath, an as redirect, ao as redirectDocument, ap as replace, aq as resolvePath, a5 as unstable_MiddlewareFunction, a8 as unstable_RouterContext, ac as unstable_RouterContextProvider, aG as unstable_SerializesTo, ab as unstable_createContext } from './route-data-C6QaL0wu.mjs';
3
- import { A as AssetsManifest, E as EntryContext, F as FutureConfig$1, S as ServerBuild } from './lib-CCSAGgcP.mjs';
4
- export { f as Await, a as AwaitProps, Q as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, v as FetcherFormProps, C as FetcherSubmitFunction, a6 as FetcherSubmitOptions, G as FetcherWithComponents, X as Form, w as FormProps, ah as HandleDataRequestFunction, ai as HandleDocumentRequestFunction, aj as HandleErrorFunction, T as HashRouter, H as HashRouterProps, q as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, U as Link, s as LinkProps, ad as Links, g as MemoryRouter, M as MemoryRouterOpts, b as MemoryRouterProps, ac as Meta, W as NavLink, t as NavLinkProps, u as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a7 as ParamKeyValuePair, P as PathRouteProps, af as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ae as Scripts, ag as ScriptsProps, Y as ScrollRestoration, x as ScrollRestorationProps, ak as ServerEntryModule, y as SetURLSearchParams, z as SubmitFunction, a8 as SubmitOptions, aa as SubmitTarget, an as UNSAFE_FrameworkContext, ao as UNSAFE_createClientRoutes, ap as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, al as UNSAFE_hydrationRouteProperties, am as UNSAFE_mapRouteProperties, aq as UNSAFE_shouldHydrateRouteLoader, ar as UNSAFE_useScrollRestoration, a9 as URLSearchParamsInit, J as createBrowserRouter, K as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, ab as createSearchParams, r as renderMatches, V as unstable_HistoryRouter, a4 as unstable_usePrompt, a3 as useBeforeUnload, a1 as useFetcher, a2 as useFetchers, a0 as useFormAction, Z as useLinkClickHandler, _ as useSearchParams, $ as useSubmit, a5 as useViewTransitionState } from './lib-CCSAGgcP.mjs';
5
1
  import * as React from 'react';
6
- import { ReactElement } from 'react';
2
+ import { ComponentType, ReactElement } from 'react';
7
3
  import { ParseOptions, SerializeOptions } from 'cookie';
8
4
  export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
9
5
 
6
+ /**
7
+ * Actions represent the type of change to a location value.
8
+ */
9
+ declare enum Action {
10
+ /**
11
+ * A POP indicates a change to an arbitrary index in the history stack, such
12
+ * as a back or forward navigation. It does not describe the direction of the
13
+ * navigation, only that the current index changed.
14
+ *
15
+ * Note: This is the default action for newly created history objects.
16
+ */
17
+ Pop = "POP",
18
+ /**
19
+ * A PUSH indicates a new entry being added to the history stack, such as when
20
+ * a link is clicked and a new page loads. When this happens, all subsequent
21
+ * entries in the stack are lost.
22
+ */
23
+ Push = "PUSH",
24
+ /**
25
+ * A REPLACE indicates the entry at the current index in the history stack
26
+ * being replaced by a new one.
27
+ */
28
+ Replace = "REPLACE"
29
+ }
30
+ /**
31
+ * The pathname, search, and hash values of a URL.
32
+ */
33
+ interface Path {
34
+ /**
35
+ * A URL pathname, beginning with a /.
36
+ */
37
+ pathname: string;
38
+ /**
39
+ * A URL search string, beginning with a ?.
40
+ */
41
+ search: string;
42
+ /**
43
+ * A URL fragment identifier, beginning with a #.
44
+ */
45
+ hash: string;
46
+ }
47
+ /**
48
+ * An entry in a history stack. A location contains information about the
49
+ * URL path, as well as possibly some arbitrary state and a key.
50
+ */
51
+ interface Location<State = any> extends Path {
52
+ /**
53
+ * A value of arbitrary data associated with this location.
54
+ */
55
+ state: State;
56
+ /**
57
+ * A unique string associated with this location. May be used to safely store
58
+ * and retrieve data in some other storage API, like `localStorage`.
59
+ *
60
+ * Note: This value is always "default" on the initial location.
61
+ */
62
+ key: string;
63
+ }
64
+ /**
65
+ * A change to the current location.
66
+ */
67
+ interface Update {
68
+ /**
69
+ * The action that triggered the change.
70
+ */
71
+ action: Action;
72
+ /**
73
+ * The new location.
74
+ */
75
+ location: Location;
76
+ /**
77
+ * The delta between this location and the former location in the history stack
78
+ */
79
+ delta: number | null;
80
+ }
81
+ /**
82
+ * A function that receives notifications about location changes.
83
+ */
84
+ interface Listener {
85
+ (update: Update): void;
86
+ }
87
+ /**
88
+ * Describes a location that is the destination of some navigation used in
89
+ * {@link Link}, {@link useNavigate}, etc.
90
+ */
91
+ type To = string | Partial<Path>;
92
+ /**
93
+ * A history is an interface to the navigation stack. The history serves as the
94
+ * source of truth for the current location, as well as provides a set of
95
+ * methods that may be used to change it.
96
+ *
97
+ * It is similar to the DOM's `window.history` object, but with a smaller, more
98
+ * focused API.
99
+ */
100
+ interface History {
101
+ /**
102
+ * The last action that modified the current location. This will always be
103
+ * Action.Pop when a history instance is first created. This value is mutable.
104
+ */
105
+ readonly action: Action;
106
+ /**
107
+ * The current location. This value is mutable.
108
+ */
109
+ readonly location: Location;
110
+ /**
111
+ * Returns a valid href for the given `to` value that may be used as
112
+ * the value of an <a href> attribute.
113
+ *
114
+ * @param to - The destination URL
115
+ */
116
+ createHref(to: To): string;
117
+ /**
118
+ * Returns a URL for the given `to` value
119
+ *
120
+ * @param to - The destination URL
121
+ */
122
+ createURL(to: To): URL;
123
+ /**
124
+ * Encode a location the same way window.history would do (no-op for memory
125
+ * history) so we ensure our PUSH/REPLACE navigations for data routers
126
+ * behave the same as POP
127
+ *
128
+ * @param to Unencoded path
129
+ */
130
+ encodeLocation(to: To): Path;
131
+ /**
132
+ * Pushes a new location onto the history stack, increasing its length by one.
133
+ * If there were any entries in the stack after the current one, they are
134
+ * lost.
135
+ *
136
+ * @param to - The new URL
137
+ * @param state - Data to associate with the new location
138
+ */
139
+ push(to: To, state?: any): void;
140
+ /**
141
+ * Replaces the current location in the history stack with a new one. The
142
+ * location that was replaced will no longer be available.
143
+ *
144
+ * @param to - The new URL
145
+ * @param state - Data to associate with the new location
146
+ */
147
+ replace(to: To, state?: any): void;
148
+ /**
149
+ * Navigates `n` entries backward/forward in the history stack relative to the
150
+ * current index. For example, a "back" navigation would use go(-1).
151
+ *
152
+ * @param delta - The delta in the stack index
153
+ */
154
+ go(delta: number): void;
155
+ /**
156
+ * Sets up a listener that will be called whenever the current location
157
+ * changes.
158
+ *
159
+ * @param listener - A function that will be called when the location changes
160
+ * @returns unlisten - A function that may be used to stop listening
161
+ */
162
+ listen(listener: Listener): () => void;
163
+ }
164
+ /**
165
+ * A user-supplied object that describes a location. Used when providing
166
+ * entries to `createMemoryHistory` via its `initialEntries` option.
167
+ */
168
+ type InitialEntry = string | Partial<Location>;
169
+ /**
170
+ * A browser history stores the current location in regular URLs in a web
171
+ * browser environment. This is the standard for most web apps and provides the
172
+ * cleanest URLs the browser's address bar.
173
+ *
174
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
175
+ */
176
+ interface BrowserHistory extends UrlHistory {
177
+ }
178
+ type BrowserHistoryOptions = UrlHistoryOptions;
179
+ /**
180
+ * Browser history stores the location in regular URLs. This is the standard for
181
+ * most web apps, but it requires some configuration on the server to ensure you
182
+ * serve the same app at multiple URLs.
183
+ *
184
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
185
+ */
186
+ declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
187
+ /**
188
+ * @private
189
+ */
190
+ declare function invariant(value: boolean, message?: string): asserts value;
191
+ declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
192
+ /**
193
+ * Creates a string URL path from the given pathname, search, and hash components.
194
+ *
195
+ * @category Utils
196
+ */
197
+ declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
198
+ /**
199
+ * Parses a string URL path into its separate pathname, search, and hash components.
200
+ *
201
+ * @category Utils
202
+ */
203
+ declare function parsePath(path: string): Partial<Path>;
204
+ interface UrlHistory extends History {
205
+ }
206
+ type UrlHistoryOptions = {
207
+ window?: Window;
208
+ v5Compat?: boolean;
209
+ };
210
+
211
+ /**
212
+ * An augmentable interface users can modify in their app-code to opt into
213
+ * future-flag-specific types
214
+ */
215
+ interface Future {
216
+ }
217
+ type MiddlewareEnabled = Future extends {
218
+ unstable_middleware: infer T extends boolean;
219
+ } ? T : false;
220
+
221
+ type MaybePromise<T> = T | Promise<T>;
222
+ /**
223
+ * Map of routeId -> data returned from a loader/action/error
224
+ */
225
+ interface RouteData {
226
+ [routeId: string]: any;
227
+ }
228
+ type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
229
+ type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
230
+ /**
231
+ * Users can specify either lowercase or uppercase form methods on `<Form>`,
232
+ * useSubmit(), `<fetcher.Form>`, etc.
233
+ */
234
+ type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
235
+ /**
236
+ * Active navigation/fetcher form methods are exposed in uppercase on the
237
+ * RouterState. This is to align with the normalization done via fetch().
238
+ */
239
+ type FormMethod = UpperCaseFormMethod;
240
+ type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
241
+ type JsonObject$1 = {
242
+ [Key in string]: JsonValue$1;
243
+ } & {
244
+ [Key in string]?: JsonValue$1 | undefined;
245
+ };
246
+ type JsonArray$1 = JsonValue$1[] | readonly JsonValue$1[];
247
+ type JsonPrimitive$1 = string | number | boolean | null;
248
+ type JsonValue$1 = JsonPrimitive$1 | JsonObject$1 | JsonArray$1;
249
+ /**
250
+ * @private
251
+ * Internal interface to pass around for action submissions, not intended for
252
+ * external consumption
253
+ */
254
+ type Submission = {
255
+ formMethod: FormMethod;
256
+ formAction: string;
257
+ formEncType: FormEncType;
258
+ formData: FormData;
259
+ json: undefined;
260
+ text: undefined;
261
+ } | {
262
+ formMethod: FormMethod;
263
+ formAction: string;
264
+ formEncType: FormEncType;
265
+ formData: undefined;
266
+ json: JsonValue$1;
267
+ text: undefined;
268
+ } | {
269
+ formMethod: FormMethod;
270
+ formAction: string;
271
+ formEncType: FormEncType;
272
+ formData: undefined;
273
+ json: undefined;
274
+ text: string;
275
+ };
276
+ interface unstable_RouterContext<T = unknown> {
277
+ defaultValue?: T;
278
+ }
279
+ /**
280
+ * Creates a context object that may be used to store and retrieve arbitrary values.
281
+ *
282
+ * If a `defaultValue` is provided, it will be returned from `context.get()` when no value has been
283
+ * set for the context. Otherwise reading this context when no value has been set will throw an
284
+ * error.
285
+ *
286
+ * @param defaultValue The default value for the context
287
+ * @returns A context object
288
+ */
289
+ declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterContext<T>;
290
+ /**
291
+ * A Map of RouterContext objects to their initial values - used to populate a
292
+ * fresh `context` value per request/navigation/fetch
293
+ */
294
+ type unstable_InitialContext = Map<unstable_RouterContext, unknown>;
295
+ /**
296
+ * Provides methods for writing/reading values in application context in a typesafe way.
297
+ */
298
+ declare class unstable_RouterContextProvider {
299
+ #private;
300
+ constructor(init?: unstable_InitialContext);
301
+ get<T>(context: unstable_RouterContext<T>): T;
302
+ set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
303
+ }
304
+ type DefaultContext = MiddlewareEnabled extends true ? unstable_RouterContextProvider : any;
305
+ /**
306
+ * @private
307
+ * Arguments passed to route loader/action functions. Same for now but we keep
308
+ * this as a private implementation detail in case they diverge in the future.
309
+ */
310
+ interface DataFunctionArgs<Context> {
311
+ /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
312
+ request: Request;
313
+ /**
314
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
315
+ * @example
316
+ * // app/routes.ts
317
+ * route("teams/:teamId", "./team.tsx"),
318
+ *
319
+ * // app/team.tsx
320
+ * export function loader({
321
+ * params,
322
+ * }: Route.LoaderArgs) {
323
+ * params.teamId;
324
+ * // ^ string
325
+ * }
326
+ **/
327
+ params: Params;
328
+ /**
329
+ * This is the context passed in to your server adapter's getLoadContext() function.
330
+ * It's a way to bridge the gap between the adapter's request/response API with your React Router app.
331
+ * It is only applicable if you are using a custom server adapter.
332
+ */
333
+ context: Context;
334
+ }
335
+ /**
336
+ * Route middleware `next` function to call downstream handlers and then complete
337
+ * middlewares from the bottom-up
338
+ */
339
+ interface unstable_MiddlewareNextFunction<Result = unknown> {
340
+ (): MaybePromise<Result>;
341
+ }
342
+ /**
343
+ * Route middleware function signature. Receives the same "data" arguments as a
344
+ * `loader`/`action` (`request`, `params`, `context`) as the first parameter and
345
+ * a `next` function as the second parameter which will call downstream handlers
346
+ * and then complete middlewares from the bottom-up
347
+ */
348
+ type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
349
+ /**
350
+ * Arguments passed to loader functions
351
+ */
352
+ interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
353
+ }
354
+ /**
355
+ * Arguments passed to action functions
356
+ */
357
+ interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
358
+ }
359
+ /**
360
+ * Loaders and actions can return anything
361
+ */
362
+ type DataFunctionValue = unknown;
363
+ type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
364
+ /**
365
+ * Route loader function signature
366
+ */
367
+ type LoaderFunction<Context = DefaultContext> = {
368
+ (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
369
+ } & {
370
+ hydrate?: boolean;
371
+ };
372
+ /**
373
+ * Route action function signature
374
+ */
375
+ interface ActionFunction<Context = DefaultContext> {
376
+ (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
377
+ }
378
+ /**
379
+ * Arguments passed to shouldRevalidate function
380
+ */
381
+ interface ShouldRevalidateFunctionArgs {
382
+ /** This is the url the navigation started from. You can compare it with `nextUrl` to decide if you need to revalidate this route's data. */
383
+ currentUrl: URL;
384
+ /** These are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the URL that can be compared to the `nextParams` to decide if you need to reload or not. Perhaps you're using only a partial piece of the param for data loading, you don't need to revalidate if a superfluous part of the param changed. */
385
+ currentParams: AgnosticDataRouteMatch["params"];
386
+ /** In the case of navigation, this the URL the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentUrl. */
387
+ nextUrl: URL;
388
+ /** In the case of navigation, these are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the next location the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentParams. */
389
+ nextParams: AgnosticDataRouteMatch["params"];
390
+ /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
391
+ formMethod?: Submission["formMethod"];
392
+ /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
393
+ formAction?: Submission["formAction"];
394
+ /** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
395
+ formEncType?: Submission["formEncType"];
396
+ /** The form submission data when the form's encType is `text/plain` */
397
+ text?: Submission["text"];
398
+ /** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
399
+ formData?: Submission["formData"];
400
+ /** The form submission data when the form's encType is `application/json` */
401
+ json?: Submission["json"];
402
+ /** The status code of the action response */
403
+ actionStatus?: number;
404
+ /**
405
+ * When a submission causes the revalidation this will be the result of the action—either action data or an error if the action failed. It's common to include some information in the action result to instruct shouldRevalidate to revalidate or not.
406
+ *
407
+ * @example
408
+ * export async function action() {
409
+ * await saveSomeStuff();
410
+ * return { ok: true };
411
+ * }
412
+ *
413
+ * export function shouldRevalidate({
414
+ * actionResult,
415
+ * }) {
416
+ * if (actionResult?.ok) {
417
+ * return false;
418
+ * }
419
+ * return true;
420
+ * }
421
+ */
422
+ actionResult?: any;
423
+ /**
424
+ * By default, React Router doesn't call every loader all the time. There are reliable optimizations it can make by default. For example, only loaders with changing params are called. Consider navigating from the following URL to the one below it:
425
+ *
426
+ * /projects/123/tasks/abc
427
+ * /projects/123/tasks/def
428
+ * React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
429
+ *
430
+ * It's safest to always return defaultShouldRevalidate after you've done your specific optimizations that return false, otherwise your UI might get out of sync with your data on the server.
431
+ */
432
+ defaultShouldRevalidate: boolean;
433
+ }
434
+ /**
435
+ * Route shouldRevalidate function signature. This runs after any submission
436
+ * (navigation or fetcher), so we flatten the navigation/fetcher submission
437
+ * onto the arguments. It shouldn't matter whether it came from a navigation
438
+ * or a fetcher, what really matters is the URLs and the formData since loaders
439
+ * have to re-run based on the data models that were potentially mutated.
440
+ */
441
+ interface ShouldRevalidateFunction {
442
+ (args: ShouldRevalidateFunctionArgs): boolean;
443
+ }
444
+ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
445
+ /**
446
+ * @private
447
+ */
448
+ _lazyPromises?: {
449
+ middleware: Promise<void> | undefined;
450
+ handler: Promise<void> | undefined;
451
+ route: Promise<void> | undefined;
452
+ };
453
+ shouldLoad: boolean;
454
+ unstable_shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
455
+ unstable_shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
456
+ resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
457
+ }
458
+ interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
459
+ matches: DataStrategyMatch[];
460
+ unstable_runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
461
+ fetcherKey: string | null;
462
+ }
463
+ /**
464
+ * Result from a loader or action called via dataStrategy
465
+ */
466
+ interface DataStrategyResult {
467
+ type: "data" | "error";
468
+ result: unknown;
469
+ }
470
+ interface DataStrategyFunction<Context = DefaultContext> {
471
+ (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
472
+ }
473
+ type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
474
+ signal: AbortSignal;
475
+ path: string;
476
+ matches: M[];
477
+ fetcherKey: string | undefined;
478
+ patch: (routeId: string | null, children: O[]) => void;
479
+ };
480
+ type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
481
+ /**
482
+ * Function provided by the framework-aware layers to set any framework-specific
483
+ * properties from framework-agnostic properties
484
+ */
485
+ interface MapRoutePropertiesFunction {
486
+ (route: AgnosticRouteObject): {
487
+ hasErrorBoundary: boolean;
488
+ } & Record<string, any>;
489
+ }
490
+ /**
491
+ * Keys we cannot change from within a lazy object. We spread all other keys
492
+ * onto the route. Either they're meaningful to the router, or they'll get
493
+ * ignored.
494
+ */
495
+ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
496
+ /**
497
+ * Keys we cannot change from within a lazy() function. We spread all other keys
498
+ * onto the route. Either they're meaningful to the router, or they'll get
499
+ * ignored.
500
+ */
501
+ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "unstable_middleware";
502
+ /**
503
+ * lazy object to load route properties, which can add non-matching
504
+ * related properties to a route
505
+ */
506
+ type LazyRouteObject<R extends AgnosticRouteObject> = {
507
+ [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
508
+ };
509
+ /**
510
+ * lazy() function to load a route definition, which can add non-matching
511
+ * related properties to a route
512
+ */
513
+ interface LazyRouteFunction<R extends AgnosticRouteObject> {
514
+ (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
515
+ }
516
+ type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
517
+ /**
518
+ * Base RouteObject with common props shared by all types of routes
519
+ */
520
+ type AgnosticBaseRouteObject = {
521
+ caseSensitive?: boolean;
522
+ path?: string;
523
+ id?: string;
524
+ unstable_middleware?: unstable_MiddlewareFunction[];
525
+ loader?: LoaderFunction | boolean;
526
+ action?: ActionFunction | boolean;
527
+ hasErrorBoundary?: boolean;
528
+ shouldRevalidate?: ShouldRevalidateFunction;
529
+ handle?: any;
530
+ lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
531
+ };
532
+ /**
533
+ * Index routes must not have children
534
+ */
535
+ type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
536
+ children?: undefined;
537
+ index: true;
538
+ };
539
+ /**
540
+ * Non-index routes may have children, but cannot have index
541
+ */
542
+ type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
543
+ children?: AgnosticRouteObject[];
544
+ index?: false;
545
+ };
546
+ /**
547
+ * A route object represents a logical route, with (optionally) its child
548
+ * routes organized in a tree-like structure.
549
+ */
550
+ type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
551
+ type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
552
+ id: string;
553
+ };
554
+ type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
555
+ children?: AgnosticDataRouteObject[];
556
+ id: string;
557
+ };
558
+ /**
559
+ * A data route object, which is just a RouteObject with a required unique ID
560
+ */
561
+ type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
562
+ type RouteManifest<R = AgnosticDataRouteObject> = Record<string, R | undefined>;
563
+ type Regex_az = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
564
+ type Regez_AZ = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
565
+ type Regex_09 = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
566
+ type Regex_w = Regex_az | Regez_AZ | Regex_09 | "_";
567
+ type ParamChar = Regex_w | "-";
568
+ type RegexMatchPlus<CharPattern extends string, T extends string> = T extends `${infer First}${infer Rest}` ? First extends CharPattern ? RegexMatchPlus<CharPattern, Rest> extends never ? First : `${First}${RegexMatchPlus<CharPattern, Rest>}` : never : never;
569
+ type _PathParam<Path extends string> = Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> : Path extends `:${infer Param}` ? Param extends `${infer Optional}?${string}` ? RegexMatchPlus<ParamChar, Optional> : RegexMatchPlus<ParamChar, Param> : never;
570
+ type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
571
+ type ParamParseKey<Segment extends string> = [
572
+ PathParam<Segment>
573
+ ] extends [never] ? string : PathParam<Segment>;
574
+ /**
575
+ * The parameters that were parsed from the URL path.
576
+ */
577
+ type Params<Key extends string = string> = {
578
+ readonly [key in Key]: string | undefined;
579
+ };
580
+ /**
581
+ * A RouteMatch contains info about how a route matched a URL.
582
+ */
583
+ interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
584
+ /**
585
+ * The names and values of dynamic parameters in the URL.
586
+ */
587
+ params: Params<ParamKey>;
588
+ /**
589
+ * The portion of the URL pathname that was matched.
590
+ */
591
+ pathname: string;
592
+ /**
593
+ * The portion of the URL pathname that was matched before child routes.
594
+ */
595
+ pathnameBase: string;
596
+ /**
597
+ * The route object that was used to match.
598
+ */
599
+ route: RouteObjectType;
600
+ }
601
+ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
602
+ }
603
+ /**
604
+ * Matches the given routes to a location and returns the match data.
605
+ *
606
+ * @category Utils
607
+ */
608
+ declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
609
+ interface UIMatch<Data = unknown, Handle = unknown> {
610
+ id: string;
611
+ pathname: string;
612
+ /**
613
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
614
+ **/
615
+ params: AgnosticRouteMatch["params"];
616
+ /** The return value from the matched route's loader or clientLoader */
617
+ data: Data;
618
+ /** The {@link https://reactrouter.com/start/framework/route-module#handle handle object} exported from the matched route module */
619
+ handle: Handle;
620
+ }
621
+ /**
622
+ * Returns a path with params interpolated.
623
+ *
624
+ * @category Utils
625
+ */
626
+ declare function generatePath<Path extends string>(originalPath: Path, params?: {
627
+ [key in PathParam<Path>]: string | null;
628
+ }): string;
629
+ /**
630
+ * A PathPattern is used to match on some portion of a URL pathname.
631
+ */
632
+ interface PathPattern<Path extends string = string> {
633
+ /**
634
+ * A string to match against a URL pathname. May contain `:id`-style segments
635
+ * to indicate placeholders for dynamic parameters. May also end with `/*` to
636
+ * indicate matching the rest of the URL pathname.
637
+ */
638
+ path: Path;
639
+ /**
640
+ * Should be `true` if the static portions of the `path` should be matched in
641
+ * the same case.
642
+ */
643
+ caseSensitive?: boolean;
644
+ /**
645
+ * Should be `true` if this pattern should match the entire URL pathname.
646
+ */
647
+ end?: boolean;
648
+ }
649
+ /**
650
+ * A PathMatch contains info about how a PathPattern matched on a URL pathname.
651
+ */
652
+ interface PathMatch<ParamKey extends string = string> {
653
+ /**
654
+ * The names and values of dynamic parameters in the URL.
655
+ */
656
+ params: Params<ParamKey>;
657
+ /**
658
+ * The portion of the URL pathname that was matched.
659
+ */
660
+ pathname: string;
661
+ /**
662
+ * The portion of the URL pathname that was matched before child routes.
663
+ */
664
+ pathnameBase: string;
665
+ /**
666
+ * The pattern that was used to match.
667
+ */
668
+ pattern: PathPattern;
669
+ }
670
+ /**
671
+ * Performs pattern matching on a URL pathname and returns information about
672
+ * the match.
673
+ *
674
+ * @category Utils
675
+ */
676
+ declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
677
+ /**
678
+ * Returns a resolved path object relative to the given pathname.
679
+ *
680
+ * @category Utils
681
+ */
682
+ declare function resolvePath(to: To, fromPathname?: string): Path;
683
+ declare class DataWithResponseInit<D> {
684
+ type: string;
685
+ data: D;
686
+ init: ResponseInit | null;
687
+ constructor(data: D, init?: ResponseInit);
688
+ }
689
+ /**
690
+ * Create "responses" that contain `status`/`headers` without forcing
691
+ * serialization into an actual `Response` - used by Remix single fetch
692
+ *
693
+ * @category Utils
694
+ */
695
+ declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
696
+ type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
697
+ /**
698
+ * A redirect response. Sets the status code and the `Location` header.
699
+ * Defaults to "302 Found".
700
+ *
701
+ * @category Utils
702
+ */
703
+ declare const redirect: RedirectFunction;
704
+ /**
705
+ * A redirect response that will force a document reload to the new location.
706
+ * Sets the status code and the `Location` header.
707
+ * Defaults to "302 Found".
708
+ *
709
+ * @category Utils
710
+ */
711
+ declare const redirectDocument: RedirectFunction;
712
+ /**
713
+ * A redirect response that will perform a `history.replaceState` instead of a
714
+ * `history.pushState` for client-side navigation redirects.
715
+ * Sets the status code and the `Location` header.
716
+ * Defaults to "302 Found".
717
+ *
718
+ * @category Utils
719
+ */
720
+ declare const replace: RedirectFunction;
721
+ type ErrorResponse = {
722
+ status: number;
723
+ statusText: string;
724
+ data: any;
725
+ };
726
+ /**
727
+ * @private
728
+ * Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
729
+ *
730
+ * We don't export the class for public use since it's an implementation
731
+ * detail, but we export the interface above so folks can build their own
732
+ * abstractions around instances via isRouteErrorResponse()
733
+ */
734
+ declare class ErrorResponseImpl implements ErrorResponse {
735
+ status: number;
736
+ statusText: string;
737
+ data: any;
738
+ private error?;
739
+ private internal;
740
+ constructor(status: number, statusText: string | undefined, data: any, internal?: boolean);
741
+ }
742
+ /**
743
+ * Check if the given error is an ErrorResponse generated from a 4xx/5xx
744
+ * Response thrown from an action/loader
745
+ *
746
+ * @category Utils
747
+ */
748
+ declare function isRouteErrorResponse(error: any): error is ErrorResponse;
749
+
750
+ /**
751
+ * A Router instance manages all navigation and data loading/mutations
752
+ */
753
+ interface Router$1 {
754
+ /**
755
+ * @private
756
+ * PRIVATE - DO NOT USE
757
+ *
758
+ * Return the basename for the router
759
+ */
760
+ get basename(): RouterInit["basename"];
761
+ /**
762
+ * @private
763
+ * PRIVATE - DO NOT USE
764
+ *
765
+ * Return the future config for the router
766
+ */
767
+ get future(): FutureConfig$1;
768
+ /**
769
+ * @private
770
+ * PRIVATE - DO NOT USE
771
+ *
772
+ * Return the current state of the router
773
+ */
774
+ get state(): RouterState;
775
+ /**
776
+ * @private
777
+ * PRIVATE - DO NOT USE
778
+ *
779
+ * Return the routes for this router instance
780
+ */
781
+ get routes(): AgnosticDataRouteObject[];
782
+ /**
783
+ * @private
784
+ * PRIVATE - DO NOT USE
785
+ *
786
+ * Return the window associated with the router
787
+ */
788
+ get window(): RouterInit["window"];
789
+ /**
790
+ * @private
791
+ * PRIVATE - DO NOT USE
792
+ *
793
+ * Initialize the router, including adding history listeners and kicking off
794
+ * initial data fetches. Returns a function to cleanup listeners and abort
795
+ * any in-progress loads
796
+ */
797
+ initialize(): Router$1;
798
+ /**
799
+ * @private
800
+ * PRIVATE - DO NOT USE
801
+ *
802
+ * Subscribe to router.state updates
803
+ *
804
+ * @param fn function to call with the new state
805
+ */
806
+ subscribe(fn: RouterSubscriber): () => void;
807
+ /**
808
+ * @private
809
+ * PRIVATE - DO NOT USE
810
+ *
811
+ * Enable scroll restoration behavior in the router
812
+ *
813
+ * @param savedScrollPositions Object that will manage positions, in case
814
+ * it's being restored from sessionStorage
815
+ * @param getScrollPosition Function to get the active Y scroll position
816
+ * @param getKey Function to get the key to use for restoration
817
+ */
818
+ enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
819
+ /**
820
+ * @private
821
+ * PRIVATE - DO NOT USE
822
+ *
823
+ * Navigate forward/backward in the history stack
824
+ * @param to Delta to move in the history stack
825
+ */
826
+ navigate(to: number): Promise<void>;
827
+ /**
828
+ * Navigate to the given path
829
+ * @param to Path to navigate to
830
+ * @param opts Navigation options (method, submission, etc.)
831
+ */
832
+ navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
833
+ /**
834
+ * @private
835
+ * PRIVATE - DO NOT USE
836
+ *
837
+ * Trigger a fetcher load/submission
838
+ *
839
+ * @param key Fetcher key
840
+ * @param routeId Route that owns the fetcher
841
+ * @param href href to fetch
842
+ * @param opts Fetcher options, (method, submission, etc.)
843
+ */
844
+ fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
845
+ /**
846
+ * @private
847
+ * PRIVATE - DO NOT USE
848
+ *
849
+ * Trigger a revalidation of all current route loaders and fetcher loads
850
+ */
851
+ revalidate(): Promise<void>;
852
+ /**
853
+ * @private
854
+ * PRIVATE - DO NOT USE
855
+ *
856
+ * Utility function to create an href for the given location
857
+ * @param location
858
+ */
859
+ createHref(location: Location | URL): string;
860
+ /**
861
+ * @private
862
+ * PRIVATE - DO NOT USE
863
+ *
864
+ * Utility function to URL encode a destination path according to the internal
865
+ * history implementation
866
+ * @param to
867
+ */
868
+ encodeLocation(to: To): Path;
869
+ /**
870
+ * @private
871
+ * PRIVATE - DO NOT USE
872
+ *
873
+ * Get/create a fetcher for the given key
874
+ * @param key
875
+ */
876
+ getFetcher<TData = any>(key: string): Fetcher<TData>;
877
+ /**
878
+ * @private
879
+ * PRIVATE - DO NOT USE
880
+ *
881
+ * Delete the fetcher for a given key
882
+ * @param key
883
+ */
884
+ deleteFetcher(key: string): void;
885
+ /**
886
+ * @private
887
+ * PRIVATE - DO NOT USE
888
+ *
889
+ * Cleanup listeners and abort any in-progress loads
890
+ */
891
+ dispose(): void;
892
+ /**
893
+ * @private
894
+ * PRIVATE - DO NOT USE
895
+ *
896
+ * Get a navigation blocker
897
+ * @param key The identifier for the blocker
898
+ * @param fn The blocker function implementation
899
+ */
900
+ getBlocker(key: string, fn: BlockerFunction): Blocker;
901
+ /**
902
+ * @private
903
+ * PRIVATE - DO NOT USE
904
+ *
905
+ * Delete a navigation blocker
906
+ * @param key The identifier for the blocker
907
+ */
908
+ deleteBlocker(key: string): void;
909
+ /**
910
+ * @private
911
+ * PRIVATE DO NOT USE
912
+ *
913
+ * Patch additional children routes into an existing parent route
914
+ * @param routeId The parent route id or a callback function accepting `patch`
915
+ * to perform batch patching
916
+ * @param children The additional children routes
917
+ */
918
+ patchRoutes(routeId: string | null, children: AgnosticRouteObject[]): void;
919
+ /**
920
+ * @private
921
+ * PRIVATE - DO NOT USE
922
+ *
923
+ * HMR needs to pass in-flight route updates to React Router
924
+ * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
925
+ */
926
+ _internalSetRoutes(routes: AgnosticRouteObject[]): void;
927
+ /**
928
+ * @private
929
+ * PRIVATE - DO NOT USE
930
+ *
931
+ * Internal fetch AbortControllers accessed by unit tests
932
+ */
933
+ _internalFetchControllers: Map<string, AbortController>;
934
+ }
935
+ /**
936
+ * State maintained internally by the router. During a navigation, all states
937
+ * reflect the "old" location unless otherwise noted.
938
+ */
939
+ interface RouterState {
940
+ /**
941
+ * The action of the most recent navigation
942
+ */
943
+ historyAction: Action;
944
+ /**
945
+ * The current location reflected by the router
946
+ */
947
+ location: Location;
948
+ /**
949
+ * The current set of route matches
950
+ */
951
+ matches: AgnosticDataRouteMatch[];
952
+ /**
953
+ * Tracks whether we've completed our initial data load
954
+ */
955
+ initialized: boolean;
956
+ /**
957
+ * Current scroll position we should start at for a new view
958
+ * - number -> scroll position to restore to
959
+ * - false -> do not restore scroll at all (used during submissions)
960
+ * - null -> don't have a saved position, scroll to hash or top of page
961
+ */
962
+ restoreScrollPosition: number | false | null;
963
+ /**
964
+ * Indicate whether this navigation should skip resetting the scroll position
965
+ * if we are unable to restore the scroll position
966
+ */
967
+ preventScrollReset: boolean;
968
+ /**
969
+ * Tracks the state of the current navigation
970
+ */
971
+ navigation: Navigation;
972
+ /**
973
+ * Tracks any in-progress revalidations
974
+ */
975
+ revalidation: RevalidationState;
976
+ /**
977
+ * Data from the loaders for the current matches
978
+ */
979
+ loaderData: RouteData;
980
+ /**
981
+ * Data from the action for the current matches
982
+ */
983
+ actionData: RouteData | null;
984
+ /**
985
+ * Errors caught from loaders for the current matches
986
+ */
987
+ errors: RouteData | null;
988
+ /**
989
+ * Map of current fetchers
990
+ */
991
+ fetchers: Map<string, Fetcher>;
992
+ /**
993
+ * Map of current blockers
994
+ */
995
+ blockers: Map<string, Blocker>;
996
+ }
997
+ /**
998
+ * Data that can be passed into hydrate a Router from SSR
999
+ */
1000
+ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
1001
+ /**
1002
+ * Future flags to toggle new feature behavior
1003
+ */
1004
+ interface FutureConfig$1 {
1005
+ unstable_middleware: boolean;
1006
+ }
1007
+ /**
1008
+ * Initialization options for createRouter
1009
+ */
1010
+ interface RouterInit {
1011
+ routes: AgnosticRouteObject[];
1012
+ history: History;
1013
+ basename?: string;
1014
+ unstable_getContext?: () => MaybePromise<unstable_InitialContext>;
1015
+ mapRouteProperties?: MapRoutePropertiesFunction;
1016
+ future?: Partial<FutureConfig$1>;
1017
+ hydrationRouteProperties?: string[];
1018
+ hydrationData?: HydrationState;
1019
+ window?: Window;
1020
+ dataStrategy?: DataStrategyFunction;
1021
+ patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
1022
+ }
1023
+ /**
1024
+ * State returned from a server-side query() call
1025
+ */
1026
+ interface StaticHandlerContext {
1027
+ basename: Router$1["basename"];
1028
+ location: RouterState["location"];
1029
+ matches: RouterState["matches"];
1030
+ loaderData: RouterState["loaderData"];
1031
+ actionData: RouterState["actionData"];
1032
+ errors: RouterState["errors"];
1033
+ statusCode: number;
1034
+ loaderHeaders: Record<string, Headers>;
1035
+ actionHeaders: Record<string, Headers>;
1036
+ _deepestRenderedBoundaryId?: string | null;
1037
+ }
1038
+ /**
1039
+ * A StaticHandler instance manages a singular SSR navigation/fetch event
1040
+ */
1041
+ interface StaticHandler {
1042
+ dataRoutes: AgnosticDataRouteObject[];
1043
+ query(request: Request, opts?: {
1044
+ requestContext?: unknown;
1045
+ filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
1046
+ skipLoaderErrorBubbling?: boolean;
1047
+ skipRevalidation?: boolean;
1048
+ dataStrategy?: DataStrategyFunction<unknown>;
1049
+ unstable_respond?: (staticContext: StaticHandlerContext) => MaybePromise<Response>;
1050
+ }): Promise<StaticHandlerContext | Response>;
1051
+ queryRoute(request: Request, opts?: {
1052
+ routeId?: string;
1053
+ requestContext?: unknown;
1054
+ dataStrategy?: DataStrategyFunction<unknown>;
1055
+ unstable_respond?: (res: Response) => MaybePromise<Response>;
1056
+ }): Promise<any>;
1057
+ }
1058
+ type ViewTransitionOpts = {
1059
+ currentLocation: Location;
1060
+ nextLocation: Location;
1061
+ };
1062
+ /**
1063
+ * Subscriber function signature for changes to router state
1064
+ */
1065
+ interface RouterSubscriber {
1066
+ (state: RouterState, opts: {
1067
+ deletedFetchers: string[];
1068
+ viewTransitionOpts?: ViewTransitionOpts;
1069
+ flushSync: boolean;
1070
+ }): void;
1071
+ }
1072
+ /**
1073
+ * Function signature for determining the key to be used in scroll restoration
1074
+ * for a given location
1075
+ */
1076
+ interface GetScrollRestorationKeyFunction {
1077
+ (location: Location, matches: UIMatch[]): string | null;
1078
+ }
1079
+ /**
1080
+ * Function signature for determining the current scroll position
1081
+ */
1082
+ interface GetScrollPositionFunction {
1083
+ (): number;
1084
+ }
1085
+ /**
1086
+ - "route": relative to the route hierarchy so `..` means remove all segments of the current route even if it has many. For example, a `route("posts/:id")` would have both `:id` and `posts` removed from the url.
1087
+ - "path": relative to the pathname so `..` means remove one segment of the pathname. For example, a `route("posts/:id")` would have only `:id` removed from the url.
1088
+ */
1089
+ type RelativeRoutingType = "route" | "path";
1090
+ type BaseNavigateOrFetchOptions = {
1091
+ preventScrollReset?: boolean;
1092
+ relative?: RelativeRoutingType;
1093
+ flushSync?: boolean;
1094
+ };
1095
+ type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
1096
+ replace?: boolean;
1097
+ state?: any;
1098
+ fromRouteId?: string;
1099
+ viewTransition?: boolean;
1100
+ };
1101
+ type BaseSubmissionOptions = {
1102
+ formMethod?: HTMLFormMethod;
1103
+ formEncType?: FormEncType;
1104
+ } & ({
1105
+ formData: FormData;
1106
+ body?: undefined;
1107
+ } | {
1108
+ formData?: undefined;
1109
+ body: any;
1110
+ });
1111
+ /**
1112
+ * Options for a navigate() call for a normal (non-submission) navigation
1113
+ */
1114
+ type LinkNavigateOptions = BaseNavigateOptions;
1115
+ /**
1116
+ * Options for a navigate() call for a submission navigation
1117
+ */
1118
+ type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
1119
+ /**
1120
+ * Options to pass to navigate() for a navigation
1121
+ */
1122
+ type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
1123
+ /**
1124
+ * Options for a fetch() load
1125
+ */
1126
+ type LoadFetchOptions = BaseNavigateOrFetchOptions;
1127
+ /**
1128
+ * Options for a fetch() submission
1129
+ */
1130
+ type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
1131
+ /**
1132
+ * Options to pass to fetch()
1133
+ */
1134
+ type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
1135
+ /**
1136
+ * Potential states for state.navigation
1137
+ */
1138
+ type NavigationStates = {
1139
+ Idle: {
1140
+ state: "idle";
1141
+ location: undefined;
1142
+ formMethod: undefined;
1143
+ formAction: undefined;
1144
+ formEncType: undefined;
1145
+ formData: undefined;
1146
+ json: undefined;
1147
+ text: undefined;
1148
+ };
1149
+ Loading: {
1150
+ state: "loading";
1151
+ location: Location;
1152
+ formMethod: Submission["formMethod"] | undefined;
1153
+ formAction: Submission["formAction"] | undefined;
1154
+ formEncType: Submission["formEncType"] | undefined;
1155
+ formData: Submission["formData"] | undefined;
1156
+ json: Submission["json"] | undefined;
1157
+ text: Submission["text"] | undefined;
1158
+ };
1159
+ Submitting: {
1160
+ state: "submitting";
1161
+ location: Location;
1162
+ formMethod: Submission["formMethod"];
1163
+ formAction: Submission["formAction"];
1164
+ formEncType: Submission["formEncType"];
1165
+ formData: Submission["formData"];
1166
+ json: Submission["json"];
1167
+ text: Submission["text"];
1168
+ };
1169
+ };
1170
+ type Navigation = NavigationStates[keyof NavigationStates];
1171
+ type RevalidationState = "idle" | "loading";
1172
+ /**
1173
+ * Potential states for fetchers
1174
+ */
1175
+ type FetcherStates<TData = any> = {
1176
+ /**
1177
+ * The fetcher is not calling a loader or action
1178
+ *
1179
+ * ```tsx
1180
+ * fetcher.state === "idle"
1181
+ * ```
1182
+ */
1183
+ Idle: {
1184
+ state: "idle";
1185
+ formMethod: undefined;
1186
+ formAction: undefined;
1187
+ formEncType: undefined;
1188
+ text: undefined;
1189
+ formData: undefined;
1190
+ json: undefined;
1191
+ /**
1192
+ * If the fetcher has never been called, this will be undefined.
1193
+ */
1194
+ data: TData | undefined;
1195
+ };
1196
+ /**
1197
+ * The fetcher is loading data from a {@link LoaderFunction | loader} from a
1198
+ * call to {@link FetcherWithComponents.load | `fetcher.load`}.
1199
+ *
1200
+ * ```tsx
1201
+ * // somewhere
1202
+ * <button onClick={() => fetcher.load("/some/route") }>Load</button>
1203
+ *
1204
+ * // the state will update
1205
+ * fetcher.state === "loading"
1206
+ * ```
1207
+ */
1208
+ Loading: {
1209
+ state: "loading";
1210
+ formMethod: Submission["formMethod"] | undefined;
1211
+ formAction: Submission["formAction"] | undefined;
1212
+ formEncType: Submission["formEncType"] | undefined;
1213
+ text: Submission["text"] | undefined;
1214
+ formData: Submission["formData"] | undefined;
1215
+ json: Submission["json"] | undefined;
1216
+ data: TData | undefined;
1217
+ };
1218
+ /**
1219
+ The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
1220
+
1221
+ ```tsx
1222
+ // somewhere
1223
+ <input
1224
+ onChange={e => {
1225
+ fetcher.submit(event.currentTarget.form, { method: "post" });
1226
+ }}
1227
+ />
1228
+
1229
+ // the state will update
1230
+ fetcher.state === "submitting"
1231
+
1232
+ // and formData will be available
1233
+ fetcher.formData
1234
+ ```
1235
+ */
1236
+ Submitting: {
1237
+ state: "submitting";
1238
+ formMethod: Submission["formMethod"];
1239
+ formAction: Submission["formAction"];
1240
+ formEncType: Submission["formEncType"];
1241
+ text: Submission["text"];
1242
+ formData: Submission["formData"];
1243
+ json: Submission["json"];
1244
+ data: TData | undefined;
1245
+ };
1246
+ };
1247
+ type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
1248
+ interface BlockerBlocked {
1249
+ state: "blocked";
1250
+ reset(): void;
1251
+ proceed(): void;
1252
+ location: Location;
1253
+ }
1254
+ interface BlockerUnblocked {
1255
+ state: "unblocked";
1256
+ reset: undefined;
1257
+ proceed: undefined;
1258
+ location: undefined;
1259
+ }
1260
+ interface BlockerProceeding {
1261
+ state: "proceeding";
1262
+ reset: undefined;
1263
+ proceed: undefined;
1264
+ location: Location;
1265
+ }
1266
+ type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1267
+ type BlockerFunction = (args: {
1268
+ currentLocation: Location;
1269
+ nextLocation: Location;
1270
+ historyAction: Action;
1271
+ }) => boolean;
1272
+ declare const IDLE_NAVIGATION: NavigationStates["Idle"];
1273
+ declare const IDLE_FETCHER: FetcherStates["Idle"];
1274
+ declare const IDLE_BLOCKER: BlockerUnblocked;
1275
+ /**
1276
+ * Create a router and listen to history POP navigations
1277
+ */
1278
+ declare function createRouter(init: RouterInit): Router$1;
1279
+ interface CreateStaticHandlerOptions$1 {
1280
+ basename?: string;
1281
+ mapRouteProperties?: MapRoutePropertiesFunction;
1282
+ future?: {};
1283
+ }
1284
+
1285
+ interface IndexRouteObject {
1286
+ caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
1287
+ path?: AgnosticIndexRouteObject["path"];
1288
+ id?: AgnosticIndexRouteObject["id"];
1289
+ unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
1290
+ loader?: AgnosticIndexRouteObject["loader"];
1291
+ action?: AgnosticIndexRouteObject["action"];
1292
+ hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
1293
+ shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
1294
+ handle?: AgnosticIndexRouteObject["handle"];
1295
+ index: true;
1296
+ children?: undefined;
1297
+ element?: React.ReactNode | null;
1298
+ hydrateFallbackElement?: React.ReactNode | null;
1299
+ errorElement?: React.ReactNode | null;
1300
+ Component?: React.ComponentType | null;
1301
+ HydrateFallback?: React.ComponentType | null;
1302
+ ErrorBoundary?: React.ComponentType | null;
1303
+ lazy?: LazyRouteDefinition<RouteObject>;
1304
+ }
1305
+ interface NonIndexRouteObject {
1306
+ caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
1307
+ path?: AgnosticNonIndexRouteObject["path"];
1308
+ id?: AgnosticNonIndexRouteObject["id"];
1309
+ unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
1310
+ loader?: AgnosticNonIndexRouteObject["loader"];
1311
+ action?: AgnosticNonIndexRouteObject["action"];
1312
+ hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
1313
+ shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
1314
+ handle?: AgnosticNonIndexRouteObject["handle"];
1315
+ index?: false;
1316
+ children?: RouteObject[];
1317
+ element?: React.ReactNode | null;
1318
+ hydrateFallbackElement?: React.ReactNode | null;
1319
+ errorElement?: React.ReactNode | null;
1320
+ Component?: React.ComponentType | null;
1321
+ HydrateFallback?: React.ComponentType | null;
1322
+ ErrorBoundary?: React.ComponentType | null;
1323
+ lazy?: LazyRouteDefinition<RouteObject>;
1324
+ }
1325
+ type RouteObject = IndexRouteObject | NonIndexRouteObject;
1326
+ type DataRouteObject = RouteObject & {
1327
+ children?: DataRouteObject[];
1328
+ id: string;
1329
+ };
1330
+ interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
1331
+ }
1332
+ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
1333
+ }
1334
+ type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
1335
+ type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
1336
+ interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
1337
+ router: Router$1;
1338
+ staticContext?: StaticHandlerContext;
1339
+ }
1340
+ declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
1341
+ declare const DataRouterStateContext: React.Context<RouterState | null>;
1342
+ type ViewTransitionContextObject = {
1343
+ isTransitioning: false;
1344
+ } | {
1345
+ isTransitioning: true;
1346
+ flushSync: boolean;
1347
+ currentLocation: Location;
1348
+ nextLocation: Location;
1349
+ };
1350
+ declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
1351
+ type FetchersContextObject = Map<string, any>;
1352
+ declare const FetchersContext: React.Context<FetchersContextObject>;
1353
+ interface NavigateOptions {
1354
+ /** Replace the current entry in the history stack instead of pushing a new one */
1355
+ replace?: boolean;
1356
+ /** Adds persistent client side routing state to the next location */
1357
+ state?: any;
1358
+ /** If you are using {@link https://api.reactrouter.com/v7/functions/react_router.ScrollRestoration.html <ScrollRestoration>}, prevent the scroll position from being reset to the top of the window when navigating */
1359
+ preventScrollReset?: boolean;
1360
+ /** Defines the relative path behavior for the link. "route" will use the route hierarchy so ".." will remove all URL segments of the current route pattern while "path" will use the URL path so ".." will remove one URL segment. */
1361
+ relative?: RelativeRoutingType;
1362
+ /** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
1363
+ flushSync?: boolean;
1364
+ /** Enables a {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API View Transition} for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the {@link https://api.reactrouter.com/v7/functions/react_router.useViewTransitionState.html useViewTransitionState()} hook. */
1365
+ viewTransition?: boolean;
1366
+ }
1367
+ /**
1368
+ * A Navigator is a "location changer"; it's how you get to different locations.
1369
+ *
1370
+ * Every history instance conforms to the Navigator interface, but the
1371
+ * distinction is useful primarily when it comes to the low-level `<Router>` API
1372
+ * where both the location and a navigator must be provided separately in order
1373
+ * to avoid "tearing" that may occur in a suspense-enabled app if the action
1374
+ * and/or location were to be read directly from the history instance.
1375
+ */
1376
+ interface Navigator {
1377
+ createHref: History["createHref"];
1378
+ encodeLocation?: History["encodeLocation"];
1379
+ go: History["go"];
1380
+ push(to: To, state?: any, opts?: NavigateOptions): void;
1381
+ replace(to: To, state?: any, opts?: NavigateOptions): void;
1382
+ }
1383
+ interface NavigationContextObject {
1384
+ basename: string;
1385
+ navigator: Navigator;
1386
+ static: boolean;
1387
+ future: {};
1388
+ }
1389
+ declare const NavigationContext: React.Context<NavigationContextObject>;
1390
+ interface LocationContextObject {
1391
+ location: Location;
1392
+ navigationType: Action;
1393
+ }
1394
+ declare const LocationContext: React.Context<LocationContextObject>;
1395
+ interface RouteContextObject {
1396
+ outlet: React.ReactElement | null;
1397
+ matches: RouteMatch[];
1398
+ isDataRoute: boolean;
1399
+ }
1400
+ declare const RouteContext: React.Context<RouteContextObject>;
1401
+
1402
+ /**
1403
+ * @private
1404
+ */
1405
+ declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
1406
+ hasErrorBoundary: boolean;
1407
+ };
1408
+ declare const hydrationRouteProperties: (keyof RouteObject)[];
1409
+ interface MemoryRouterOpts {
1410
+ /**
1411
+ * Basename path for the application.
1412
+ */
1413
+ basename?: string;
1414
+ /**
1415
+ * Function to provide the initial context values for all client side navigations/fetches
1416
+ */
1417
+ unstable_getContext?: RouterInit["unstable_getContext"];
1418
+ /**
1419
+ * Future flags to enable for the router.
1420
+ */
1421
+ future?: Partial<FutureConfig$1>;
1422
+ /**
1423
+ * Hydration data to initialize the router with if you have already performed
1424
+ * data loading on the server.
1425
+ */
1426
+ hydrationData?: HydrationState;
1427
+ /**
1428
+ * Initial entires in the in-memory history stack
1429
+ */
1430
+ initialEntries?: InitialEntry[];
1431
+ /**
1432
+ * Index of `initialEntries` the application should initialize to
1433
+ */
1434
+ initialIndex?: number;
1435
+ /**
1436
+ * Override the default data strategy of loading in parallel.
1437
+ * Only intended for advanced usage.
1438
+ */
1439
+ dataStrategy?: DataStrategyFunction;
1440
+ /**
1441
+ * Lazily define portions of the route tree on navigations.
1442
+ */
1443
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
1444
+ }
1445
+ /**
1446
+ * Create a new data router that manages the application path using an in-memory
1447
+ * history stack. Useful for non-browser environments without a DOM API.
1448
+ *
1449
+ * @category Data Routers
1450
+ */
1451
+ declare function createMemoryRouter(
1452
+ /**
1453
+ * Application routes
1454
+ */
1455
+ routes: RouteObject[],
1456
+ /**
1457
+ * Router options
1458
+ */
1459
+ opts?: MemoryRouterOpts): Router$1;
1460
+ interface RouterProviderProps {
1461
+ router: Router$1;
1462
+ flushSync?: (fn: () => unknown) => undefined;
1463
+ }
1464
+ /**
1465
+ * Given a Remix Router instance, render the appropriate UI
1466
+ */
1467
+ declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
1468
+ /**
1469
+ * @category Types
1470
+ */
1471
+ interface MemoryRouterProps {
1472
+ basename?: string;
1473
+ children?: React.ReactNode;
1474
+ initialEntries?: InitialEntry[];
1475
+ initialIndex?: number;
1476
+ }
1477
+ /**
1478
+ * A `<Router>` that stores all entries in memory.
1479
+ *
1480
+ * @category Component Routers
1481
+ */
1482
+ declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
1483
+ /**
1484
+ * @category Types
1485
+ */
1486
+ interface NavigateProps {
1487
+ to: To;
1488
+ replace?: boolean;
1489
+ state?: any;
1490
+ relative?: RelativeRoutingType;
1491
+ }
1492
+ /**
1493
+ * A component-based version of {@link useNavigate} to use in a [`React.Component
1494
+ * Class`](https://reactjs.org/docs/react-component.html) where hooks are not
1495
+ * able to be used.
1496
+ *
1497
+ * It's recommended to avoid using this component in favor of {@link useNavigate}
1498
+ *
1499
+ * @category Components
1500
+ */
1501
+ declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
1502
+ /**
1503
+ * @category Types
1504
+ */
1505
+ interface OutletProps {
1506
+ /**
1507
+ Provides a context value to the element tree below the outlet. Use when the parent route needs to provide values to child routes.
1508
+
1509
+ ```tsx
1510
+ <Outlet context={myContextValue} />
1511
+ ```
1512
+
1513
+ Access the context with {@link useOutletContext}.
1514
+ */
1515
+ context?: unknown;
1516
+ }
1517
+ /**
1518
+ Renders the matching child route of a parent route or nothing if no child route matches.
1519
+
1520
+ ```tsx
1521
+ import { Outlet } from "react-router"
1522
+
1523
+ export default function SomeParent() {
1524
+ return (
1525
+ <div>
1526
+ <h1>Parent Content</h1>
1527
+ <Outlet />
1528
+ </div>
1529
+ );
1530
+ }
1531
+ ```
1532
+
1533
+ @category Components
1534
+ */
1535
+ declare function Outlet(props: OutletProps): React.ReactElement | null;
1536
+ /**
1537
+ * @category Types
1538
+ */
1539
+ interface PathRouteProps {
1540
+ caseSensitive?: NonIndexRouteObject["caseSensitive"];
1541
+ path?: NonIndexRouteObject["path"];
1542
+ id?: NonIndexRouteObject["id"];
1543
+ lazy?: LazyRouteFunction<NonIndexRouteObject>;
1544
+ loader?: NonIndexRouteObject["loader"];
1545
+ action?: NonIndexRouteObject["action"];
1546
+ hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
1547
+ shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
1548
+ handle?: NonIndexRouteObject["handle"];
1549
+ index?: false;
1550
+ children?: React.ReactNode;
1551
+ element?: React.ReactNode | null;
1552
+ hydrateFallbackElement?: React.ReactNode | null;
1553
+ errorElement?: React.ReactNode | null;
1554
+ Component?: React.ComponentType | null;
1555
+ HydrateFallback?: React.ComponentType | null;
1556
+ ErrorBoundary?: React.ComponentType | null;
1557
+ }
1558
+ /**
1559
+ * @category Types
1560
+ */
1561
+ interface LayoutRouteProps extends PathRouteProps {
1562
+ }
1563
+ /**
1564
+ * @category Types
1565
+ */
1566
+ interface IndexRouteProps {
1567
+ caseSensitive?: IndexRouteObject["caseSensitive"];
1568
+ path?: IndexRouteObject["path"];
1569
+ id?: IndexRouteObject["id"];
1570
+ lazy?: LazyRouteFunction<IndexRouteObject>;
1571
+ loader?: IndexRouteObject["loader"];
1572
+ action?: IndexRouteObject["action"];
1573
+ hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
1574
+ shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
1575
+ handle?: IndexRouteObject["handle"];
1576
+ index: true;
1577
+ children?: undefined;
1578
+ element?: React.ReactNode | null;
1579
+ hydrateFallbackElement?: React.ReactNode | null;
1580
+ errorElement?: React.ReactNode | null;
1581
+ Component?: React.ComponentType | null;
1582
+ HydrateFallback?: React.ComponentType | null;
1583
+ ErrorBoundary?: React.ComponentType | null;
1584
+ }
1585
+ type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
1586
+ /**
1587
+ * Configures an element to render when a pattern matches the current location.
1588
+ * It must be rendered within a {@link Routes} element. Note that these routes
1589
+ * do not participate in data loading, actions, code splitting, or any other
1590
+ * route module features.
1591
+ *
1592
+ * @category Components
1593
+ */
1594
+ declare function Route$1(_props: RouteProps): React.ReactElement | null;
1595
+ /**
1596
+ * @category Types
1597
+ */
1598
+ interface RouterProps {
1599
+ basename?: string;
1600
+ children?: React.ReactNode;
1601
+ location: Partial<Location> | string;
1602
+ navigationType?: Action;
1603
+ navigator: Navigator;
1604
+ static?: boolean;
1605
+ }
1606
+ /**
1607
+ * Provides location context for the rest of the app.
1608
+ *
1609
+ * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
1610
+ * router that is more specific to your environment such as a `<BrowserRouter>`
1611
+ * in web browsers or a `<StaticRouter>` for server rendering.
1612
+ *
1613
+ * @category Components
1614
+ */
1615
+ declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
1616
+ /**
1617
+ * @category Types
1618
+ */
1619
+ interface RoutesProps {
1620
+ /**
1621
+ * Nested {@link Route} elements
1622
+ */
1623
+ children?: React.ReactNode;
1624
+ /**
1625
+ * The location to match against. Defaults to the current location.
1626
+ */
1627
+ location?: Partial<Location> | string;
1628
+ }
1629
+ /**
1630
+ Renders a branch of {@link Route | `<Routes>`} that best matches the current
1631
+ location. Note that these routes do not participate in data loading, actions,
1632
+ code splitting, or any other route module features.
1633
+
1634
+ ```tsx
1635
+ import { Routes, Route } from "react-router"
1636
+
1637
+ <Routes>
1638
+ <Route index element={<StepOne />} />
1639
+ <Route path="step-2" element={<StepTwo />} />
1640
+ <Route path="step-3" element={<StepThree />}>
1641
+ </Routes>
1642
+ ```
1643
+
1644
+ @category Components
1645
+ */
1646
+ declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
1647
+ interface AwaitResolveRenderFunction<Resolve = any> {
1648
+ (data: Awaited<Resolve>): React.ReactNode;
1649
+ }
1650
+ /**
1651
+ * @category Types
1652
+ */
1653
+ interface AwaitProps<Resolve> {
1654
+ /**
1655
+ When using a function, the resolved value is provided as the parameter.
1656
+
1657
+ ```tsx [2]
1658
+ <Await resolve={reviewsPromise}>
1659
+ {(resolvedReviews) => <Reviews items={resolvedReviews} />}
1660
+ </Await>
1661
+ ```
1662
+
1663
+ When using React elements, {@link useAsyncValue} will provide the
1664
+ resolved value:
1665
+
1666
+ ```tsx [2]
1667
+ <Await resolve={reviewsPromise}>
1668
+ <Reviews />
1669
+ </Await>
1670
+
1671
+ function Reviews() {
1672
+ const resolvedReviews = useAsyncValue()
1673
+ return <div>...</div>
1674
+ }
1675
+ ```
1676
+ */
1677
+ children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
1678
+ /**
1679
+ The error element renders instead of the children when the promise rejects.
1680
+
1681
+ ```tsx
1682
+ <Await
1683
+ errorElement={<div>Oops</div>}
1684
+ resolve={reviewsPromise}
1685
+ >
1686
+ <Reviews />
1687
+ </Await>
1688
+ ```
1689
+
1690
+ To provide a more contextual error, you can use the {@link useAsyncError} in a
1691
+ child component
1692
+
1693
+ ```tsx
1694
+ <Await
1695
+ errorElement={<ReviewsError />}
1696
+ resolve={reviewsPromise}
1697
+ >
1698
+ <Reviews />
1699
+ </Await>
1700
+
1701
+ function ReviewsError() {
1702
+ const error = useAsyncError()
1703
+ return <div>Error loading reviews: {error.message}</div>
1704
+ }
1705
+ ```
1706
+
1707
+ If you do not provide an errorElement, the rejected value will bubble up to
1708
+ the nearest route-level {@link NonIndexRouteObject#ErrorBoundary | ErrorBoundary} and be accessible
1709
+ via {@link useRouteError} hook.
1710
+ */
1711
+ errorElement?: React.ReactNode;
1712
+ /**
1713
+ Takes a promise returned from a {@link LoaderFunction | loader} value to be resolved and rendered.
1714
+
1715
+ ```jsx
1716
+ import { useLoaderData, Await } from "react-router"
1717
+
1718
+ export async function loader() {
1719
+ let reviews = getReviews() // not awaited
1720
+ let book = await getBook()
1721
+ return {
1722
+ book,
1723
+ reviews, // this is a promise
1724
+ }
1725
+ }
1726
+
1727
+ export default function Book() {
1728
+ const {
1729
+ book,
1730
+ reviews, // this is the same promise
1731
+ } = useLoaderData()
1732
+
1733
+ return (
1734
+ <div>
1735
+ <h1>{book.title}</h1>
1736
+ <p>{book.description}</p>
1737
+ <React.Suspense fallback={<ReviewsSkeleton />}>
1738
+ <Await
1739
+ // and is the promise we pass to Await
1740
+ resolve={reviews}
1741
+ >
1742
+ <Reviews />
1743
+ </Await>
1744
+ </React.Suspense>
1745
+ </div>
1746
+ );
1747
+ }
1748
+ ```
1749
+ */
1750
+ resolve: Resolve;
1751
+ }
1752
+ /**
1753
+ Used to render promise values with automatic error handling.
1754
+
1755
+ ```tsx
1756
+ import { Await, useLoaderData } from "react-router";
1757
+
1758
+ export function loader() {
1759
+ // not awaited
1760
+ const reviews = getReviews()
1761
+ // awaited (blocks the transition)
1762
+ const book = await fetch("/api/book").then((res) => res.json())
1763
+ return { book, reviews }
1764
+ }
1765
+
1766
+ function Book() {
1767
+ const { book, reviews } = useLoaderData();
1768
+ return (
1769
+ <div>
1770
+ <h1>{book.title}</h1>
1771
+ <p>{book.description}</p>
1772
+ <React.Suspense fallback={<ReviewsSkeleton />}>
1773
+ <Await
1774
+ resolve={reviews}
1775
+ errorElement={
1776
+ <div>Could not load reviews 😬</div>
1777
+ }
1778
+ children={(resolvedReviews) => (
1779
+ <Reviews items={resolvedReviews} />
1780
+ )}
1781
+ />
1782
+ </React.Suspense>
1783
+ </div>
1784
+ );
1785
+ }
1786
+ ```
1787
+
1788
+ **Note:** `<Await>` expects to be rendered inside of a `<React.Suspense>`
1789
+
1790
+ @category Components
1791
+
1792
+ */
1793
+ declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
1794
+ /**
1795
+ * Creates a route config from a React "children" object, which is usually
1796
+ * either a `<Route>` element or an array of them. Used internally by
1797
+ * `<Routes>` to create a route config from its children.
1798
+ *
1799
+ * @category Utils
1800
+ */
1801
+ declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
1802
+ /**
1803
+ * Create route objects from JSX elements instead of arrays of objects
1804
+ */
1805
+ declare let createRoutesFromElements: typeof createRoutesFromChildren;
1806
+ /**
1807
+ * Renders the result of `matchRoutes()` into a React element.
1808
+ *
1809
+ * @category Utils
1810
+ */
1811
+ declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
1812
+
1813
+ type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
1814
+ interface ServerRoute extends Route {
1815
+ children: ServerRoute[];
1816
+ module: ServerRouteModule;
1817
+ }
1818
+
1819
+ /**
1820
+ * An object of unknown type for route loaders and actions provided by the
1821
+ * server's `getLoadContext()` function. This is defined as an empty interface
1822
+ * specifically so apps can leverage declaration merging to augment this type
1823
+ * globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
1824
+ */
1825
+ interface AppLoadContext {
1826
+ [key: string]: unknown;
1827
+ }
1828
+
1829
+ type OptionalCriticalCss = CriticalCss | undefined;
1830
+ /**
1831
+ * The output of the compiler for the server build.
1832
+ */
1833
+ interface ServerBuild {
1834
+ entry: {
1835
+ module: ServerEntryModule;
1836
+ };
1837
+ routes: ServerRouteManifest;
1838
+ assets: AssetsManifest;
1839
+ basename?: string;
1840
+ publicPath: string;
1841
+ assetsBuildDirectory: string;
1842
+ future: FutureConfig;
1843
+ ssr: boolean;
1844
+ unstable_getCriticalCss?: (args: {
1845
+ pathname: string;
1846
+ }) => OptionalCriticalCss | Promise<OptionalCriticalCss>;
1847
+ /**
1848
+ * @deprecated This is now done via a custom header during prerendering
1849
+ */
1850
+ isSpaMode: boolean;
1851
+ prerender: string[];
1852
+ routeDiscovery: {
1853
+ mode: "lazy" | "initial";
1854
+ manifestPath: string;
1855
+ };
1856
+ }
1857
+ interface HandleDocumentRequestFunction {
1858
+ (request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext): Promise<Response> | Response;
1859
+ }
1860
+ interface HandleDataRequestFunction {
1861
+ (response: Response, args: LoaderFunctionArgs | ActionFunctionArgs): Promise<Response> | Response;
1862
+ }
1863
+ interface HandleErrorFunction {
1864
+ (error: unknown, args: LoaderFunctionArgs | ActionFunctionArgs): void;
1865
+ }
1866
+ /**
1867
+ * A module that serves as the entry point for a Remix app during server
1868
+ * rendering.
1869
+ */
1870
+ interface ServerEntryModule {
1871
+ default: HandleDocumentRequestFunction;
1872
+ handleDataRequest?: HandleDataRequestFunction;
1873
+ handleError?: HandleErrorFunction;
1874
+ streamTimeout?: number;
1875
+ }
1876
+
1877
+ type SerializedError = {
1878
+ message: string;
1879
+ stack?: string;
1880
+ };
1881
+ interface FrameworkContextObject {
1882
+ manifest: AssetsManifest;
1883
+ routeModules: RouteModules;
1884
+ criticalCss?: CriticalCss;
1885
+ serverHandoffString?: string;
1886
+ future: FutureConfig;
1887
+ ssr: boolean;
1888
+ isSpaMode: boolean;
1889
+ routeDiscovery: ServerBuild["routeDiscovery"];
1890
+ serializeError?(error: Error): SerializedError;
1891
+ renderMeta?: {
1892
+ didRenderScripts?: boolean;
1893
+ streamCache?: Record<number, Promise<void> & {
1894
+ result?: {
1895
+ done: boolean;
1896
+ value: string;
1897
+ };
1898
+ error?: unknown;
1899
+ }>;
1900
+ };
1901
+ }
1902
+ interface EntryContext extends FrameworkContextObject {
1903
+ staticHandlerContext: StaticHandlerContext;
1904
+ serverHandoffStream?: ReadableStream<Uint8Array>;
1905
+ }
1906
+ interface FutureConfig {
1907
+ unstable_subResourceIntegrity: boolean;
1908
+ unstable_middleware: boolean;
1909
+ }
1910
+ type CriticalCss = string | {
1911
+ rel: "stylesheet";
1912
+ href: string;
1913
+ };
1914
+ interface AssetsManifest {
1915
+ entry: {
1916
+ imports: string[];
1917
+ module: string;
1918
+ };
1919
+ routes: RouteManifest<EntryRoute>;
1920
+ url: string;
1921
+ version: string;
1922
+ hmr?: {
1923
+ timestamp?: number;
1924
+ runtime: string;
1925
+ };
1926
+ sri?: Record<string, string> | true;
1927
+ }
1928
+
1929
+ interface Route {
1930
+ index?: boolean;
1931
+ caseSensitive?: boolean;
1932
+ id: string;
1933
+ parentId?: string;
1934
+ path?: string;
1935
+ }
1936
+ interface EntryRoute extends Route {
1937
+ hasAction: boolean;
1938
+ hasLoader: boolean;
1939
+ hasClientAction: boolean;
1940
+ hasClientLoader: boolean;
1941
+ hasClientMiddleware: boolean;
1942
+ hasErrorBoundary: boolean;
1943
+ imports?: string[];
1944
+ css?: string[];
1945
+ module: string;
1946
+ clientActionModule: string | undefined;
1947
+ clientLoaderModule: string | undefined;
1948
+ clientMiddlewareModule: string | undefined;
1949
+ hydrateFallbackModule: string | undefined;
1950
+ parentId?: string;
1951
+ }
1952
+ declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, ssr: boolean, isSpaMode: boolean): DataRouteObject[];
1953
+ 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[];
1954
+ declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
1955
+
1956
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
1957
+ type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
1958
+ interface HtmlLinkProps {
1959
+ /**
1960
+ * Address of the hyperlink
1961
+ */
1962
+ href?: string;
1963
+ /**
1964
+ * How the element handles crossorigin requests
1965
+ */
1966
+ crossOrigin?: "anonymous" | "use-credentials";
1967
+ /**
1968
+ * Relationship between the document containing the hyperlink and the destination resource
1969
+ */
1970
+ rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
1971
+ /**
1972
+ * Applicable media: "screen", "print", "(max-width: 764px)"
1973
+ */
1974
+ media?: string;
1975
+ /**
1976
+ * Integrity metadata used in Subresource Integrity checks
1977
+ */
1978
+ integrity?: string;
1979
+ /**
1980
+ * Language of the linked resource
1981
+ */
1982
+ hrefLang?: string;
1983
+ /**
1984
+ * Hint for the type of the referenced resource
1985
+ */
1986
+ type?: string;
1987
+ /**
1988
+ * Referrer policy for fetches initiated by the element
1989
+ */
1990
+ referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
1991
+ /**
1992
+ * Sizes of the icons (for rel="icon")
1993
+ */
1994
+ sizes?: string;
1995
+ /**
1996
+ * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
1997
+ */
1998
+ as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
1999
+ /**
2000
+ * Color to use when customizing a site's icon (for rel="mask-icon")
2001
+ */
2002
+ color?: string;
2003
+ /**
2004
+ * Whether the link is disabled
2005
+ */
2006
+ disabled?: boolean;
2007
+ /**
2008
+ * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
2009
+ */
2010
+ title?: string;
2011
+ /**
2012
+ * Images to use in different situations, e.g., high-resolution displays,
2013
+ * small monitors, etc. (for rel="preload")
2014
+ */
2015
+ imageSrcSet?: string;
2016
+ /**
2017
+ * Image sizes for different page layouts (for rel="preload")
2018
+ */
2019
+ imageSizes?: string;
2020
+ }
2021
+ interface HtmlLinkPreloadImage extends HtmlLinkProps {
2022
+ /**
2023
+ * Relationship between the document containing the hyperlink and the destination resource
2024
+ */
2025
+ rel: "preload";
2026
+ /**
2027
+ * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
2028
+ */
2029
+ as: "image";
2030
+ /**
2031
+ * Address of the hyperlink
2032
+ */
2033
+ href?: string;
2034
+ /**
2035
+ * Images to use in different situations, e.g., high-resolution displays,
2036
+ * small monitors, etc. (for rel="preload")
2037
+ */
2038
+ imageSrcSet: string;
2039
+ /**
2040
+ * Image sizes for different page layouts (for rel="preload")
2041
+ */
2042
+ imageSizes?: string;
2043
+ }
2044
+ /**
2045
+ * Represents a `<link>` element.
2046
+ *
2047
+ * WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
2048
+ */
2049
+ type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
2050
+ imageSizes?: never;
2051
+ });
2052
+ interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
2053
+ /**
2054
+ * The absolute path of the page to prefetch.
2055
+ */
2056
+ page: string;
2057
+ }
2058
+ type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
2059
+
2060
+ interface RouteModules {
2061
+ [routeId: string]: RouteModule | undefined;
2062
+ }
2063
+ /**
2064
+ * The shape of a route module shipped to the client
2065
+ */
2066
+ interface RouteModule {
2067
+ clientAction?: ClientActionFunction;
2068
+ clientLoader?: ClientLoaderFunction;
2069
+ unstable_clientMiddleware?: unstable_MiddlewareFunction<undefined>[];
2070
+ ErrorBoundary?: ErrorBoundaryComponent;
2071
+ HydrateFallback?: HydrateFallbackComponent;
2072
+ Layout?: LayoutComponent;
2073
+ default: RouteComponent;
2074
+ handle?: RouteHandle;
2075
+ links?: LinksFunction;
2076
+ meta?: MetaFunction;
2077
+ shouldRevalidate?: ShouldRevalidateFunction;
2078
+ }
2079
+ /**
2080
+ * The shape of a route module on the server
2081
+ */
2082
+ interface ServerRouteModule extends RouteModule {
2083
+ action?: ActionFunction;
2084
+ headers?: HeadersFunction | {
2085
+ [name: string]: string;
2086
+ };
2087
+ loader?: LoaderFunction;
2088
+ unstable_middleware?: unstable_MiddlewareFunction<Response>[];
2089
+ }
2090
+ /**
2091
+ * A function that handles data mutations for a route on the client
2092
+ */
2093
+ type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<ActionFunction>;
2094
+ /**
2095
+ * Arguments passed to a route `clientAction` function
2096
+ */
2097
+ type ClientActionFunctionArgs = ActionFunctionArgs & {
2098
+ serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
2099
+ };
2100
+ /**
2101
+ * A function that loads data for a route on the client
2102
+ */
2103
+ type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
2104
+ hydrate?: boolean;
2105
+ };
2106
+ /**
2107
+ * Arguments passed to a route `clientLoader` function
2108
+ */
2109
+ type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
2110
+ serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
2111
+ };
2112
+ /**
2113
+ * ErrorBoundary to display for this route
2114
+ */
2115
+ type ErrorBoundaryComponent = ComponentType;
2116
+ type HeadersArgs = {
2117
+ loaderHeaders: Headers;
2118
+ parentHeaders: Headers;
2119
+ actionHeaders: Headers;
2120
+ errorHeaders: Headers | undefined;
2121
+ };
2122
+ /**
2123
+ * A function that returns HTTP headers to be used for a route. These headers
2124
+ * will be merged with (and take precedence over) headers from parent routes.
2125
+ */
2126
+ interface HeadersFunction {
2127
+ (args: HeadersArgs): Headers | HeadersInit;
2128
+ }
2129
+ /**
2130
+ * `<Route HydrateFallback>` component to render on initial loads
2131
+ * when client loaders are present
2132
+ */
2133
+ type HydrateFallbackComponent = ComponentType;
2134
+ /**
2135
+ * Optional, root-only `<Route Layout>` component to wrap the root content in.
2136
+ * Useful for defining the <html>/<head>/<body> document shell shared by the
2137
+ * Component, HydrateFallback, and ErrorBoundary
2138
+ */
2139
+ type LayoutComponent = ComponentType<{
2140
+ children: ReactElement<unknown, ErrorBoundaryComponent | HydrateFallbackComponent | RouteComponent>;
2141
+ }>;
2142
+ /**
2143
+ * A function that defines `<link>` tags to be inserted into the `<head>` of
2144
+ * the document on route transitions.
2145
+ *
2146
+ * @see https://remix.run/route/meta
2147
+ */
2148
+ interface LinksFunction {
2149
+ (): LinkDescriptor[];
2150
+ }
2151
+ interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
2152
+ id: RouteId;
2153
+ pathname: DataRouteMatch["pathname"];
2154
+ data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
2155
+ handle?: RouteHandle;
2156
+ params: DataRouteMatch["params"];
2157
+ meta: MetaDescriptor[];
2158
+ error?: unknown;
2159
+ }
2160
+ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
2161
+ [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
2162
+ }[keyof MatchLoaders]>;
2163
+ interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2164
+ data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
2165
+ params: Params;
2166
+ location: Location;
2167
+ matches: MetaMatches<MatchLoaders>;
2168
+ error?: unknown;
2169
+ }
2170
+ /**
2171
+ * A function that returns an array of data objects to use for rendering
2172
+ * metadata HTML tags in a route. These tags are not rendered on descendant
2173
+ * routes in the route hierarchy. In other words, they will only be rendered on
2174
+ * the route in which they are exported.
2175
+ *
2176
+ * @param Loader - The type of the current route's loader function
2177
+ * @param MatchLoaders - Mapping from a parent route's filepath to its loader
2178
+ * function type
2179
+ *
2180
+ * Note that parent route filepaths are relative to the `app/` directory.
2181
+ *
2182
+ * For example, if this meta function is for `/sales/customers/$customerId`:
2183
+ *
2184
+ * ```ts
2185
+ * // app/root.tsx
2186
+ * const loader = () => ({ hello: "world" })
2187
+ * export type Loader = typeof loader
2188
+ *
2189
+ * // app/routes/sales.tsx
2190
+ * const loader = () => ({ salesCount: 1074 })
2191
+ * export type Loader = typeof loader
2192
+ *
2193
+ * // app/routes/sales/customers.tsx
2194
+ * const loader = () => ({ customerCount: 74 })
2195
+ * export type Loader = typeof loader
2196
+ *
2197
+ * // app/routes/sales/customers/$customersId.tsx
2198
+ * import type { Loader as RootLoader } from "../../../root"
2199
+ * import type { Loader as SalesLoader } from "../../sales"
2200
+ * import type { Loader as CustomersLoader } from "../../sales/customers"
2201
+ *
2202
+ * const loader = () => ({ name: "Customer name" })
2203
+ *
2204
+ * const meta: MetaFunction<typeof loader, {
2205
+ * "root": RootLoader,
2206
+ * "routes/sales": SalesLoader,
2207
+ * "routes/sales/customers": CustomersLoader,
2208
+ * }> = ({ data, matches }) => {
2209
+ * const { name } = data
2210
+ * // ^? string
2211
+ * const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").data
2212
+ * // ^? number
2213
+ * const { salesCount } = matches.find((match) => match.id === "routes/sales").data
2214
+ * // ^? number
2215
+ * const { hello } = matches.find((match) => match.id === "root").data
2216
+ * // ^? "world"
2217
+ * }
2218
+ * ```
2219
+ */
2220
+ interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2221
+ (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
2222
+ }
2223
+ type MetaDescriptor = {
2224
+ charSet: "utf-8";
2225
+ } | {
2226
+ title: string;
2227
+ } | {
2228
+ name: string;
2229
+ content: string;
2230
+ } | {
2231
+ property: string;
2232
+ content: string;
2233
+ } | {
2234
+ httpEquiv: string;
2235
+ content: string;
2236
+ } | {
2237
+ "script:ld+json": LdJsonObject;
2238
+ } | {
2239
+ tagName: "meta" | "link";
2240
+ [name: string]: string;
2241
+ } | {
2242
+ [name: string]: unknown;
2243
+ };
2244
+ type LdJsonObject = {
2245
+ [Key in string]: LdJsonValue;
2246
+ } & {
2247
+ [Key in string]?: LdJsonValue | undefined;
2248
+ };
2249
+ type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
2250
+ type LdJsonPrimitive = string | number | boolean | null;
2251
+ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
2252
+ /**
2253
+ * A React component that is rendered for a route.
2254
+ */
2255
+ type RouteComponent = ComponentType<{}>;
2256
+ /**
2257
+ * An arbitrary object that is associated with a route.
2258
+ *
2259
+ * @see https://remix.run/route/handle
2260
+ */
2261
+ type RouteHandle = unknown;
2262
+
10
2263
  declare const SingleFetchRedirectSymbol: unique symbol;
11
- declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined): DataStrategyFunction;
2264
+ declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router$1, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined): DataStrategyFunction;
12
2265
  declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
13
2266
  done: Promise<undefined>;
14
2267
  value: unknown;
15
2268
  }>;
16
2269
 
17
2270
  /**
18
- * The mode to use when running the server.
2271
+ * The mode to use when running the server.
2272
+ */
2273
+ declare enum ServerMode {
2274
+ Development = "development",
2275
+ Production = "production",
2276
+ Test = "test"
2277
+ }
2278
+
2279
+ type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
2280
+ [key: PropertyKey]: Serializable;
2281
+ } | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
2282
+
2283
+ /**
2284
+ * A brand that can be applied to a type to indicate that it will serialize
2285
+ * to a specific type when transported to the client from a loader.
2286
+ * Only use this if you have additional serialization/deserialization logic
2287
+ * in your application.
2288
+ */
2289
+ type unstable_SerializesTo<T> = {
2290
+ unstable__ReactRouter_SerializesTo: [T];
2291
+ };
2292
+
2293
+ type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
2294
+ type IsAny<T> = 0 extends 1 & T ? true : false;
2295
+ type Func = (...args: any[]) => unknown;
2296
+
2297
+ type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
2298
+ [K in keyof T]: Serialize<T[K]>;
2299
+ } : undefined;
2300
+ type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
2301
+ type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
2302
+ type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
2303
+ type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
2304
+ type ServerDataFrom<T> = ServerData<DataFrom<T>>;
2305
+ type ClientDataFrom<T> = ClientData<DataFrom<T>>;
2306
+ type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
2307
+
2308
+ /**
2309
+ Resolves a URL against the current location.
2310
+
2311
+ ```tsx
2312
+ import { useHref } from "react-router"
2313
+
2314
+ function SomeComponent() {
2315
+ let href = useHref("some/where");
2316
+ // "/resolved/some/where"
2317
+ }
2318
+ ```
2319
+
2320
+ @category Hooks
2321
+ */
2322
+ declare function useHref(to: To, { relative }?: {
2323
+ relative?: RelativeRoutingType;
2324
+ }): string;
2325
+ /**
2326
+ * Returns true if this component is a descendant of a Router, useful to ensure
2327
+ * a component is used within a Router.
2328
+ *
2329
+ * @category Hooks
2330
+ */
2331
+ declare function useInRouterContext(): boolean;
2332
+ /**
2333
+ Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
2334
+
2335
+ ```tsx
2336
+ import * as React from 'react'
2337
+ import { useLocation } from 'react-router'
2338
+
2339
+ function SomeComponent() {
2340
+ let location = useLocation()
2341
+
2342
+ React.useEffect(() => {
2343
+ // Google Analytics
2344
+ ga('send', 'pageview')
2345
+ }, [location]);
2346
+
2347
+ return (
2348
+ // ...
2349
+ );
2350
+ }
2351
+ ```
2352
+
2353
+ @category Hooks
2354
+ */
2355
+ declare function useLocation(): Location;
2356
+ /**
2357
+ * Returns the current navigation action which describes how the router came to
2358
+ * the current location, either by a pop, push, or replace on the history stack.
2359
+ *
2360
+ * @category Hooks
2361
+ */
2362
+ declare function useNavigationType(): Action;
2363
+ /**
2364
+ * Returns a PathMatch object if the given pattern matches the current URL.
2365
+ * This is useful for components that need to know "active" state, e.g.
2366
+ * `<NavLink>`.
2367
+ *
2368
+ * @category Hooks
2369
+ */
2370
+ declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
2371
+ /**
2372
+ * The interface for the navigate() function returned from useNavigate().
2373
+ */
2374
+ interface NavigateFunction {
2375
+ (to: To, options?: NavigateOptions): void | Promise<void>;
2376
+ (delta: number): void | Promise<void>;
2377
+ }
2378
+ /**
2379
+ Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
2380
+
2381
+ ```tsx
2382
+ import { useNavigate } from "react-router";
2383
+
2384
+ function SomeComponent() {
2385
+ let navigate = useNavigate();
2386
+ return (
2387
+ <button
2388
+ onClick={() => {
2389
+ navigate(-1);
2390
+ }}
2391
+ />
2392
+ );
2393
+ }
2394
+ ```
2395
+
2396
+ It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
2397
+
2398
+ @category Hooks
2399
+ */
2400
+ declare function useNavigate(): NavigateFunction;
2401
+ /**
2402
+ * Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
2403
+ *
2404
+ * @category Hooks
2405
+ */
2406
+ declare function useOutletContext<Context = unknown>(): Context;
2407
+ /**
2408
+ * Returns the element for the child route at this level of the route
2409
+ * hierarchy. Used internally by `<Outlet>` to render child routes.
2410
+ *
2411
+ * @category Hooks
2412
+ */
2413
+ declare function useOutlet(context?: unknown): React.ReactElement | null;
2414
+ /**
2415
+ 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.
2416
+
2417
+ ```tsx
2418
+ import { useParams } from "react-router"
2419
+
2420
+ function SomeComponent() {
2421
+ let params = useParams()
2422
+ params.postId
2423
+ }
2424
+ ```
2425
+
2426
+ Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
2427
+
2428
+ @category Hooks
2429
+ */
2430
+ declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
2431
+ ParamsOrKey
2432
+ ] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
2433
+ /**
2434
+ 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.
2435
+
2436
+ ```tsx
2437
+ import { useResolvedPath } from "react-router"
2438
+
2439
+ function SomeComponent() {
2440
+ // if the user is at /dashboard/profile
2441
+ let path = useResolvedPath("../accounts")
2442
+ path.pathname // "/dashboard/accounts"
2443
+ path.search // ""
2444
+ path.hash // ""
2445
+ }
2446
+ ```
2447
+
2448
+ @category Hooks
2449
+ */
2450
+ declare function useResolvedPath(to: To, { relative }?: {
2451
+ relative?: RelativeRoutingType;
2452
+ }): Path;
2453
+ /**
2454
+ Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
2455
+
2456
+ The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
2457
+
2458
+ ```tsx
2459
+ import * as React from "react";
2460
+ import { useRoutes } from "react-router";
2461
+
2462
+ function App() {
2463
+ let element = useRoutes([
2464
+ {
2465
+ path: "/",
2466
+ element: <Dashboard />,
2467
+ children: [
2468
+ {
2469
+ path: "messages",
2470
+ element: <DashboardMessages />,
2471
+ },
2472
+ { path: "tasks", element: <DashboardTasks /> },
2473
+ ],
2474
+ },
2475
+ { path: "team", element: <AboutPage /> },
2476
+ ]);
2477
+
2478
+ return element;
2479
+ }
2480
+ ```
2481
+
2482
+ @category Hooks
2483
+ */
2484
+ declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
2485
+ /**
2486
+ 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.
2487
+
2488
+ ```tsx
2489
+ import { useNavigation } from "react-router"
2490
+
2491
+ function SomeComponent() {
2492
+ let navigation = useNavigation();
2493
+ navigation.state
2494
+ navigation.formData
2495
+ // etc.
2496
+ }
2497
+ ```
2498
+
2499
+ @category Hooks
2500
+ */
2501
+ declare function useNavigation(): Navigation;
2502
+ /**
2503
+ Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
2504
+
2505
+ ```tsx
2506
+ import { useRevalidator } from "react-router";
2507
+
2508
+ function WindowFocusRevalidator() {
2509
+ const revalidator = useRevalidator();
2510
+
2511
+ useFakeWindowFocus(() => {
2512
+ revalidator.revalidate();
2513
+ });
2514
+
2515
+ return (
2516
+ <div hidden={revalidator.state === "idle"}>
2517
+ Revalidating...
2518
+ </div>
2519
+ );
2520
+ }
2521
+ ```
2522
+
2523
+ 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.
2524
+
2525
+ @category Hooks
2526
+ */
2527
+ declare function useRevalidator(): {
2528
+ revalidate: () => Promise<void>;
2529
+ state: Router$1["state"]["revalidation"];
2530
+ };
2531
+ /**
2532
+ * Returns the active route matches, useful for accessing loaderData for
2533
+ * parent/child routes or the route "handle" property
2534
+ *
2535
+ * @category Hooks
2536
+ */
2537
+ declare function useMatches(): UIMatch[];
2538
+ /**
2539
+ Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
2540
+
2541
+ ```tsx
2542
+ import { useLoaderData } from "react-router"
2543
+
2544
+ export async function loader() {
2545
+ return await fakeDb.invoices.findAll();
2546
+ }
2547
+
2548
+ export default function Invoices() {
2549
+ let invoices = useLoaderData<typeof loader>();
2550
+ // ...
2551
+ }
2552
+ ```
2553
+
2554
+ @category Hooks
2555
+ */
2556
+ declare function useLoaderData<T = any>(): SerializeFrom<T>;
2557
+ /**
2558
+ Returns the loader data for a given route by route ID.
2559
+
2560
+ ```tsx
2561
+ import { useRouteLoaderData } from "react-router";
2562
+
2563
+ function SomeComponent() {
2564
+ const { user } = useRouteLoaderData("root");
2565
+ }
2566
+ ```
2567
+
2568
+ Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
2569
+
2570
+ | Route Filename | Route ID |
2571
+ | -------------------------- | -------------------- |
2572
+ | `app/root.tsx` | `"root"` |
2573
+ | `app/routes/teams.tsx` | `"routes/teams"` |
2574
+ | `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
2575
+
2576
+ If you created an ID manually, you can use that instead:
2577
+
2578
+ ```tsx
2579
+ route("/", "containers/app.tsx", { id: "app" }})
2580
+ ```
2581
+
2582
+ @category Hooks
2583
+ */
2584
+ declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
2585
+ /**
2586
+ Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
2587
+
2588
+ ```tsx
2589
+ import { Form, useActionData } from "react-router"
2590
+
2591
+ export async function action({ request }) {
2592
+ const body = await request.formData()
2593
+ const name = body.get("visitorsName")
2594
+ return { message: `Hello, ${name}` }
2595
+ }
2596
+
2597
+ export default function Invoices() {
2598
+ const data = useActionData()
2599
+ return (
2600
+ <Form method="post">
2601
+ <input type="text" name="visitorsName" />
2602
+ {data ? data.message : "Waiting..."}
2603
+ </Form>
2604
+ )
2605
+ }
2606
+ ```
2607
+
2608
+ @category Hooks
2609
+ */
2610
+ declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
2611
+ /**
2612
+ Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
2613
+
2614
+ ```tsx
2615
+ export function ErrorBoundary() {
2616
+ const error = useRouteError();
2617
+ return <div>{error.message}</div>;
2618
+ }
2619
+ ```
2620
+
2621
+ @category Hooks
2622
+ */
2623
+ declare function useRouteError(): unknown;
2624
+ /**
2625
+ Returns the resolved promise value from the closest {@link Await | `<Await>`}.
2626
+
2627
+ ```tsx
2628
+ function SomeDescendant() {
2629
+ const value = useAsyncValue();
2630
+ // ...
2631
+ }
2632
+
2633
+ // somewhere in your app
2634
+ <Await resolve={somePromise}>
2635
+ <SomeDescendant />
2636
+ </Await>
2637
+ ```
2638
+
2639
+ @category Hooks
2640
+ */
2641
+ declare function useAsyncValue(): unknown;
2642
+ /**
2643
+ Returns the rejection value from the closest {@link Await | `<Await>`}.
2644
+
2645
+ ```tsx
2646
+ import { Await, useAsyncError } from "react-router"
2647
+
2648
+ function ErrorElement() {
2649
+ const error = useAsyncError();
2650
+ return (
2651
+ <p>Uh Oh, something went wrong! {error.message}</p>
2652
+ );
2653
+ }
2654
+
2655
+ // somewhere in your app
2656
+ <Await
2657
+ resolve={promiseThatRejects}
2658
+ errorElement={<ErrorElement />}
2659
+ />
2660
+ ```
2661
+
2662
+ @category Hooks
2663
+ */
2664
+ declare function useAsyncError(): unknown;
2665
+ /**
2666
+ * Allow the application to block navigations within the SPA and present the
2667
+ * user a confirmation dialog to confirm the navigation. Mostly used to avoid
2668
+ * using half-filled form data. This does not handle hard-reloads or
2669
+ * cross-origin navigations.
2670
+ *
2671
+ * @category Hooks
2672
+ */
2673
+ declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
2674
+
2675
+ type ParamKeyValuePair = [string, string];
2676
+ type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
2677
+ /**
2678
+ Creates a URLSearchParams object using the given initializer.
2679
+
2680
+ This is identical to `new URLSearchParams(init)` except it also
2681
+ supports arrays as values in the object form of the initializer
2682
+ instead of just strings. This is convenient when you need multiple
2683
+ values for a given key, but don't want to use an array initializer.
2684
+
2685
+ For example, instead of:
2686
+
2687
+ ```tsx
2688
+ let searchParams = new URLSearchParams([
2689
+ ['sort', 'name'],
2690
+ ['sort', 'price']
2691
+ ]);
2692
+ ```
2693
+ you can do:
2694
+
2695
+ ```
2696
+ let searchParams = createSearchParams({
2697
+ sort: ['name', 'price']
2698
+ });
2699
+ ```
2700
+
2701
+ @category Utils
2702
+ */
2703
+ declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
2704
+ type JsonObject = {
2705
+ [Key in string]: JsonValue;
2706
+ } & {
2707
+ [Key in string]?: JsonValue | undefined;
2708
+ };
2709
+ type JsonArray = JsonValue[] | readonly JsonValue[];
2710
+ type JsonPrimitive = string | number | boolean | null;
2711
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
2712
+ type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
2713
+ /**
2714
+ * Submit options shared by both navigations and fetchers
2715
+ */
2716
+ interface SharedSubmitOptions {
2717
+ /**
2718
+ * The HTTP method used to submit the form. Overrides `<form method>`.
2719
+ * Defaults to "GET".
2720
+ */
2721
+ method?: HTMLFormMethod;
2722
+ /**
2723
+ * The action URL path used to submit the form. Overrides `<form action>`.
2724
+ * Defaults to the path of the current route.
2725
+ */
2726
+ action?: string;
2727
+ /**
2728
+ * The encoding used to submit the form. Overrides `<form encType>`.
2729
+ * Defaults to "application/x-www-form-urlencoded".
2730
+ */
2731
+ encType?: FormEncType;
2732
+ /**
2733
+ * Determines whether the form action is relative to the route hierarchy or
2734
+ * the pathname. Use this if you want to opt out of navigating the route
2735
+ * hierarchy and want to instead route based on /-delimited URL segments
2736
+ */
2737
+ relative?: RelativeRoutingType;
2738
+ /**
2739
+ * In browser-based environments, prevent resetting scroll after this
2740
+ * navigation when using the <ScrollRestoration> component
2741
+ */
2742
+ preventScrollReset?: boolean;
2743
+ /**
2744
+ * Enable flushSync for this submission's state updates
2745
+ */
2746
+ flushSync?: boolean;
2747
+ }
2748
+ /**
2749
+ * Submit options available to fetchers
2750
+ */
2751
+ interface FetcherSubmitOptions extends SharedSubmitOptions {
2752
+ }
2753
+ /**
2754
+ * Submit options available to navigations
2755
+ */
2756
+ interface SubmitOptions extends FetcherSubmitOptions {
2757
+ /**
2758
+ * Set `true` to replace the current entry in the browser's history stack
2759
+ * instead of creating a new one (i.e. stay on "the same page"). Defaults
2760
+ * to `false`.
2761
+ */
2762
+ replace?: boolean;
2763
+ /**
2764
+ * State object to add to the history stack entry for this navigation
2765
+ */
2766
+ state?: any;
2767
+ /**
2768
+ * Indicate a specific fetcherKey to use when using navigate=false
2769
+ */
2770
+ fetcherKey?: string;
2771
+ /**
2772
+ * navigate=false will use a fetcher instead of a navigation
2773
+ */
2774
+ navigate?: boolean;
2775
+ /**
2776
+ * Enable view transitions on this submission navigation
2777
+ */
2778
+ viewTransition?: boolean;
2779
+ }
2780
+
2781
+ declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
2782
+ /**
2783
+ * Defines the discovery behavior of the link:
2784
+ *
2785
+ * - "render" - default, discover the route when the link renders
2786
+ * - "none" - don't eagerly discover, only discover if the link is clicked
19
2787
  */
20
- declare enum ServerMode {
21
- Development = "development",
22
- Production = "production",
23
- Test = "test"
24
- }
25
-
2788
+ type DiscoverBehavior = "render" | "none";
26
2789
  /**
27
- Resolves a URL against the current location.
2790
+ * Defines the prefetching behavior of the link:
2791
+ *
2792
+ * - "none": Never fetched
2793
+ * - "intent": Fetched when the user focuses or hovers the link
2794
+ * - "render": Fetched when the link is rendered
2795
+ * - "viewport": Fetched when the link is in the viewport
2796
+ */
2797
+ type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
2798
+ /**
2799
+ Renders all of the `<link>` tags created by route module {@link LinksFunction} export. You should render it inside the `<head>` of your document.
28
2800
 
29
2801
  ```tsx
30
- import { useHref } from "react-router"
2802
+ import { Links } from "react-router";
31
2803
 
32
- function SomeComponent() {
33
- let href = useHref("some/where");
34
- // "/resolved/some/where"
2804
+ export default function Root() {
2805
+ return (
2806
+ <html>
2807
+ <head>
2808
+ <Links />
2809
+ </head>
2810
+ <body></body>
2811
+ </html>
2812
+ );
35
2813
  }
36
2814
  ```
37
2815
 
38
- @category Hooks
2816
+ @category Components
39
2817
  */
40
- declare function useHref(to: To, { relative }?: {
41
- relative?: RelativeRoutingType;
42
- }): string;
2818
+ declare function Links(): React.JSX.Element;
43
2819
  /**
44
- * Returns true if this component is a descendant of a Router, useful to ensure
45
- * a component is used within a Router.
46
- *
47
- * @category Hooks
2820
+ 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.
2821
+
2822
+ ```tsx
2823
+ import { PrefetchPageLinks } from "react-router"
2824
+
2825
+ <PrefetchPageLinks page="/absolute/path" />
2826
+ ```
2827
+
2828
+ 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.
2829
+
2830
+ @category Components
48
2831
  */
49
- declare function useInRouterContext(): boolean;
2832
+ declare function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor): React.JSX.Element | null;
50
2833
  /**
51
- Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
2834
+ Renders all the `<meta>` tags created by route module {@link MetaFunction} exports. You should render it inside the `<head>` of your HTML.
52
2835
 
53
2836
  ```tsx
54
- import * as React from 'react'
55
- import { useLocation } from 'react-router'
2837
+ import { Meta } from "react-router";
56
2838
 
57
- function SomeComponent() {
58
- let location = useLocation()
2839
+ export default function Root() {
2840
+ return (
2841
+ <html>
2842
+ <head>
2843
+ <Meta />
2844
+ </head>
2845
+ </html>
2846
+ );
2847
+ }
2848
+ ```
59
2849
 
60
- React.useEffect(() => {
61
- // Google Analytics
62
- ga('send', 'pageview')
63
- }, [location]);
2850
+ @category Components
2851
+ */
2852
+ declare function Meta(): React.JSX.Element;
2853
+ /**
2854
+ A couple common attributes:
2855
+
2856
+ - `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
2857
+ - `<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.
64
2858
 
2859
+ You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
2860
+
2861
+ @category Types
2862
+ */
2863
+ type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
2864
+ /**
2865
+ Renders the client runtime of your app. It should be rendered inside the `<body>` of the document.
2866
+
2867
+ ```tsx
2868
+ import { Scripts } from "react-router";
2869
+
2870
+ export default function Root() {
65
2871
  return (
66
- // ...
2872
+ <html>
2873
+ <head />
2874
+ <body>
2875
+ <Scripts />
2876
+ </body>
2877
+ </html>
67
2878
  );
68
2879
  }
69
2880
  ```
70
2881
 
71
- @category Hooks
2882
+ 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.
2883
+
2884
+ @category Components
72
2885
  */
73
- declare function useLocation(): Location;
2886
+ declare function Scripts(props: ScriptsProps): React.JSX.Element | null;
2887
+
2888
+ declare global {
2889
+ const REACT_ROUTER_VERSION: string;
2890
+ }
74
2891
  /**
75
- * Returns the current navigation action which describes how the router came to
76
- * the current location, either by a pop, push, or replace on the history stack.
2892
+ * @category Routers
2893
+ */
2894
+ interface DOMRouterOpts {
2895
+ /**
2896
+ * Basename path for the application.
2897
+ */
2898
+ basename?: string;
2899
+ /**
2900
+ * Function to provide the initial context values for all client side navigations/fetches
2901
+ */
2902
+ unstable_getContext?: RouterInit["unstable_getContext"];
2903
+ /**
2904
+ * Future flags to enable for the router.
2905
+ */
2906
+ future?: Partial<FutureConfig$1>;
2907
+ /**
2908
+ * Hydration data to initialize the router with if you have already performed
2909
+ * data loading on the server.
2910
+ */
2911
+ hydrationData?: HydrationState;
2912
+ /**
2913
+ * Override the default data strategy of loading in parallel.
2914
+ * Only intended for advanced usage.
2915
+ */
2916
+ dataStrategy?: DataStrategyFunction;
2917
+ /**
2918
+ * Lazily define portions of the route tree on navigations.
2919
+ */
2920
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
2921
+ /**
2922
+ * Window object override - defaults to the global `window` instance.
2923
+ */
2924
+ window?: Window;
2925
+ }
2926
+ /**
2927
+ * Create a new data router that manages the application path via `history.pushState`
2928
+ * and `history.replaceState`.
77
2929
  *
78
- * @category Hooks
2930
+ * @category Data Routers
79
2931
  */
80
- declare function useNavigationType(): Action;
2932
+ declare function createBrowserRouter(
81
2933
  /**
82
- * Returns a PathMatch object if the given pattern matches the current URL.
83
- * This is useful for components that need to know "active" state, e.g.
84
- * `<NavLink>`.
2934
+ * Application routes
2935
+ */
2936
+ routes: RouteObject[],
2937
+ /**
2938
+ * Router options
2939
+ */
2940
+ opts?: DOMRouterOpts): Router$1;
2941
+ /**
2942
+ * Create a new data router that manages the application path via the URL hash
85
2943
  *
86
- * @category Hooks
2944
+ * @category Data Routers
87
2945
  */
88
- declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
2946
+ declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
89
2947
  /**
90
- * The interface for the navigate() function returned from useNavigate().
2948
+ * @category Types
91
2949
  */
92
- interface NavigateFunction {
93
- (to: To, options?: NavigateOptions): void | Promise<void>;
94
- (delta: number): void | Promise<void>;
2950
+ interface BrowserRouterProps {
2951
+ basename?: string;
2952
+ children?: React.ReactNode;
2953
+ window?: Window;
95
2954
  }
96
2955
  /**
97
- Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
2956
+ * A `<Router>` for use in web browsers. Provides the cleanest URLs.
2957
+ *
2958
+ * @category Component Routers
2959
+ */
2960
+ declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
2961
+ /**
2962
+ * @category Types
2963
+ */
2964
+ interface HashRouterProps {
2965
+ basename?: string;
2966
+ children?: React.ReactNode;
2967
+ window?: Window;
2968
+ }
2969
+ /**
2970
+ * A `<Router>` for use in web browsers. Stores the location in the hash
2971
+ * portion of the URL so it is not sent to the server.
2972
+ *
2973
+ * @category Component Routers
2974
+ */
2975
+ declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
2976
+ /**
2977
+ * @category Types
2978
+ */
2979
+ interface HistoryRouterProps {
2980
+ basename?: string;
2981
+ children?: React.ReactNode;
2982
+ history: History;
2983
+ }
2984
+ /**
2985
+ * A `<Router>` that accepts a pre-instantiated history object. It's important
2986
+ * to note that using your own history object is highly discouraged and may add
2987
+ * two versions of the history library to your bundles unless you use the same
2988
+ * version of the history library that React Router uses internally.
2989
+ *
2990
+ * @name unstable_HistoryRouter
2991
+ * @category Component Routers
2992
+ */
2993
+ declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
2994
+ declare namespace HistoryRouter {
2995
+ var displayName: string;
2996
+ }
2997
+ /**
2998
+ * @category Types
2999
+ */
3000
+ interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
3001
+ /**
3002
+ Defines the link discovery behavior
3003
+
3004
+ ```tsx
3005
+ <Link /> // default ("render")
3006
+ <Link discover="render" />
3007
+ <Link discover="none" />
3008
+ ```
3009
+
3010
+ - **render** - default, discover the route when the link renders
3011
+ - **none** - don't eagerly discover, only discover if the link is clicked
3012
+ */
3013
+ discover?: DiscoverBehavior;
3014
+ /**
3015
+ Defines the data and module prefetching behavior for the link.
3016
+
3017
+ ```tsx
3018
+ <Link /> // default
3019
+ <Link prefetch="none" />
3020
+ <Link prefetch="intent" />
3021
+ <Link prefetch="render" />
3022
+ <Link prefetch="viewport" />
3023
+ ```
3024
+
3025
+ - **none** - default, no prefetching
3026
+ - **intent** - prefetches when the user hovers or focuses the link
3027
+ - **render** - prefetches when the link renders
3028
+ - **viewport** - prefetches when the link is in the viewport, very useful for mobile
3029
+
3030
+ Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted after the link.
3031
+
3032
+ ```tsx
3033
+ <a href="..." />
3034
+ <a href="..." />
3035
+ <link rel="prefetch" /> // might conditionally render
3036
+ ```
3037
+
3038
+ 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).
3039
+ */
3040
+ prefetch?: PrefetchBehavior;
3041
+ /**
3042
+ 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>`).
3043
+
3044
+ ```tsx
3045
+ <Link to="/logout" reloadDocument />
3046
+ ```
3047
+ */
3048
+ reloadDocument?: boolean;
3049
+ /**
3050
+ Replaces the current entry in the history stack instead of pushing a new one onto it.
3051
+
3052
+ ```tsx
3053
+ <Link replace />
3054
+ ```
3055
+
3056
+ ```
3057
+ # with a history stack like this
3058
+ A -> B
3059
+
3060
+ # normal link click pushes a new entry
3061
+ A -> B -> C
3062
+
3063
+ # but with `replace`, B is replaced by C
3064
+ A -> C
3065
+ ```
3066
+ */
3067
+ replace?: boolean;
3068
+ /**
3069
+ Adds persistent client side routing state to the next location.
3070
+
3071
+ ```tsx
3072
+ <Link to="/somewhere/else" state={{ some: "value" }} />
3073
+ ```
3074
+
3075
+ The location state is accessed from the `location`.
3076
+
3077
+ ```tsx
3078
+ function SomeComp() {
3079
+ const location = useLocation()
3080
+ location.state; // { some: "value" }
3081
+ }
3082
+ ```
3083
+
3084
+ 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)
3085
+ */
3086
+ state?: any;
3087
+ /**
3088
+ 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.
3089
+
3090
+ ```tsx
3091
+ <Link to="?tab=one" preventScrollReset />
3092
+ ```
3093
+ */
3094
+ preventScrollReset?: boolean;
3095
+ /**
3096
+ Defines the relative path behavior for the link.
3097
+
3098
+ ```tsx
3099
+ <Link to=".." /> // default: "route"
3100
+ <Link relative="route" />
3101
+ <Link relative="path" />
3102
+ ```
3103
+
3104
+ Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".
3105
+
3106
+ - **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".
3107
+ - **path** - relative to the path so `..` will only remove one URL segment up to "/blog/:slug"
3108
+ */
3109
+ relative?: RelativeRoutingType;
3110
+ /**
3111
+ Can be a string or a partial {@link Path}:
3112
+
3113
+ ```tsx
3114
+ <Link to="/some/path" />
3115
+
3116
+ <Link
3117
+ to={{
3118
+ pathname: "/some/path",
3119
+ search: "?query=string",
3120
+ hash: "#hash",
3121
+ }}
3122
+ />
3123
+ ```
3124
+ */
3125
+ to: To;
3126
+ /**
3127
+ Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) for this navigation.
3128
+
3129
+ ```jsx
3130
+ <Link to={to} viewTransition>
3131
+ Click me
3132
+ </Link>
3133
+ ```
3134
+
3135
+ To apply specific styles for the transition, see {@link useViewTransitionState}
3136
+ */
3137
+ viewTransition?: boolean;
3138
+ }
3139
+ /**
3140
+ A progressively enhanced `<a href>` wrapper to enable navigation with client-side routing.
98
3141
 
99
3142
  ```tsx
100
- import { useNavigate } from "react-router";
3143
+ import { Link } from "react-router";
101
3144
 
102
- function SomeComponent() {
103
- let navigate = useNavigate();
104
- return (
105
- <button
106
- onClick={() => {
107
- navigate(-1);
108
- }}
109
- />
110
- );
111
- }
3145
+ <Link to="/dashboard">Dashboard</Link>;
3146
+
3147
+ <Link
3148
+ to={{
3149
+ pathname: "/some/path",
3150
+ search: "?query=string",
3151
+ hash: "#hash",
3152
+ }}
3153
+ />
112
3154
  ```
113
3155
 
114
- It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
3156
+ @category Components
3157
+ */
3158
+ declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
3159
+ /**
3160
+ The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
3161
+
3162
+ ```
3163
+ // className
3164
+ <NavLink
3165
+ to="/messages"
3166
+ className={({ isActive, isPending }) =>
3167
+ isPending ? "pending" : isActive ? "active" : ""
3168
+ }
3169
+ >
3170
+ Messages
3171
+ </NavLink>
3172
+
3173
+ // style
3174
+ <NavLink
3175
+ to="/messages"
3176
+ style={({ isActive, isPending }) => {
3177
+ return {
3178
+ fontWeight: isActive ? "bold" : "",
3179
+ color: isPending ? "red" : "black",
3180
+ }
3181
+ )}
3182
+ />
3183
+
3184
+ // children
3185
+ <NavLink to="/tasks">
3186
+ {({ isActive, isPending }) => (
3187
+ <span className={isActive ? "active" : ""}>Tasks</span>
3188
+ )}
3189
+ </NavLink>
3190
+ ```
115
3191
 
116
- @category Hooks
117
3192
  */
118
- declare function useNavigate(): NavigateFunction;
3193
+ type NavLinkRenderProps = {
3194
+ /**
3195
+ * Indicates if the link's URL matches the current location.
3196
+ */
3197
+ isActive: boolean;
3198
+ /**
3199
+ * Indicates if the pending location matches the link's URL.
3200
+ */
3201
+ isPending: boolean;
3202
+ /**
3203
+ * Indicates if a view transition to the link's URL is in progress. See {@link useViewTransitionState}
3204
+ */
3205
+ isTransitioning: boolean;
3206
+ };
119
3207
  /**
120
- * Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
121
- *
122
- * @category Hooks
3208
+ * @category Types
123
3209
  */
124
- declare function useOutletContext<Context = unknown>(): Context;
3210
+ interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
3211
+ /**
3212
+ Can be regular React children or a function that receives an object with the active and pending states of the link.
3213
+
3214
+ ```tsx
3215
+ <NavLink to="/tasks">
3216
+ {({ isActive }) => (
3217
+ <span className={isActive ? "active" : ""}>Tasks</span>
3218
+ )}
3219
+ </NavLink>
3220
+ ```
3221
+ */
3222
+ children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
3223
+ /**
3224
+ Changes the matching logic to make it case-sensitive:
3225
+
3226
+ | Link | URL | isActive |
3227
+ | -------------------------------------------- | ------------- | -------- |
3228
+ | `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
3229
+ | `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
3230
+ */
3231
+ caseSensitive?: boolean;
3232
+ /**
3233
+ Classes are automatically applied to NavLink that correspond to {@link NavLinkRenderProps}.
3234
+
3235
+ ```css
3236
+ a.active { color: red; }
3237
+ a.pending { color: blue; }
3238
+ a.transitioning {
3239
+ view-transition-name: my-transition;
3240
+ }
3241
+ ```
3242
+ */
3243
+ className?: string | ((props: NavLinkRenderProps) => string | undefined);
3244
+ /**
3245
+ 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.
3246
+
3247
+ | Link | URL | isActive |
3248
+ | ----------------------------- | ------------ | -------- |
3249
+ | `<NavLink to="/tasks" />` | `/tasks` | true |
3250
+ | `<NavLink to="/tasks" />` | `/tasks/123` | true |
3251
+ | `<NavLink to="/tasks" end />` | `/tasks` | true |
3252
+ | `<NavLink to="/tasks" end />` | `/tasks/123` | false |
3253
+
3254
+ `<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.
3255
+ */
3256
+ end?: boolean;
3257
+ style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
3258
+ }
125
3259
  /**
126
- * Returns the element for the child route at this level of the route
127
- * hierarchy. Used internally by `<Outlet>` to render child routes.
128
- *
129
- * @category Hooks
3260
+ Wraps {@link Link | `<Link>`} with additional props for styling active and pending states.
3261
+
3262
+ - Automatically applies classes to the link based on its active and pending states, see {@link NavLinkProps.className}.
3263
+ - 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.
3264
+
3265
+ ```tsx
3266
+ import { NavLink } from "react-router"
3267
+ <NavLink to="/message" />
3268
+ ```
3269
+
3270
+ States are available through the className, style, and children render props. See {@link NavLinkRenderProps}.
3271
+
3272
+ ```tsx
3273
+ <NavLink
3274
+ to="/messages"
3275
+ className={({ isActive, isPending }) =>
3276
+ isPending ? "pending" : isActive ? "active" : ""
3277
+ }
3278
+ >
3279
+ Messages
3280
+ </NavLink>
3281
+ ```
3282
+
3283
+ @category Components
130
3284
  */
131
- declare function useOutlet(context?: unknown): React.ReactElement | null;
3285
+ declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
3286
+ /**
3287
+ * Form props shared by navigations and fetchers
3288
+ */
3289
+ interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
3290
+ /**
3291
+ * The HTTP verb to use when the form is submitted. Supports "get", "post",
3292
+ * "put", "delete", and "patch".
3293
+ *
3294
+ * Native `<form>` only supports `get` and `post`, avoid the other verbs if
3295
+ * you'd like to support progressive enhancement
3296
+ */
3297
+ method?: HTMLFormMethod;
3298
+ /**
3299
+ * The encoding type to use for the form submission.
3300
+ */
3301
+ encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
3302
+ /**
3303
+ * The URL to submit the form data to. If `undefined`, this defaults to the closest route in context.
3304
+ */
3305
+ action?: string;
3306
+ /**
3307
+ * Determines whether the form action is relative to the route hierarchy or
3308
+ * the pathname. Use this if you want to opt out of navigating the route
3309
+ * hierarchy and want to instead route based on /-delimited URL segments
3310
+ */
3311
+ relative?: RelativeRoutingType;
3312
+ /**
3313
+ * Prevent the scroll position from resetting to the top of the viewport on
3314
+ * completion of the navigation when using the <ScrollRestoration> component
3315
+ */
3316
+ preventScrollReset?: boolean;
3317
+ /**
3318
+ * A function to call when the form is submitted. If you call
3319
+ * `event.preventDefault()` then this form will not do anything.
3320
+ */
3321
+ onSubmit?: React.FormEventHandler<HTMLFormElement>;
3322
+ }
3323
+ /**
3324
+ * Form props available to fetchers
3325
+ * @category Types
3326
+ */
3327
+ interface FetcherFormProps extends SharedFormProps {
3328
+ }
3329
+ /**
3330
+ * Form props available to navigations
3331
+ * @category Types
3332
+ */
3333
+ interface FormProps extends SharedFormProps {
3334
+ discover?: DiscoverBehavior;
3335
+ /**
3336
+ * Indicates a specific fetcherKey to use when using `navigate={false}` so you
3337
+ * can pick up the fetcher's state in a different component in a {@link
3338
+ * useFetcher}.
3339
+ */
3340
+ fetcherKey?: string;
3341
+ /**
3342
+ * Skips the navigation and uses a {@link useFetcher | fetcher} internally
3343
+ * when `false`. This is essentially a shorthand for `useFetcher()` +
3344
+ * `<fetcher.Form>` where you don't care about the resulting data in this
3345
+ * component.
3346
+ */
3347
+ navigate?: boolean;
3348
+ /**
3349
+ * Forces a full document navigation instead of client side routing + data
3350
+ * fetch.
3351
+ */
3352
+ reloadDocument?: boolean;
3353
+ /**
3354
+ * Replaces the current entry in the browser history stack when the form
3355
+ * navigates. Use this if you don't want the user to be able to click "back"
3356
+ * to the page with the form on it.
3357
+ */
3358
+ replace?: boolean;
3359
+ /**
3360
+ * State object to add to the history stack entry for this navigation
3361
+ */
3362
+ state?: any;
3363
+ /**
3364
+ * Enables a [View
3365
+ * Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
3366
+ * for this navigation. To apply specific styles during the transition see
3367
+ * {@link useViewTransitionState}.
3368
+ */
3369
+ viewTransition?: boolean;
3370
+ }
3371
+ /**
3372
+
3373
+ 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.
3374
+
3375
+ 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.
3376
+
3377
+ 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].
3378
+
3379
+ ```tsx
3380
+ import { Form } from "react-router";
3381
+
3382
+ function NewEvent() {
3383
+ return (
3384
+ <Form action="/events" method="post">
3385
+ <input name="title" type="text" />
3386
+ <input name="description" type="text" />
3387
+ </Form>
3388
+ )
3389
+ }
3390
+ ```
3391
+
3392
+ @category Components
3393
+ */
3394
+ declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
3395
+ type ScrollRestorationProps = ScriptsProps & {
3396
+ /**
3397
+ Defines the key used to restore scroll positions.
3398
+
3399
+ ```tsx
3400
+ <ScrollRestoration
3401
+ getKey={(location, matches) => {
3402
+ // default behavior
3403
+ return location.key
3404
+ }}
3405
+ />
3406
+ ```
3407
+ */
3408
+ getKey?: GetScrollRestorationKeyFunction;
3409
+ storageKey?: string;
3410
+ };
132
3411
  /**
133
- 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.
3412
+ Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
134
3413
 
135
3414
  ```tsx
136
- import { useParams } from "react-router"
3415
+ import { ScrollRestoration } from "react-router";
137
3416
 
138
- function SomeComponent() {
139
- let params = useParams()
140
- params.postId
3417
+ export default function Root() {
3418
+ return (
3419
+ <html>
3420
+ <body>
3421
+ <ScrollRestoration />
3422
+ <Scripts />
3423
+ </body>
3424
+ </html>
3425
+ );
141
3426
  }
142
3427
  ```
143
3428
 
144
- Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
145
-
146
- @category Hooks
147
- */
148
- declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
149
- ParamsOrKey
150
- ] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>;
151
- /**
152
- 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.
3429
+ 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.
153
3430
 
154
3431
  ```tsx
155
- import { useResolvedPath } from "react-router"
156
-
157
- function SomeComponent() {
158
- // if the user is at /dashboard/profile
159
- let path = useResolvedPath("../accounts")
160
- path.pathname // "/dashboard/accounts"
161
- path.search // ""
162
- path.hash // ""
163
- }
3432
+ <ScrollRestoration nonce={cspNonce} />
164
3433
  ```
165
3434
 
166
- @category Hooks
3435
+ @category Components
167
3436
  */
168
- declare function useResolvedPath(to: To, { relative }?: {
3437
+ declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
3438
+ declare namespace ScrollRestoration {
3439
+ var displayName: string;
3440
+ }
3441
+ /**
3442
+ * Handles the click behavior for router `<Link>` components. This is useful if
3443
+ * you need to create custom `<Link>` components with the same click behavior we
3444
+ * use in our exported `<Link>`.
3445
+ *
3446
+ * @category Hooks
3447
+ */
3448
+ declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
3449
+ target?: React.HTMLAttributeAnchorTarget;
3450
+ replace?: boolean;
3451
+ state?: any;
3452
+ preventScrollReset?: boolean;
169
3453
  relative?: RelativeRoutingType;
170
- }): Path;
3454
+ viewTransition?: boolean;
3455
+ }): (event: React.MouseEvent<E, MouseEvent>) => void;
171
3456
  /**
172
- Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
173
-
174
- The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
3457
+ Returns a tuple of the current URL's {@link URLSearchParams} and a function to update them. Setting the search params causes a navigation.
175
3458
 
176
3459
  ```tsx
177
- import * as React from "react";
178
- import { useRoutes } from "react-router";
179
-
180
- function App() {
181
- let element = useRoutes([
182
- {
183
- path: "/",
184
- element: <Dashboard />,
185
- children: [
186
- {
187
- path: "messages",
188
- element: <DashboardMessages />,
189
- },
190
- { path: "tasks", element: <DashboardTasks /> },
191
- ],
192
- },
193
- { path: "team", element: <AboutPage /> },
194
- ]);
3460
+ import { useSearchParams } from "react-router";
195
3461
 
196
- return element;
3462
+ export function SomeComponent() {
3463
+ const [searchParams, setSearchParams] = useSearchParams();
3464
+ // ...
197
3465
  }
198
3466
  ```
199
3467
 
200
3468
  @category Hooks
201
3469
  */
202
- declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
3470
+ declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
203
3471
  /**
204
- 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.
3472
+ Sets new search params and causes a navigation when called.
205
3473
 
206
3474
  ```tsx
207
- import { useNavigation } from "react-router"
208
-
209
- function SomeComponent() {
210
- let navigation = useNavigation();
211
- navigation.state
212
- navigation.formData
213
- // etc.
214
- }
3475
+ <button
3476
+ onClick={() => {
3477
+ const params = new URLSearchParams();
3478
+ params.set("someKey", "someValue");
3479
+ setSearchParams(params, {
3480
+ preventScrollReset: true,
3481
+ });
3482
+ }}
3483
+ />
215
3484
  ```
216
3485
 
217
- @category Hooks
3486
+ It also supports a function for setting new search params.
3487
+
3488
+ ```tsx
3489
+ <button
3490
+ onClick={() => {
3491
+ setSearchParams((prev) => {
3492
+ prev.set("someKey", "someValue");
3493
+ return prev;
3494
+ });
3495
+ }}
3496
+ />
3497
+ ```
218
3498
  */
219
- declare function useNavigation(): Navigation;
3499
+ type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
220
3500
  /**
221
- Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
3501
+ * Submits a HTML `<form>` to the server without reloading the page.
3502
+ */
3503
+ interface SubmitFunction {
3504
+ (
3505
+ /**
3506
+ Can be multiple types of elements and objects
222
3507
 
223
- ```tsx
224
- import { useRevalidator } from "react-router";
3508
+ **`HTMLFormElement`**
225
3509
 
226
- function WindowFocusRevalidator() {
227
- const revalidator = useRevalidator();
3510
+ ```tsx
3511
+ <Form
3512
+ onSubmit={(event) => {
3513
+ submit(event.currentTarget);
3514
+ }}
3515
+ />
3516
+ ```
228
3517
 
229
- useFakeWindowFocus(() => {
230
- revalidator.revalidate();
231
- });
3518
+ **`FormData`**
232
3519
 
233
- return (
234
- <div hidden={revalidator.state === "idle"}>
235
- Revalidating...
236
- </div>
237
- );
238
- }
239
- ```
3520
+ ```tsx
3521
+ const formData = new FormData();
3522
+ formData.append("myKey", "myValue");
3523
+ submit(formData, { method: "post" });
3524
+ ```
240
3525
 
241
- 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.
3526
+ **Plain object that will be serialized as `FormData`**
242
3527
 
243
- @category Hooks
244
- */
245
- declare function useRevalidator(): {
246
- revalidate: () => Promise<void>;
247
- state: Router["state"]["revalidation"];
248
- };
3528
+ ```tsx
3529
+ submit({ myKey: "myValue" }, { method: "post" });
3530
+ ```
3531
+
3532
+ **Plain object that will be serialized as JSON**
3533
+
3534
+ ```tsx
3535
+ submit(
3536
+ { myKey: "myValue" },
3537
+ { method: "post", encType: "application/json" }
3538
+ );
3539
+ ```
3540
+ */
3541
+ target: SubmitTarget,
3542
+ /**
3543
+ * Options that override the `<form>`'s own attributes. Required when
3544
+ * submitting arbitrary data without a backing `<form>`.
3545
+ */
3546
+ options?: SubmitOptions): Promise<void>;
3547
+ }
249
3548
  /**
250
- * Returns the active route matches, useful for accessing loaderData for
251
- * parent/child routes or the route "handle" property
252
- *
253
- * @category Hooks
3549
+ * Submits a fetcher `<form>` to the server without reloading the page.
254
3550
  */
255
- declare function useMatches(): UIMatch[];
256
- /**
257
- Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
3551
+ interface FetcherSubmitFunction {
3552
+ (
3553
+ /**
3554
+ Can be multiple types of elements and objects
258
3555
 
259
- ```tsx
260
- import { useLoaderData } from "react-router"
3556
+ **`HTMLFormElement`**
261
3557
 
262
- export async function loader() {
263
- return await fakeDb.invoices.findAll();
264
- }
3558
+ ```tsx
3559
+ <fetcher.Form
3560
+ onSubmit={(event) => {
3561
+ fetcher.submit(event.currentTarget);
3562
+ }}
3563
+ />
3564
+ ```
265
3565
 
266
- export default function Invoices() {
267
- let invoices = useLoaderData<typeof loader>();
268
- // ...
269
- }
270
- ```
3566
+ **`FormData`**
271
3567
 
272
- @category Hooks
273
- */
274
- declare function useLoaderData<T = any>(): SerializeFrom<T>;
275
- /**
276
- Returns the loader data for a given route by route ID.
3568
+ ```tsx
3569
+ const formData = new FormData();
3570
+ formData.append("myKey", "myValue");
3571
+ fetcher.submit(formData, { method: "post" });
3572
+ ```
277
3573
 
278
- ```tsx
279
- import { useRouteLoaderData } from "react-router";
3574
+ **Plain object that will be serialized as `FormData`**
280
3575
 
281
- function SomeComponent() {
282
- const { user } = useRouteLoaderData("root");
283
- }
284
- ```
3576
+ ```tsx
3577
+ fetcher.submit({ myKey: "myValue" }, { method: "post" });
3578
+ ```
285
3579
 
286
- Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
3580
+ **Plain object that will be serialized as JSON**
287
3581
 
288
- | Route Filename | Route ID |
289
- | -------------------------- | -------------------- |
290
- | `app/root.tsx` | `"root"` |
291
- | `app/routes/teams.tsx` | `"routes/teams"` |
292
- | `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
3582
+ ```tsx
3583
+ fetcher.submit(
3584
+ { myKey: "myValue" },
3585
+ { method: "post", encType: "application/json" }
3586
+ );
3587
+ ```
293
3588
 
294
- If you created an ID manually, you can use that instead:
3589
+ */
3590
+ target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
3591
+ }
3592
+ /**
3593
+ The imperative version of {@link Form | `<Form>`} that lets you submit a form from code instead of a user interaction.
295
3594
 
296
3595
  ```tsx
297
- route("/", "containers/app.tsx", { id: "app" }})
3596
+ import { useSubmit } from "react-router";
3597
+
3598
+ function SomeComponent() {
3599
+ const submit = useSubmit();
3600
+ return (
3601
+ <Form
3602
+ onChange={(event) => {
3603
+ submit(event.currentTarget);
3604
+ }}
3605
+ />
3606
+ );
3607
+ }
298
3608
  ```
299
3609
 
300
3610
  @category Hooks
301
3611
  */
302
- declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
3612
+ declare function useSubmit(): SubmitFunction;
303
3613
  /**
304
- Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
3614
+ Resolves the URL to the closest route in the component hierarchy instead of the current URL of the app.
3615
+
3616
+ This is used internally by {@link Form} resolve the action to the closest route, but can be used generically as well.
305
3617
 
306
3618
  ```tsx
307
- import { Form, useActionData } from "react-router"
3619
+ import { useFormAction } from "react-router";
308
3620
 
309
- export async function action({ request }) {
310
- const body = await request.formData()
311
- const name = body.get("visitorsName")
312
- return { message: `Hello, ${name}` }
313
- }
3621
+ function SomeComponent() {
3622
+ // closest route URL
3623
+ let action = useFormAction();
314
3624
 
315
- export default function Invoices() {
316
- const data = useActionData()
317
- return (
318
- <Form method="post">
319
- <input type="text" name="visitorsName" />
320
- {data ? data.message : "Waiting..."}
321
- </Form>
322
- )
3625
+ // closest route URL + "destroy"
3626
+ let destroyAction = useFormAction("destroy");
323
3627
  }
324
3628
  ```
325
3629
 
326
3630
  @category Hooks
327
3631
  */
328
- declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
3632
+ declare function useFormAction(
329
3633
  /**
330
- Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
3634
+ * The action to append to the closest route URL.
3635
+ */
3636
+ action?: string, { relative }?: {
3637
+ relative?: RelativeRoutingType;
3638
+ }): string;
3639
+ /**
3640
+ The return value of `useFetcher` that keeps track of the state of a fetcher.
3641
+
3642
+ ```tsx
3643
+ let fetcher = useFetcher();
3644
+ ```
3645
+ */
3646
+ type FetcherWithComponents<TData> = Fetcher<TData> & {
3647
+ /**
3648
+ Just like {@link Form} except it doesn't cause a navigation.
3649
+
3650
+ ```tsx
3651
+ function SomeComponent() {
3652
+ const fetcher = useFetcher()
3653
+ return (
3654
+ <fetcher.Form method="post" action="/some/route">
3655
+ <input type="text" />
3656
+ </fetcher.Form>
3657
+ )
3658
+ }
3659
+ ```
3660
+ */
3661
+ Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
3662
+ /**
3663
+ Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
3664
+
3665
+ The `formData` can be multiple types:
3666
+
3667
+ - [`FormData`][form_data] - A `FormData` instance.
3668
+ - [`HTMLFormElement`][html_form_element] - A [`<form>`][form_element] DOM element.
3669
+ - `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.
3670
+
3671
+ 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.
3672
+
3673
+ ```tsx
3674
+ // Submit a FormData instance (GET request)
3675
+ const formData = new FormData();
3676
+ fetcher.submit(formData);
3677
+
3678
+ // Submit the HTML form element
3679
+ fetcher.submit(event.currentTarget.form, {
3680
+ method: "POST",
3681
+ });
3682
+
3683
+ // Submit key/value JSON as a FormData instance
3684
+ fetcher.submit(
3685
+ { serialized: "values" },
3686
+ { method: "POST" }
3687
+ );
3688
+
3689
+ // Submit raw JSON
3690
+ fetcher.submit(
3691
+ {
3692
+ deeply: {
3693
+ nested: {
3694
+ json: "values",
3695
+ },
3696
+ },
3697
+ },
3698
+ {
3699
+ method: "POST",
3700
+ encType: "application/json",
3701
+ }
3702
+ );
3703
+ ```
3704
+ */
3705
+ submit: FetcherSubmitFunction;
3706
+ /**
3707
+ 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.
3708
+
3709
+ ```tsx
3710
+ let fetcher = useFetcher()
3711
+
3712
+ <input onChange={e => {
3713
+ fetcher.load(`/search?q=${e.target.value}`)
3714
+ }} />
3715
+ ```
3716
+ */
3717
+ load: (href: string, opts?: {
3718
+ /**
3719
+ * Wraps the initial state update for this `fetcher.load` in a
3720
+ * `ReactDOM.flushSync` call instead of the default `React.startTransition`.
3721
+ * This allows you to perform synchronous DOM actions immediately after the
3722
+ * update is flushed to the DOM.
3723
+ */
3724
+ flushSync?: boolean;
3725
+ }) => Promise<void>;
3726
+ };
3727
+ /**
3728
+ Useful for creating complex, dynamic user interfaces that require multiple, concurrent data interactions without causing a navigation.
3729
+
3730
+ Fetchers track their own, independent state and can be used to load data, submit forms, and generally interact with loaders and actions.
331
3731
 
332
3732
  ```tsx
333
- export function ErrorBoundary() {
334
- const error = useRouteError();
335
- return <div>{error.message}</div>;
3733
+ import { useFetcher } from "react-router"
3734
+
3735
+ function SomeComponent() {
3736
+ let fetcher = useFetcher()
3737
+
3738
+ // states are available on the fetcher
3739
+ fetcher.state // "idle" | "loading" | "submitting"
3740
+ fetcher.data // the data returned from the action or loader
3741
+
3742
+ // render a form
3743
+ <fetcher.Form method="post" />
3744
+
3745
+ // load data
3746
+ fetcher.load("/some/route")
3747
+
3748
+ // submit data
3749
+ fetcher.submit(someFormRef, { method: "post" })
3750
+ fetcher.submit(someData, {
3751
+ method: "post",
3752
+ encType: "application/json"
3753
+ })
336
3754
  }
337
3755
  ```
338
3756
 
339
3757
  @category Hooks
340
3758
  */
341
- declare function useRouteError(): unknown;
3759
+ declare function useFetcher<T = any>({ key, }?: {
3760
+ /**
3761
+ 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:
3762
+
3763
+ ```tsx
3764
+ function SomeComp() {
3765
+ let fetcher = useFetcher({ key: "my-key" })
3766
+ // ...
3767
+ }
3768
+
3769
+ // Somewhere else
3770
+ function AnotherComp() {
3771
+ // this will be the same fetcher, sharing the state across the app
3772
+ let fetcher = useFetcher({ key: "my-key" });
3773
+ // ...
3774
+ }
3775
+ ```
3776
+ */
3777
+ key?: string;
3778
+ }): FetcherWithComponents<SerializeFrom<T>>;
342
3779
  /**
343
- Returns the resolved promise value from the closest {@link Await | `<Await>`}.
3780
+ 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.
344
3781
 
345
3782
  ```tsx
346
- function SomeDescendant() {
347
- const value = useAsyncValue();
3783
+ import { useFetchers } from "react-router";
3784
+
3785
+ function SomeComponent() {
3786
+ const fetchers = useFetchers();
3787
+ fetchers[0].formData; // FormData
3788
+ fetchers[0].state; // etc.
348
3789
  // ...
349
3790
  }
350
-
351
- // somewhere in your app
352
- <Await resolve={somePromise}>
353
- <SomeDescendant />
354
- </Await>
355
3791
  ```
356
3792
 
357
3793
  @category Hooks
358
3794
  */
359
- declare function useAsyncValue(): unknown;
3795
+ declare function useFetchers(): (Fetcher & {
3796
+ key: string;
3797
+ })[];
360
3798
  /**
361
- Returns the rejection value from the closest {@link Await | `<Await>`}.
3799
+ * When rendered inside a RouterProvider, will restore scroll positions on navigations
3800
+ */
3801
+ declare function useScrollRestoration({ getKey, storageKey, }?: {
3802
+ getKey?: GetScrollRestorationKeyFunction;
3803
+ storageKey?: string;
3804
+ }): void;
3805
+ /**
3806
+ * Setup a callback to be fired on the window's `beforeunload` event.
3807
+ *
3808
+ * @category Hooks
3809
+ */
3810
+ declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
3811
+ capture?: boolean;
3812
+ }): void;
3813
+ /**
3814
+ Wrapper around useBlocker to show a window.confirm prompt to users instead of building a custom UI with {@link useBlocker}.
3815
+
3816
+ 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.
362
3817
 
363
3818
  ```tsx
364
- import { Await, useAsyncError } from "react-router"
3819
+ function ImportantForm() {
3820
+ let [value, setValue] = React.useState("");
3821
+
3822
+ // Block navigating elsewhere when data has been entered into the input
3823
+ unstable_usePrompt({
3824
+ message: "Are you sure?",
3825
+ when: ({ currentLocation, nextLocation }) =>
3826
+ value !== "" &&
3827
+ currentLocation.pathname !== nextLocation.pathname,
3828
+ });
365
3829
 
366
- function ErrorElement() {
367
- const error = useAsyncError();
368
3830
  return (
369
- <p>Uh Oh, something went wrong! {error.message}</p>
3831
+ <Form method="post">
3832
+ <label>
3833
+ Enter some important data:
3834
+ <input
3835
+ name="data"
3836
+ value={value}
3837
+ onChange={(e) => setValue(e.target.value)}
3838
+ />
3839
+ </label>
3840
+ <button type="submit">Save</button>
3841
+ </Form>
370
3842
  );
371
3843
  }
372
-
373
- // somewhere in your app
374
- <Await
375
- resolve={promiseThatRejects}
376
- errorElement={<ErrorElement />}
377
- />
378
3844
  ```
379
3845
 
380
3846
  @category Hooks
3847
+ @name unstable_usePrompt
381
3848
  */
382
- declare function useAsyncError(): unknown;
3849
+ declare function usePrompt({ when, message, }: {
3850
+ when: boolean | BlockerFunction;
3851
+ message: string;
3852
+ }): void;
383
3853
  /**
384
- * Allow the application to block navigations within the SPA and present the
385
- * user a confirmation dialog to confirm the navigation. Mostly used to avoid
386
- * using half-filled form data. This does not handle hard-reloads or
387
- * cross-origin navigations.
388
- *
389
- * @category Hooks
3854
+ 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)
3855
+
3856
+ @category Hooks
3857
+ @name useViewTransitionState
390
3858
  */
391
- declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
3859
+ declare function useViewTransitionState(to: To, opts?: {
3860
+ relative?: RelativeRoutingType;
3861
+ }): boolean;
392
3862
 
393
3863
  interface StaticRouterProps {
394
3864
  basename?: string;
@@ -404,7 +3874,7 @@ interface StaticRouterProps {
404
3874
  declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
405
3875
  interface StaticRouterProviderProps {
406
3876
  context: StaticHandlerContext;
407
- router: Router;
3877
+ router: Router$1;
408
3878
  hydrate?: boolean;
409
3879
  nonce?: string;
410
3880
  }
@@ -424,8 +3894,8 @@ declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticH
424
3894
  * @category Data Routers
425
3895
  */
426
3896
  declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
427
- future?: Partial<FutureConfig>;
428
- }): Router;
3897
+ future?: Partial<FutureConfig$1>;
3898
+ }): Router$1;
429
3899
 
430
3900
  interface ServerRouterProps {
431
3901
  context: EntryContext;
@@ -497,7 +3967,7 @@ interface RoutesTestStubProps {
497
3967
  /**
498
3968
  * Future flags mimicking the settings in react-router.config.ts
499
3969
  */
500
- future?: Partial<FutureConfig$1>;
3970
+ future?: Partial<FutureConfig>;
501
3971
  }
502
3972
  /**
503
3973
  * @category Utils
@@ -752,16 +4222,26 @@ declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
752
4222
  */
753
4223
  interface Register {
754
4224
  }
4225
+ type AnyParams = Record<string, string | undefined>;
4226
+ type AnyPages = Record<string, {
4227
+ params: AnyParams;
4228
+ }>;
4229
+ type Pages = Register extends {
4230
+ pages: infer Registered extends AnyPages;
4231
+ } ? Registered : AnyPages;
4232
+ type AnyRouteFiles = Record<string, {
4233
+ id: string;
4234
+ page: string;
4235
+ }>;
4236
+ type RouteFiles = Register extends {
4237
+ routeFiles: infer Registered extends AnyRouteFiles;
4238
+ } ? Registered : AnyRouteFiles;
755
4239
 
756
- type AnyParams = Record<string, Record<string, string | undefined>>;
757
- type Params = Register extends {
758
- params: infer RegisteredParams extends AnyParams;
759
- } ? RegisteredParams : AnyParams;
760
4240
  type Args = {
761
- [K in keyof Params]: ToArgs<Params[K]>;
4241
+ [K in keyof Pages]: ToArgs<Pages[K]["params"]>;
762
4242
  };
763
- type ToArgs<T> = Equal<T, {}> extends true ? [] : Partial<T> extends T ? [T] | [] : [
764
- T
4243
+ type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [
4244
+ Params
765
4245
  ];
766
4246
  /**
767
4247
  Returns a resolved URL path for the specified route.
@@ -799,16 +4279,16 @@ declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps
799
4279
  }
800
4280
 
801
4281
  declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
802
- declare function useFogOFWarDiscovery(router: Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean): void;
4282
+ declare function useFogOFWarDiscovery(router: Router$1, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean): void;
803
4283
 
804
4284
  declare function getHydrationData(state: {
805
- loaderData?: Router["state"]["loaderData"];
806
- actionData?: Router["state"]["actionData"];
807
- errors?: Router["state"]["errors"];
4285
+ loaderData?: Router$1["state"]["loaderData"];
4286
+ actionData?: Router$1["state"]["actionData"];
4287
+ errors?: Router$1["state"]["errors"];
808
4288
  }, routes: DataRouteObject[], getRouteInfo: (routeId: string) => {
809
4289
  clientLoader: ClientLoaderFunction | undefined;
810
4290
  hasLoader: boolean;
811
4291
  hasHydrateFallback: boolean;
812
4292
  }, location: Path, basename: string | undefined, isSpaMode: boolean): HydrationState;
813
4293
 
814
- export { ActionFunction, AppLoadContext, Blocker, BlockerFunction, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, DataRouteObject, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params$1 as Params, PatchRoutesOnNavigationFunction, Path, PathMatch, PathPattern, type Register, RelativeRoutingType, type RequestHandler, RouteObject, RouterState, type RoutesTestStubProps, ServerBuild, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, MiddlewareEnabled as UNSAFE_MiddlewareEnabled, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, unstable_InitialContext, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
4294
+ export { type ActionFunction, type ActionFunctionArgs, type AppLoadContext, Await, type AwaitProps, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router$1 as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type Pages, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route$1 as Route, type RouteFiles, type RouteMatch, type RouteObject, type RouteProps, Router, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, 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, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, type MiddlewareEnabled as UNSAFE_MiddlewareEnabled, NavigationContext as UNSAFE_NavigationContext, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, mapRouteProperties as UNSAFE_mapRouteProperties, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, type URLSearchParamsInit, createBrowserRouter, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, type unstable_InitialContext, type unstable_MiddlewareFunction, type unstable_RouterContext, unstable_RouterContextProvider, type unstable_SerializesTo, unstable_createContext, 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 };