react-router 0.0.0-experimental-b588f7e → 0.0.0-experimental-23decd7bc

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