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