UNPKG

56.3 kBTypeScriptView Raw
1import { J as RouteModules, l as DataStrategyFunction, r as MiddlewareEnabled, c as RouterContextProvider, s as AppLoadContext, T as To, K as SerializeFrom, L as Location, O as ParamParseKey, p as Path, Q as PathPattern, V as PathMatch, U as UIMatch, i as Action, P as Params, e as RouteObject, G as GetLoaderData, I as GetActionData, W as InitialEntry, X as IndexRouteObject, d as LoaderFunction, A as ActionFunction, M as MetaFunction, b as LinksFunction, Y as NonIndexRouteObject, Z as Equal, m as PatchRoutesOnNavigationFunction, n as DataRouteObject, a as ClientLoaderFunction } from './routeModules-CM_clkdE.js';
2export { _ as ActionFunctionArgs, $ as BaseRouteObject, C as ClientActionFunction, ap as ClientActionFunctionArgs, aq as ClientLoaderFunctionArgs, D as DataRouteMatch, a0 as DataStrategyFunctionArgs, a1 as DataStrategyMatch, B as DataStrategyResult, a3 as ErrorResponse, F as FormEncType, a4 as FormMethod, av as Future, o as HTMLFormMethod, ar as HeadersArgs, H as HeadersFunction, au as HtmlLinkDescriptor, a5 as LazyRouteFunction, t as LinkDescriptor, q as LoaderFunctionArgs, as as MetaArgs, w as MetaDescriptor, a6 as MiddlewareFunction, at as PageLinkDescriptor, a7 as PatchRoutesOnNavigationFunctionArgs, a8 as PathParam, a9 as RedirectFunction, aa as RouteMatch, ab as RouterContext, S as ShouldRevalidateFunction, ac as ShouldRevalidateFunctionArgs, a2 as UNSAFE_DataWithResponseInit, aB as UNSAFE_ErrorResponseImpl, ay as UNSAFE_createBrowserHistory, az as UNSAFE_createHashHistory, ax as UNSAFE_createMemoryHistory, aA as UNSAFE_invariant, ad as createContext, ae as createPath, ag as data, ah as generatePath, ai as isRouteErrorResponse, aj as matchPath, ak as matchRoutes, af as parsePath, al as redirect, am as redirectDocument, an as replace, ao as resolvePath, aw as unstable_SerializesTo } from './routeModules-CM_clkdE.js';
3import { a as Router, B as BlockerFunction, b as Blocker, c as RelativeRoutingType, N as Navigation, H as HydrationState, d as RouterState } from './instrumentation-CMVbvxj9.js';
4export { F as Fetcher, G as GetScrollPositionFunction, e as GetScrollRestorationKeyFunction, r as IDLE_BLOCKER, q as IDLE_FETCHER, I as IDLE_NAVIGATION, g as NavigationStates, k as RevalidationState, j as RouterFetchOptions, R as RouterInit, i as RouterNavigateOptions, h as RouterSubscriber, S as StaticHandler, f as StaticHandlerContext, s as UNSAFE_createRouter, u as unstable_ClientInstrumentation, m as unstable_InstrumentRequestHandlerFunction, o as unstable_InstrumentRouteFunction, n as unstable_InstrumentRouterFunction, p as unstable_InstrumentationHandlerResult, l as unstable_ServerInstrumentation } from './instrumentation-CMVbvxj9.js';
5import { A as AssetsManifest, S as ServerBuild, N as NavigateOptions, E as EntryContext, F as FutureConfig } from './index-react-server-client-CimaPp9o.js';
6export { i as Await, c as AwaitProps, W as BrowserRouter, B as BrowserRouterProps, C as ClientOnErrorFunction, D as DOMRouterOpts, at as DiscoverBehavior, y as FetcherFormProps, Q as FetcherSubmitFunction, aa as FetcherSubmitOptions, T as FetcherWithComponents, $ as Form, z as FormProps, au as HandleDataRequestFunction, av as HandleDocumentRequestFunction, aw as HandleErrorFunction, X as HashRouter, H as HashRouterProps, u as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, Y as Link, v as LinkProps, an as Links, aq as LinksProps, j as MemoryRouter, M as MemoryRouterOpts, d as MemoryRouterProps, am as Meta, _ as NavLink, w as NavLinkProps, x as NavLinkRenderProps, k as Navigate, e as NavigateProps, a as Navigator, l as Outlet, O as OutletProps, ab as ParamKeyValuePair, P as PathRouteProps, as as PrefetchBehavior, ap as PrefetchPageLinks, m as Route, R as RouteProps, n as Router, f as RouterProps, o as RouterProvider, g as RouterProviderProps, p as Routes, h as RoutesProps, ao as Scripts, ar as ScriptsProps, a0 as ScrollRestoration, G as ScrollRestorationProps, ax as ServerEntryModule, J as SetURLSearchParams, ak as StaticRouter, ag as StaticRouterProps, al as StaticRouterProvider, ah as StaticRouterProviderProps, K as SubmitFunction, ac as SubmitOptions, ae as SubmitTarget, b as UNSAFE_AwaitContextProvider, ay as UNSAFE_DataRouterContext, az as UNSAFE_DataRouterStateContext, aA as UNSAFE_FetchersContext, aN as UNSAFE_FrameworkContext, aB as UNSAFE_LocationContext, aC as UNSAFE_NavigationContext, aD as UNSAFE_RouteContext, aE as UNSAFE_ViewTransitionContext, aH as UNSAFE_WithComponentProps, aL as UNSAFE_WithErrorBoundaryProps, aJ as UNSAFE_WithHydrateFallbackProps, aO as UNSAFE_createClientRoutes, aP as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, aF as UNSAFE_hydrationRouteProperties, aG as UNSAFE_mapRouteProperties, aQ as UNSAFE_shouldHydrateRouteLoader, aR as UNSAFE_useScrollRestoration, aI as UNSAFE_withComponentProps, aM as UNSAFE_withErrorBoundaryProps, aK as UNSAFE_withHydrateFallbackProps, ad as URLSearchParamsInit, U as createBrowserRouter, V as createHashRouter, q as createMemoryRouter, r as createRoutesFromChildren, s as createRoutesFromElements, af as createSearchParams, ai as createStaticHandler, aj as createStaticRouter, t as renderMatches, Z as unstable_HistoryRouter, a8 as unstable_usePrompt, a7 as useBeforeUnload, a5 as useFetcher, a6 as useFetchers, a4 as useFormAction, a1 as useLinkClickHandler, a2 as useSearchParams, a3 as useSubmit, a9 as useViewTransitionState } from './index-react-server-client-CimaPp9o.js';
7import * as React from 'react';
8import React__default, { ReactElement } from 'react';
9import { a as RouteModules$1, P as Pages } from './register-D1WlEpq9.js';
10export { b as Register } from './register-D1WlEpq9.js';
11import { ParseOptions, SerializeOptions } from 'cookie';
12export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
13import { e as RSCPayload, g as getRequest, m as matchRSCServerRequest } from './browser-CtktEGQs.js';
14export { B as unstable_BrowserCreateFromReadableStreamFunction, D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, E as unstable_EncodeReplyFunction, L as unstable_LoadServerActionFunction, h as unstable_RSCHydratedRouterProps, d as unstable_RSCManifestPayload, i as unstable_RSCMatch, f as unstable_RSCRenderPayload, n as unstable_RSCRouteConfig, l as unstable_RSCRouteConfigEntry, j as unstable_RSCRouteManifest, k as unstable_RSCRouteMatch } from './browser-CtktEGQs.js';
15
16declare const SingleFetchRedirectSymbol: unique symbol;
17declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined, trailingSlashAware: boolean): DataStrategyFunction;
18declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
19 done: Promise<undefined>;
20 value: unknown;
21}>;
22
23/**
24 * The mode to use when running the server.
25 */
26declare enum ServerMode {
27 Development = "development",
28 Production = "production",
29 Test = "test"
30}
31
32type RequestHandler = (request: Request, loadContext?: MiddlewareEnabled extends true ? RouterContextProvider : AppLoadContext) => Promise<Response>;
33type CreateRequestHandlerFunction = (build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>), mode?: string) => RequestHandler;
34declare const createRequestHandler: CreateRequestHandlerFunction;
35
36/**
37 * Resolves a URL against the current {@link Location}.
38 *
39 * @example
40 * import { useHref } from "react-router";
41 *
42 * function SomeComponent() {
43 * let href = useHref("some/where");
44 * // "/resolved/some/where"
45 * }
46 *
47 * @public
48 * @category Hooks
49 * @param to The path to resolve
50 * @param options Options
51 * @param options.relative Defaults to `"route"` so routing is relative to the
52 * route tree.
53 * Set to `"path"` to make relative routing operate against path segments.
54 * @returns The resolved href string
55 */
56declare function useHref(to: To, { relative }?: {
57 relative?: RelativeRoutingType;
58}): string;
59/**
60 * Returns `true` if this component is a descendant of a {@link Router}, useful
61 * to ensure a component is used within a {@link Router}.
62 *
63 * @public
64 * @category Hooks
65 * @mode framework
66 * @mode data
67 * @returns Whether the component is within a {@link Router} context
68 */
69declare function useInRouterContext(): boolean;
70/**
71 * Returns the current {@link Location}. This can be useful if you'd like to
72 * perform some side effect whenever it changes.
73 *
74 * @example
75 * import * as React from 'react'
76 * import { useLocation } from 'react-router'
77 *
78 * function SomeComponent() {
79 * let location = useLocation()
80 *
81 * React.useEffect(() => {
82 * // Google Analytics
83 * ga('send', 'pageview')
84 * }, [location]);
85 *
86 * return (
87 * // ...
88 * );
89 * }
90 *
91 * @public
92 * @category Hooks
93 * @returns The current {@link Location} object
94 */
95declare function useLocation(): Location;
96/**
97 * Returns the current {@link Navigation} action which describes how the router
98 * came to the current {@link Location}, either by a pop, push, or replace on
99 * the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History) stack.
100 *
101 * @public
102 * @category Hooks
103 * @returns The current {@link NavigationType} (`"POP"`, `"PUSH"`, or `"REPLACE"`)
104 */
105declare function useNavigationType(): Action;
106/**
107 * Returns a {@link PathMatch} object if the given pattern matches the current URL.
108 * This is useful for components that need to know "active" state, e.g.
109 * {@link NavLink | `<NavLink>`}.
110 *
111 * @public
112 * @category Hooks
113 * @param pattern The pattern to match against the current {@link Location}
114 * @returns The path match object if the pattern matches, `null` otherwise
115 */
116declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
117/**
118 * The interface for the `navigate` function returned from {@link useNavigate}.
119 */
120interface NavigateFunction {
121 (to: To, options?: NavigateOptions): void | Promise<void>;
122 (delta: number): void | Promise<void>;
123}
124/**
125 * Returns a function that lets you navigate programmatically in the browser in
126 * response to user interactions or effects.
127 *
128 * It's often better to use {@link redirect} in [`action`](../../start/framework/route-module#action)/[`loader`](../../start/framework/route-module#loader)
129 * functions than this hook.
130 *
131 * The returned function signature is `navigate(to, options?)`/`navigate(delta)` where:
132 *
133 * * `to` can be a string path, a {@link To} object, or a number (delta)
134 * * `options` contains options for modifying the navigation
135 * * These options work in all modes (Framework, Data, and Declarative):
136 * * `relative`: `"route"` or `"path"` to control relative routing logic
137 * * `replace`: Replace the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History) stack
138 * * `state`: Optional [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state) to include with the new {@link Location}
139 * * These options only work in Framework and Data modes:
140 * * `flushSync`: Wrap the DOM updates in [`ReactDom.flushSync`](https://react.dev/reference/react-dom/flushSync)
141 * * `preventScrollReset`: Do not scroll back to the top of the page after navigation
142 * * `viewTransition`: Enable [`document.startViewTransition`](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for this navigation
143 *
144 * @example
145 * import { useNavigate } from "react-router";
146 *
147 * function SomeComponent() {
148 * let navigate = useNavigate();
149 * return (
150 * <button onClick={() => navigate(-1)}>
151 * Go Back
152 * </button>
153 * );
154 * }
155 *
156 * @additionalExamples
157 * ### Navigate to another path
158 *
159 * ```tsx
160 * navigate("/some/route");
161 * navigate("/some/route?search=param");
162 * ```
163 *
164 * ### Navigate with a {@link To} object
165 *
166 * All properties are optional.
167 *
168 * ```tsx
169 * navigate({
170 * pathname: "/some/route",
171 * search: "?search=param",
172 * hash: "#hash",
173 * state: { some: "state" },
174 * });
175 * ```
176 *
177 * If you use `state`, that will be available on the {@link Location} object on
178 * the next page. Access it with `useLocation().state` (see {@link useLocation}).
179 *
180 * ### Navigate back or forward in the history stack
181 *
182 * ```tsx
183 * // back
184 * // often used to close modals
185 * navigate(-1);
186 *
187 * // forward
188 * // often used in a multistep wizard workflows
189 * navigate(1);
190 * ```
191 *
192 * Be cautious with `navigate(number)`. If your application can load up to a
193 * route that has a button that tries to navigate forward/back, there may not be
194 * a [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
195 * entry to go back or forward to, or it can go somewhere you don't expect
196 * (like a different domain).
197 *
198 * Only use this if you're sure they will have an entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
199 * stack to navigate to.
200 *
201 * ### Replace the current entry in the history stack
202 *
203 * This will remove the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
204 * stack, replacing it with a new one, similar to a server side redirect.
205 *
206 * ```tsx
207 * navigate("/some/route", { replace: true });
208 * ```
209 *
210 * ### Prevent Scroll Reset
211 *
212 * [MODES: framework, data]
213 *
214 * <br/>
215 * <br/>
216 *
217 * To prevent {@link ScrollRestoration | `<ScrollRestoration>`} from resetting
218 * the scroll position, use the `preventScrollReset` option.
219 *
220 * ```tsx
221 * navigate("?some-tab=1", { preventScrollReset: true });
222 * ```
223 *
224 * For example, if you have a tab interface connected to search params in the
225 * middle of a page, and you don't want it to scroll to the top when a tab is
226 * clicked.
227 *
228 * ### Return Type Augmentation
229 *
230 * Internally, `useNavigate` uses a separate implementation when you are in
231 * Declarative mode versus Data/Framework mode - the primary difference being
232 * that the latter is able to return a stable reference that does not change
233 * identity across navigations. The implementation in Data/Framework mode also
234 * returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
235 * that resolves when the navigation is completed. This means the return type of
236 * `useNavigate` is `void | Promise<void>`. This is accurate, but can lead to
237 * some red squigglies based on the union in the return value:
238 *
239 * - If you're using `typescript-eslint`, you may see errors from
240 * [`@typescript-eslint/no-floating-promises`](https://typescript-eslint.io/rules/no-floating-promises)
241 * - In Framework/Data mode, `React.use(navigate())` will show a false-positive
242 * `Argument of type 'void | Promise<void>' is not assignable to parameter of
243 * type 'Usable<void>'` error
244 *
245 * The easiest way to work around these issues is to augment the type based on the
246 * router you're using:
247 *
248 * ```ts
249 * // If using <BrowserRouter>
250 * declare module "react-router" {
251 * interface NavigateFunction {
252 * (to: To, options?: NavigateOptions): void;
253 * (delta: number): void;
254 * }
255 * }
256 *
257 * // If using <RouterProvider> or Framework mode
258 * declare module "react-router" {
259 * interface NavigateFunction {
260 * (to: To, options?: NavigateOptions): Promise<void>;
261 * (delta: number): Promise<void>;
262 * }
263 * }
264 * ```
265 *
266 * @public
267 * @category Hooks
268 * @returns A navigate function for programmatic navigation
269 */
270declare function useNavigate(): NavigateFunction;
271/**
272 * Returns the parent route {@link Outlet | `<Outlet context>`}.
273 *
274 * Often parent routes manage state or other values you want shared with child
275 * routes. You can create your own [context provider](https://react.dev/learn/passing-data-deeply-with-context)
276 * if you like, but this is such a common situation that it's built-into
277 * {@link Outlet | `<Outlet>`}.
278 *
279 * ```tsx
280 * // Parent route
281 * function Parent() {
282 * const [count, setCount] = React.useState(0);
283 * return <Outlet context={[count, setCount]} />;
284 * }
285 * ```
286 *
287 * ```tsx
288 * // Child route
289 * import { useOutletContext } from "react-router";
290 *
291 * function Child() {
292 * const [count, setCount] = useOutletContext();
293 * const increment = () => setCount((c) => c + 1);
294 * return <button onClick={increment}>{count}</button>;
295 * }
296 * ```
297 *
298 * If you're using TypeScript, we recommend the parent component provide a
299 * custom hook for accessing the context value. This makes it easier for
300 * consumers to get nice typings, control consumers, and know who's consuming
301 * the context value.
302 *
303 * Here's a more realistic example:
304 *
305 * ```tsx filename=src/routes/dashboard.tsx lines=[14,20]
306 * import { useState } from "react";
307 * import { Outlet, useOutletContext } from "react-router";
308 *
309 * import type { User } from "./types";
310 *
311 * type ContextType = { user: User | null };
312 *
313 * export default function Dashboard() {
314 * const [user, setUser] = useState<User | null>(null);
315 *
316 * return (
317 * <div>
318 * <h1>Dashboard</h1>
319 * <Outlet context={{ user } satisfies ContextType} />
320 * </div>
321 * );
322 * }
323 *
324 * export function useUser() {
325 * return useOutletContext<ContextType>();
326 * }
327 * ```
328 *
329 * ```tsx filename=src/routes/dashboard/messages.tsx lines=[1,4]
330 * import { useUser } from "../dashboard";
331 *
332 * export default function DashboardMessages() {
333 * const { user } = useUser();
334 * return (
335 * <div>
336 * <h2>Messages</h2>
337 * <p>Hello, {user.name}!</p>
338 * </div>
339 * );
340 * }
341 * ```
342 *
343 * @public
344 * @category Hooks
345 * @returns The context value passed to the parent {@link Outlet} component
346 */
347declare function useOutletContext<Context = unknown>(): Context;
348/**
349 * Returns the element for the child route at this level of the route
350 * hierarchy. Used internally by {@link Outlet | `<Outlet>`} to render child
351 * routes.
352 *
353 * @public
354 * @category Hooks
355 * @param context The context to pass to the outlet
356 * @returns The child route element or `null` if no child routes match
357 */
358declare function useOutlet(context?: unknown): React.ReactElement | null;
359/**
360 * Returns an object of key/value-pairs of the dynamic params from the current
361 * URL that were matched by the routes. Child routes inherit all params from
362 * their parent routes.
363 *
364 * Assuming a route pattern like `/posts/:postId` is matched by `/posts/123`
365 * then `params.postId` will be `"123"`.
366 *
367 * @example
368 * import { useParams } from "react-router";
369 *
370 * function SomeComponent() {
371 * let params = useParams();
372 * params.postId;
373 * }
374 *
375 * @additionalExamples
376 * ### Basic Usage
377 *
378 * ```tsx
379 * import { useParams } from "react-router";
380 *
381 * // given a route like:
382 * <Route path="/posts/:postId" element={<Post />} />;
383 *
384 * // or a data route like:
385 * createBrowserRouter([
386 * {
387 * path: "/posts/:postId",
388 * component: Post,
389 * },
390 * ]);
391 *
392 * // or in routes.ts
393 * route("/posts/:postId", "routes/post.tsx");
394 * ```
395 *
396 * Access the params in a component:
397 *
398 * ```tsx
399 * import { useParams } from "react-router";
400 *
401 * export default function Post() {
402 * let params = useParams();
403 * return <h1>Post: {params.postId}</h1>;
404 * }
405 * ```
406 *
407 * ### Multiple Params
408 *
409 * Patterns can have multiple params:
410 *
411 * ```tsx
412 * "/posts/:postId/comments/:commentId";
413 * ```
414 *
415 * All will be available in the params object:
416 *
417 * ```tsx
418 * import { useParams } from "react-router";
419 *
420 * export default function Post() {
421 * let params = useParams();
422 * return (
423 * <h1>
424 * Post: {params.postId}, Comment: {params.commentId}
425 * </h1>
426 * );
427 * }
428 * ```
429 *
430 * ### Catchall Params
431 *
432 * Catchall params are defined with `*`:
433 *
434 * ```tsx
435 * "/files/*";
436 * ```
437 *
438 * The matched value will be available in the params object as follows:
439 *
440 * ```tsx
441 * import { useParams } from "react-router";
442 *
443 * export default function File() {
444 * let params = useParams();
445 * let catchall = params["*"];
446 * // ...
447 * }
448 * ```
449 *
450 * You can destructure the catchall param:
451 *
452 * ```tsx
453 * export default function File() {
454 * let { "*": catchall } = useParams();
455 * console.log(catchall);
456 * }
457 * ```
458 *
459 * @public
460 * @category Hooks
461 * @returns An object containing the dynamic route parameters
462 */
463declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
464 ParamsOrKey
465] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
466/**
467 * Resolves the pathname of the given `to` value against the current
468 * {@link Location}. Similar to {@link useHref}, but returns a
469 * {@link Path} instead of a string.
470 *
471 * @example
472 * import { useResolvedPath } from "react-router";
473 *
474 * function SomeComponent() {
475 * // if the user is at /dashboard/profile
476 * let path = useResolvedPath("../accounts");
477 * path.pathname; // "/dashboard/accounts"
478 * path.search; // ""
479 * path.hash; // ""
480 * }
481 *
482 * @public
483 * @category Hooks
484 * @param to The path to resolve
485 * @param options Options
486 * @param options.relative Defaults to `"route"` so routing is relative to the route tree.
487 * Set to `"path"` to make relative routing operate against path segments.
488 * @returns The resolved {@link Path} object with `pathname`, `search`, and `hash`
489 */
490declare function useResolvedPath(to: To, { relative }?: {
491 relative?: RelativeRoutingType;
492}): Path;
493/**
494 * Hook version of {@link Routes | `<Routes>`} that uses objects instead of
495 * components. These objects have the same properties as the component props.
496 * The return value of `useRoutes` is either a valid React element you can use
497 * to render the route tree, or `null` if nothing matched.
498 *
499 * @example
500 * import { useRoutes } from "react-router";
501 *
502 * function App() {
503 * let element = useRoutes([
504 * {
505 * path: "/",
506 * element: <Dashboard />,
507 * children: [
508 * {
509 * path: "messages",
510 * element: <DashboardMessages />,
511 * },
512 * { path: "tasks", element: <DashboardTasks /> },
513 * ],
514 * },
515 * { path: "team", element: <AboutPage /> },
516 * ]);
517 *
518 * return element;
519 * }
520 *
521 * @public
522 * @category Hooks
523 * @param routes An array of {@link RouteObject}s that define the route hierarchy
524 * @param locationArg An optional {@link Location} object or pathname string to
525 * use instead of the current {@link Location}
526 * @returns A React element to render the matched route, or `null` if no routes matched
527 */
528declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
529/**
530 * Returns the current {@link Navigation}, defaulting to an "idle" navigation
531 * when no navigation is in progress. You can use this to render pending UI
532 * (like a global spinner) or read [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
533 * from a form navigation.
534 *
535 * @example
536 * import { useNavigation } from "react-router";
537 *
538 * function SomeComponent() {
539 * let navigation = useNavigation();
540 * navigation.state;
541 * navigation.formData;
542 * // etc.
543 * }
544 *
545 * @public
546 * @category Hooks
547 * @mode framework
548 * @mode data
549 * @returns The current {@link Navigation} object
550 */
551declare function useNavigation(): Navigation;
552/**
553 * Revalidate the data on the page for reasons outside of normal data mutations
554 * like [`Window` focus](https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event)
555 * or polling on an interval.
556 *
557 * Note that page data is already revalidated automatically after actions.
558 * If you find yourself using this for normal CRUD operations on your data in
559 * response to user interactions, you're probably not taking advantage of the
560 * other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do
561 * this automatically.
562 *
563 * @example
564 * import { useRevalidator } from "react-router";
565 *
566 * function WindowFocusRevalidator() {
567 * const revalidator = useRevalidator();
568 *
569 * useFakeWindowFocus(() => {
570 * revalidator.revalidate();
571 * });
572 *
573 * return (
574 * <div hidden={revalidator.state === "idle"}>
575 * Revalidating...
576 * </div>
577 * );
578 * }
579 *
580 * @public
581 * @category Hooks
582 * @mode framework
583 * @mode data
584 * @returns An object with a `revalidate` function and the current revalidation
585 * `state`
586 */
587declare function useRevalidator(): {
588 revalidate: () => Promise<void>;
589 state: Router["state"]["revalidation"];
590};
591/**
592 * Returns the active route matches, useful for accessing `loaderData` for
593 * parent/child routes or the route [`handle`](../../start/framework/route-module#handle)
594 * property
595 *
596 * @public
597 * @category Hooks
598 * @mode framework
599 * @mode data
600 * @returns An array of {@link UIMatch | UI matches} for the current route hierarchy
601 */
602declare function useMatches(): UIMatch[];
603/**
604 * Returns the data from the closest route
605 * [`loader`](../../start/framework/route-module#loader) or
606 * [`clientLoader`](../../start/framework/route-module#clientloader).
607 *
608 * @example
609 * import { useLoaderData } from "react-router";
610 *
611 * export async function loader() {
612 * return await fakeDb.invoices.findAll();
613 * }
614 *
615 * export default function Invoices() {
616 * let invoices = useLoaderData<typeof loader>();
617 * // ...
618 * }
619 *
620 * @public
621 * @category Hooks
622 * @mode framework
623 * @mode data
624 * @returns The data returned from the route's [`loader`](../../start/framework/route-module#loader) or [`clientLoader`](../../start/framework/route-module#clientloader) function
625 */
626declare function useLoaderData<T = any>(): SerializeFrom<T>;
627/**
628 * Returns the [`loader`](../../start/framework/route-module#loader) data for a
629 * given route by route ID.
630 *
631 * Route IDs are created automatically. They are simply the path of the route file
632 * relative to the app folder without the extension.
633 *
634 * | Route Filename | Route ID |
635 * | ---------------------------- | ---------------------- |
636 * | `app/root.tsx` | `"root"` |
637 * | `app/routes/teams.tsx` | `"routes/teams"` |
638 * | `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
639 *
640 * @example
641 * import { useRouteLoaderData } from "react-router";
642 *
643 * function SomeComponent() {
644 * const { user } = useRouteLoaderData("root");
645 * }
646 *
647 * // You can also specify your own route ID's manually in your routes.ts file:
648 * route("/", "containers/app.tsx", { id: "app" })
649 * useRouteLoaderData("app");
650 *
651 * @public
652 * @category Hooks
653 * @mode framework
654 * @mode data
655 * @param routeId The ID of the route to return loader data from
656 * @returns The data returned from the specified route's [`loader`](../../start/framework/route-module#loader)
657 * function, or `undefined` if not found
658 */
659declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
660/**
661 * Returns the [`action`](../../start/framework/route-module#action) data from
662 * the most recent `POST` navigation form submission or `undefined` if there
663 * hasn't been one.
664 *
665 * @example
666 * import { Form, useActionData } from "react-router";
667 *
668 * export async function action({ request }) {
669 * const body = await request.formData();
670 * const name = body.get("visitorsName");
671 * return { message: `Hello, ${name}` };
672 * }
673 *
674 * export default function Invoices() {
675 * const data = useActionData();
676 * return (
677 * <Form method="post">
678 * <input type="text" name="visitorsName" />
679 * {data ? data.message : "Waiting..."}
680 * </Form>
681 * );
682 * }
683 *
684 * @public
685 * @category Hooks
686 * @mode framework
687 * @mode data
688 * @returns The data returned from the route's [`action`](../../start/framework/route-module#action)
689 * function, or `undefined` if no [`action`](../../start/framework/route-module#action)
690 * has been called
691 */
692declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
693/**
694 * Accesses the error thrown during an
695 * [`action`](../../start/framework/route-module#action),
696 * [`loader`](../../start/framework/route-module#loader),
697 * or component render to be used in a route module
698 * [`ErrorBoundary`](../../start/framework/route-module#errorboundary).
699 *
700 * @example
701 * export function ErrorBoundary() {
702 * const error = useRouteError();
703 * return <div>{error.message}</div>;
704 * }
705 *
706 * @public
707 * @category Hooks
708 * @mode framework
709 * @mode data
710 * @returns The error that was thrown during route [loading](../../start/framework/route-module#loader),
711 * [`action`](../../start/framework/route-module#action) execution, or rendering
712 */
713declare function useRouteError(): unknown;
714/**
715 * Returns the resolved promise value from the closest {@link Await | `<Await>`}.
716 *
717 * @example
718 * function SomeDescendant() {
719 * const value = useAsyncValue();
720 * // ...
721 * }
722 *
723 * // somewhere in your app
724 * <Await resolve={somePromise}>
725 * <SomeDescendant />
726 * </Await>;
727 *
728 * @public
729 * @category Hooks
730 * @mode framework
731 * @mode data
732 * @returns The resolved value from the nearest {@link Await} component
733 */
734declare function useAsyncValue(): unknown;
735/**
736 * Returns the rejection value from the closest {@link Await | `<Await>`}.
737 *
738 * @example
739 * import { Await, useAsyncError } from "react-router";
740 *
741 * function ErrorElement() {
742 * const error = useAsyncError();
743 * return (
744 * <p>Uh Oh, something went wrong! {error.message}</p>
745 * );
746 * }
747 *
748 * // somewhere in your app
749 * <Await
750 * resolve={promiseThatRejects}
751 * errorElement={<ErrorElement />}
752 * />;
753 *
754 * @public
755 * @category Hooks
756 * @mode framework
757 * @mode data
758 * @returns The error that was thrown in the nearest {@link Await} component
759 */
760declare function useAsyncError(): unknown;
761/**
762 * Allow the application to block navigations within the SPA and present the
763 * user a confirmation dialog to confirm the navigation. Mostly used to avoid
764 * using half-filled form data. This does not handle hard-reloads or
765 * cross-origin navigations.
766 *
767 * The {@link Blocker} object returned by the hook has the following properties:
768 *
769 * - **`state`**
770 * - `unblocked` - the blocker is idle and has not prevented any navigation
771 * - `blocked` - the blocker has prevented a navigation
772 * - `proceeding` - the blocker is proceeding through from a blocked navigation
773 * - **`location`**
774 * - When in a `blocked` state, this represents the {@link Location} to which
775 * we blocked a navigation. When in a `proceeding` state, this is the
776 * location being navigated to after a `blocker.proceed()` call.
777 * - **`proceed()`**
778 * - When in a `blocked` state, you may call `blocker.proceed()` to proceed to
779 * the blocked location.
780 * - **`reset()`**
781 * - When in a `blocked` state, you may call `blocker.reset()` to return the
782 * blocker to an `unblocked` state and leave the user at the current
783 * location.
784 *
785 * @example
786 * // Boolean version
787 * let blocker = useBlocker(value !== "");
788 *
789 * // Function version
790 * let blocker = useBlocker(
791 * ({ currentLocation, nextLocation, historyAction }) =>
792 * value !== "" &&
793 * currentLocation.pathname !== nextLocation.pathname
794 * );
795 *
796 * @additionalExamples
797 * ```tsx
798 * import { useCallback, useState } from "react";
799 * import { BlockerFunction, useBlocker } from "react-router";
800 *
801 * export function ImportantForm() {
802 * const [value, setValue] = useState("");
803 *
804 * const shouldBlock = useCallback<BlockerFunction>(
805 * () => value !== "",
806 * [value]
807 * );
808 * const blocker = useBlocker(shouldBlock);
809 *
810 * return (
811 * <form
812 * onSubmit={(e) => {
813 * e.preventDefault();
814 * setValue("");
815 * if (blocker.state === "blocked") {
816 * blocker.proceed();
817 * }
818 * }}
819 * >
820 * <input
821 * name="data"
822 * value={value}
823 * onChange={(e) => setValue(e.target.value)}
824 * />
825 *
826 * <button type="submit">Save</button>
827 *
828 * {blocker.state === "blocked" ? (
829 * <>
830 * <p style={{ color: "red" }}>
831 * Blocked the last navigation to
832 * </p>
833 * <button
834 * type="button"
835 * onClick={() => blocker.proceed()}
836 * >
837 * Let me through
838 * </button>
839 * <button
840 * type="button"
841 * onClick={() => blocker.reset()}
842 * >
843 * Keep me here
844 * </button>
845 * </>
846 * ) : blocker.state === "proceeding" ? (
847 * <p style={{ color: "orange" }}>
848 * Proceeding through blocked navigation
849 * </p>
850 * ) : (
851 * <p style={{ color: "green" }}>
852 * Blocker is currently unblocked
853 * </p>
854 * )}
855 * </form>
856 * );
857 * }
858 * ```
859 *
860 * @public
861 * @category Hooks
862 * @mode framework
863 * @mode data
864 * @param shouldBlock Either a boolean or a function returning a boolean which
865 * indicates whether the navigation should be blocked. The function format
866 * receives a single object parameter containing the `currentLocation`,
867 * `nextLocation`, and `historyAction` of the potential navigation.
868 * @returns A {@link Blocker} object with state and reset functionality
869 */
870declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
871type UseRouteArgs = [] | [routeId: keyof RouteModules$1];
872type UseRouteResult<Args extends UseRouteArgs> = Args extends [] ? UseRoute<unknown> : Args extends ["root"] ? UseRoute<"root"> : Args extends [infer RouteId extends keyof RouteModules$1] ? UseRoute<RouteId> | undefined : never;
873type UseRoute<RouteId extends keyof RouteModules$1 | unknown> = {
874 handle: RouteId extends keyof RouteModules$1 ? RouteModules$1[RouteId] extends {
875 handle: infer handle;
876 } ? handle : unknown : unknown;
877 loaderData: RouteId extends keyof RouteModules$1 ? GetLoaderData<RouteModules$1[RouteId]> | undefined : unknown;
878 actionData: RouteId extends keyof RouteModules$1 ? GetActionData<RouteModules$1[RouteId]> | undefined : unknown;
879};
880declare function useRoute<Args extends UseRouteArgs>(...args: Args): UseRouteResult<Args>;
881
882/**
883 * @category Types
884 */
885interface ServerRouterProps {
886 /**
887 * The entry context containing the manifest, route modules, and other data
888 * needed for rendering.
889 */
890 context: EntryContext;
891 /**
892 * The URL of the request being handled.
893 */
894 url: string | URL;
895 /**
896 * An optional `nonce` for [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP)
897 * compliance, used to allow inline scripts to run safely.
898 */
899 nonce?: string;
900}
901/**
902 * The server entry point for a React Router app in Framework Mode. This
903 * component is used to generate the HTML in the response from the server. See
904 * [`entry.server.tsx`](../framework-conventions/entry.server.tsx).
905 *
906 * @public
907 * @category Framework Routers
908 * @mode framework
909 * @param props Props
910 * @param {ServerRouterProps.context} props.context n/a
911 * @param {ServerRouterProps.nonce} props.nonce n/a
912 * @param {ServerRouterProps.url} props.url n/a
913 * @returns A React element that represents the server-rendered application.
914 */
915declare function ServerRouter({ context, url, nonce, }: ServerRouterProps): ReactElement;
916
917interface StubRouteExtensions {
918 Component?: React.ComponentType<any>;
919 HydrateFallback?: React.ComponentType<any>;
920 ErrorBoundary?: React.ComponentType<any>;
921 loader?: LoaderFunction;
922 action?: ActionFunction;
923 children?: StubRouteObject[];
924 meta?: MetaFunction;
925 links?: LinksFunction;
926}
927interface StubIndexRouteObject extends Omit<IndexRouteObject, "Component" | "HydrateFallback" | "ErrorBoundary" | "loader" | "action" | "element" | "errorElement" | "children">, StubRouteExtensions {
928}
929interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "Component" | "HydrateFallback" | "ErrorBoundary" | "loader" | "action" | "element" | "errorElement" | "children">, StubRouteExtensions {
930}
931type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
932interface RoutesTestStubProps {
933 /**
934 * The initial entries in the history stack. This allows you to start a test with
935 * multiple locations already in the history stack (for testing a back navigation, etc.)
936 * The test will default to the last entry in initialEntries if no initialIndex is provided.
937 * e.g. initialEntries={["/home", "/about", "/contact"]}
938 */
939 initialEntries?: InitialEntry[];
940 /**
941 * The initial index in the history stack to render. This allows you to start a test at a specific entry.
942 * It defaults to the last entry in initialEntries.
943 * e.g.
944 * initialEntries: ["/", "/events/123"]
945 * initialIndex: 1 // start at "/events/123"
946 */
947 initialIndex?: number;
948 /**
949 * Used to set the route's initial loader and action data.
950 * e.g. hydrationData={{
951 * loaderData: { "/contact": { locale: "en-US" } },
952 * actionData: { "/login": { errors: { email: "invalid email" } }}
953 * }}
954 */
955 hydrationData?: HydrationState;
956 /**
957 * Future flags mimicking the settings in react-router.config.ts
958 */
959 future?: Partial<FutureConfig>;
960}
961/**
962 * @category Utils
963 */
964declare function createRoutesStub(routes: StubRouteObject[], _context?: AppLoadContext | RouterContextProvider): ({ initialEntries, initialIndex, hydrationData, future, }: RoutesTestStubProps) => React.JSX.Element;
965
966interface CookieSignatureOptions {
967 /**
968 * An array of secrets that may be used to sign/unsign the value of a cookie.
969 *
970 * The array makes it easy to rotate secrets. New secrets should be added to
971 * the beginning of the array. `cookie.serialize()` will always use the first
972 * value in the array, but `cookie.parse()` may use any of them so that
973 * cookies that were signed with older secrets still work.
974 */
975 secrets?: string[];
976}
977type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
978/**
979 * A HTTP cookie.
980 *
981 * A Cookie is a logical container for metadata about a HTTP cookie; its name
982 * and options. But it doesn't contain a value. Instead, it has `parse()` and
983 * `serialize()` methods that allow a single instance to be reused for
984 * parsing/encoding multiple different values.
985 *
986 * @see https://remix.run/utils/cookies#cookie-api
987 */
988interface Cookie {
989 /**
990 * The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
991 */
992 readonly name: string;
993 /**
994 * True if this cookie uses one or more secrets for verification.
995 */
996 readonly isSigned: boolean;
997 /**
998 * The Date this cookie expires.
999 *
1000 * Note: This is calculated at access time using `maxAge` when no `expires`
1001 * option is provided to `createCookie()`.
1002 */
1003 readonly expires?: Date;
1004 /**
1005 * Parses a raw `Cookie` header and returns the value of this cookie or
1006 * `null` if it's not present.
1007 */
1008 parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;
1009 /**
1010 * Serializes the given value to a string and returns the `Set-Cookie`
1011 * header.
1012 */
1013 serialize(value: any, options?: SerializeOptions): Promise<string>;
1014}
1015/**
1016 * Creates a logical container for managing a browser cookie from the server.
1017 */
1018declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
1019type IsCookieFunction = (object: any) => object is Cookie;
1020/**
1021 * Returns true if an object is a Remix cookie container.
1022 *
1023 * @see https://remix.run/utils/cookies#iscookie
1024 */
1025declare const isCookie: IsCookieFunction;
1026
1027/**
1028 * An object of name/value pairs to be used in the session.
1029 */
1030interface SessionData {
1031 [name: string]: any;
1032}
1033/**
1034 * Session persists data across HTTP requests.
1035 *
1036 * @see https://reactrouter.com/explanation/sessions-and-cookies#sessions
1037 */
1038interface Session<Data = SessionData, FlashData = Data> {
1039 /**
1040 * A unique identifier for this session.
1041 *
1042 * Note: This will be the empty string for newly created sessions and
1043 * sessions that are not backed by a database (i.e. cookie-based sessions).
1044 */
1045 readonly id: string;
1046 /**
1047 * The raw data contained in this session.
1048 *
1049 * This is useful mostly for SessionStorage internally to access the raw
1050 * session data to persist.
1051 */
1052 readonly data: FlashSessionData<Data, FlashData>;
1053 /**
1054 * Returns `true` if the session has a value for the given `name`, `false`
1055 * otherwise.
1056 */
1057 has(name: (keyof Data | keyof FlashData) & string): boolean;
1058 /**
1059 * Returns the value for the given `name` in this session.
1060 */
1061 get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
1062 /**
1063 * Sets a value in the session for the given `name`.
1064 */
1065 set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
1066 /**
1067 * Sets a value in the session that is only valid until the next `get()`.
1068 * This can be useful for temporary values, like error messages.
1069 */
1070 flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
1071 /**
1072 * Removes a value from the session.
1073 */
1074 unset(name: keyof Data & string): void;
1075}
1076type FlashSessionData<Data, FlashData> = Partial<Data & {
1077 [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
1078}>;
1079type FlashDataKey<Key extends string> = `__flash_${Key}__`;
1080type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
1081/**
1082 * Creates a new Session object.
1083 *
1084 * Note: This function is typically not invoked directly by application code.
1085 * Instead, use a `SessionStorage` object's `getSession` method.
1086 */
1087declare const createSession: CreateSessionFunction;
1088type IsSessionFunction = (object: any) => object is Session;
1089/**
1090 * Returns true if an object is a React Router session.
1091 *
1092 * @see https://reactrouter.com/api/utils/isSession
1093 */
1094declare const isSession: IsSessionFunction;
1095/**
1096 * SessionStorage stores session data between HTTP requests and knows how to
1097 * parse and create cookies.
1098 *
1099 * A SessionStorage creates Session objects using a `Cookie` header as input.
1100 * Then, later it generates the `Set-Cookie` header to be used in the response.
1101 */
1102interface SessionStorage<Data = SessionData, FlashData = Data> {
1103 /**
1104 * Parses a Cookie header from a HTTP request and returns the associated
1105 * Session. If there is no session associated with the cookie, this will
1106 * return a new Session with no data.
1107 */
1108 getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>;
1109 /**
1110 * Stores all data in the Session and returns the Set-Cookie header to be
1111 * used in the HTTP response.
1112 */
1113 commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
1114 /**
1115 * Deletes all data associated with the Session and returns the Set-Cookie
1116 * header to be used in the HTTP response.
1117 */
1118 destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
1119}
1120/**
1121 * SessionIdStorageStrategy is designed to allow anyone to easily build their
1122 * own SessionStorage using `createSessionStorage(strategy)`.
1123 *
1124 * This strategy describes a common scenario where the session id is stored in
1125 * a cookie but the actual session data is stored elsewhere, usually in a
1126 * database or on disk. A set of create, read, update, and delete operations
1127 * are provided for managing the session data.
1128 */
1129interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
1130 /**
1131 * The Cookie used to store the session id, or options used to automatically
1132 * create one.
1133 */
1134 cookie?: Cookie | (CookieOptions & {
1135 name?: string;
1136 });
1137 /**
1138 * Creates a new record with the given data and returns the session id.
1139 */
1140 createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
1141 /**
1142 * Returns data for a given session id, or `null` if there isn't any.
1143 */
1144 readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
1145 /**
1146 * Updates data for the given session id.
1147 */
1148 updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
1149 /**
1150 * Deletes data for a given session id from the data store.
1151 */
1152 deleteData: (id: string) => Promise<void>;
1153}
1154/**
1155 * Creates a SessionStorage object using a SessionIdStorageStrategy.
1156 *
1157 * Note: This is a low-level API that should only be used if none of the
1158 * existing session storage options meet your requirements.
1159 */
1160declare function createSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg, createData, readData, updateData, deleteData, }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
1161
1162interface CookieSessionStorageOptions {
1163 /**
1164 * The Cookie used to store the session data on the client, or options used
1165 * to automatically create one.
1166 */
1167 cookie?: SessionIdStorageStrategy["cookie"];
1168}
1169/**
1170 * Creates and returns a SessionStorage object that stores all session data
1171 * directly in the session cookie itself.
1172 *
1173 * This has the advantage that no database or other backend services are
1174 * needed, and can help to simplify some load-balanced scenarios. However, it
1175 * also has the limitation that serialized session data may not exceed the
1176 * browser's maximum cookie size. Trade-offs!
1177 */
1178declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
1179
1180interface MemorySessionStorageOptions {
1181 /**
1182 * The Cookie used to store the session id on the client, or options used
1183 * to automatically create one.
1184 */
1185 cookie?: SessionIdStorageStrategy["cookie"];
1186}
1187/**
1188 * Creates and returns a simple in-memory SessionStorage object, mostly useful
1189 * for testing and as a reference implementation.
1190 *
1191 * Note: This storage does not scale beyond a single process, so it is not
1192 * suitable for most production scenarios.
1193 */
1194declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
1195
1196type DevServerHooks = {
1197 getCriticalCss?: (pathname: string) => Promise<string | undefined>;
1198 processRequestError?: (error: unknown) => void;
1199};
1200declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
1201
1202type Args = {
1203 [K in keyof Pages]: ToArgs<Pages[K]["params"]>;
1204};
1205type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [
1206 Params
1207];
1208/**
1209 Returns a resolved URL path for the specified route.
1210
1211 ```tsx
1212 const h = href("/:lang?/about", { lang: "en" })
1213 // -> `/en/about`
1214
1215 <Link to={href("/products/:id", { id: "abc123" })} />
1216 ```
1217 */
1218declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
1219
1220type DecodedPayload = Promise<RSCPayload> & {
1221 _deepestRenderedBoundaryId?: string | null;
1222 formState: Promise<any>;
1223};
1224type SSRCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>) => Promise<unknown>;
1225/**
1226 * Routes the incoming [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
1227 * to the [RSC](https://react.dev/reference/rsc/server-components) server and
1228 * appropriately proxies the server response for data / resource requests, or
1229 * renders to HTML for a document request.
1230 *
1231 * @example
1232 * import { createFromReadableStream } from "@vitejs/plugin-rsc/ssr";
1233 * import * as ReactDomServer from "react-dom/server.edge";
1234 * import {
1235 * unstable_RSCStaticRouter as RSCStaticRouter,
1236 * unstable_routeRSCServerRequest as routeRSCServerRequest,
1237 * } from "react-router";
1238 *
1239 * routeRSCServerRequest({
1240 * request,
1241 * serverResponse,
1242 * createFromReadableStream,
1243 * async renderHTML(getPayload) {
1244 * const payload = getPayload();
1245 *
1246 * return await renderHTMLToReadableStream(
1247 * <RSCStaticRouter getPayload={getPayload} />,
1248 * {
1249 * bootstrapScriptContent,
1250 * formState: await payload.formState,
1251 * }
1252 * );
1253 * },
1254 * });
1255 *
1256 * @name unstable_routeRSCServerRequest
1257 * @public
1258 * @category RSC
1259 * @mode data
1260 * @param opts Options
1261 * @param opts.createFromReadableStream Your `react-server-dom-xyz/client`'s
1262 * `createFromReadableStream` function, used to decode payloads from the server.
1263 * @param opts.serverResponse A Response or partial response generated by the [RSC](https://react.dev/reference/rsc/server-components) handler containing a serialized {@link unstable_RSCPayload}.
1264 * @param opts.hydrate Whether to hydrate the server response with the RSC payload.
1265 * Defaults to `true`.
1266 * @param opts.renderHTML A function that renders the {@link unstable_RSCPayload} to
1267 * HTML, usually using a {@link unstable_RSCStaticRouter | `<RSCStaticRouter>`}.
1268 * @param opts.request The request to route.
1269 * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
1270 * that either contains the [RSC](https://react.dev/reference/rsc/server-components)
1271 * payload for data requests, or renders the HTML for document requests.
1272 */
1273declare function routeRSCServerRequest({ request, serverResponse, createFromReadableStream, renderHTML, hydrate, }: {
1274 request: Request;
1275 serverResponse: Response;
1276 createFromReadableStream: SSRCreateFromReadableStreamFunction;
1277 renderHTML: (getPayload: () => DecodedPayload, options: {
1278 onError(error: unknown): string | undefined;
1279 onHeaders(headers: Headers): void;
1280 }) => ReadableStream<Uint8Array> | Promise<ReadableStream<Uint8Array>>;
1281 hydrate?: boolean;
1282}): Promise<Response>;
1283/**
1284 * Props for the {@link unstable_RSCStaticRouter} component.
1285 *
1286 * @name unstable_RSCStaticRouterProps
1287 * @category Types
1288 */
1289interface RSCStaticRouterProps {
1290 /**
1291 * A function that starts decoding of the {@link unstable_RSCPayload}. Usually passed
1292 * through from {@link unstable_routeRSCServerRequest}'s `renderHTML`.
1293 */
1294 getPayload: () => DecodedPayload;
1295}
1296/**
1297 * Pre-renders an {@link unstable_RSCPayload} to HTML. Usually used in
1298 * {@link unstable_routeRSCServerRequest}'s `renderHTML` callback.
1299 *
1300 * @example
1301 * import { createFromReadableStream } from "@vitejs/plugin-rsc/ssr";
1302 * import * as ReactDomServer from "react-dom/server.edge";
1303 * import {
1304 * unstable_RSCStaticRouter as RSCStaticRouter,
1305 * unstable_routeRSCServerRequest as routeRSCServerRequest,
1306 * } from "react-router";
1307 *
1308 * routeRSCServerRequest({
1309 * request,
1310 * serverResponse,
1311 * createFromReadableStream,
1312 * async renderHTML(getPayload) {
1313 * const payload = getPayload();
1314 *
1315 * return await renderHTMLToReadableStream(
1316 * <RSCStaticRouter getPayload={getPayload} />,
1317 * {
1318 * bootstrapScriptContent,
1319 * formState: await payload.formState,
1320 * }
1321 * );
1322 * },
1323 * });
1324 *
1325 * @name unstable_RSCStaticRouter
1326 * @public
1327 * @category RSC
1328 * @mode data
1329 * @param props Props
1330 * @param {unstable_RSCStaticRouterProps.getPayload} props.getPayload n/a
1331 * @returns A React component that renders the {@link unstable_RSCPayload} as HTML.
1332 */
1333declare function RSCStaticRouter({ getPayload }: RSCStaticRouterProps): React.JSX.Element | null;
1334
1335declare function RSCDefaultRootErrorBoundary({ hasRootLayout, }: {
1336 hasRootLayout: boolean;
1337}): React__default.JSX.Element;
1338
1339declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
1340
1341type RemixErrorBoundaryProps = React.PropsWithChildren<{
1342 location: Location;
1343 isOutsideRemixApp?: boolean;
1344 error?: Error;
1345}>;
1346type RemixErrorBoundaryState = {
1347 error: null | Error;
1348 location: Location;
1349};
1350declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps, RemixErrorBoundaryState> {
1351 constructor(props: RemixErrorBoundaryProps);
1352 static getDerivedStateFromError(error: Error): {
1353 error: Error;
1354 };
1355 static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): {
1356 error: Error | null;
1357 location: Location<any>;
1358 };
1359 render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
1360}
1361
1362declare function getPatchRoutesOnNavigationFunction(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
1363declare function useFogOFWarDiscovery(router: Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean): void;
1364
1365declare function getHydrationData({ state, routes, getRouteInfo, location, basename, isSpaMode, }: {
1366 state: {
1367 loaderData?: Router["state"]["loaderData"];
1368 actionData?: Router["state"]["actionData"];
1369 errors?: Router["state"]["errors"];
1370 };
1371 routes: DataRouteObject[];
1372 getRouteInfo: (routeId: string) => {
1373 clientLoader: ClientLoaderFunction | undefined;
1374 hasLoader: boolean;
1375 hasHydrateFallback: boolean;
1376 };
1377 location: Path;
1378 basename: string | undefined;
1379 isSpaMode: boolean;
1380}): HydrationState;
1381
1382/**
1383 * @module index
1384 * @mergeModuleWith react-router
1385 */
1386
1387declare const unstable_getRequest: typeof getRequest;
1388declare const unstable_matchRSCServerRequest: typeof matchRSCServerRequest;
1389
1390export { ActionFunction, AppLoadContext, Blocker, BlockerFunction, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, DataRouteObject, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params, PatchRoutesOnNavigationFunction, Path, PathMatch, PathPattern, RelativeRoutingType, type RequestHandler, RouteObject, RouterContextProvider, RouterState, type RoutesTestStubProps, ServerBuild, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, To, UIMatch, 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, RSCPayload as unstable_RSCPayload, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, useRoute as unstable_useRoute, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };