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