UNPKG

32.6 kBTypeScriptView Raw
1import { R as RouteModules, a as Router, D as DataStrategyFunction, b as RouteManifest, S as ServerRouteModule, L as LoaderFunctionArgs, A as ActionFunctionArgs, T as To, c as RelativeRoutingType, d as Location, e as Action, P as ParamParseKey, f as Path, g as PathPattern, h as PathMatch, N as NavigateOptions, i as Params, j as RouteObject, k as Navigation, l as RevalidationState, U as UIMatch, m as SerializeFrom, B as BlockerFunction, n as Blocker, o as StaticHandlerContext, p as StaticHandler, F as FutureConfig$1, C as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, q as IndexRouteObject, r as LoaderFunction, s as ActionFunction, M as MetaFunction, t as LinksFunction, u as NonIndexRouteObject, v as RouterState } from './route-data-Cq_b5feC.js';
2export { ao as ClientActionFunction, ap as ClientActionFunctionArgs, aq as ClientLoaderFunction, ar as ClientLoaderFunctionArgs, ai as DataRouteMatch, aj as DataRouteObject, O as DataStrategyFunctionArgs, Q as DataStrategyMatch, V as DataStrategyResult, X as ErrorResponse, x as Fetcher, Y as FormEncType, Z as FormMethod, G as GetScrollPositionFunction, w as GetScrollRestorationKeyFunction, _ as HTMLFormMethod, as as HeadersArgs, at as HeadersFunction, ax as HtmlLinkDescriptor, a8 as IDLE_BLOCKER, a7 as IDLE_FETCHER, a6 as IDLE_NAVIGATION, $ as LazyRouteFunction, ay as LinkDescriptor, au as MetaArgs, av as MetaDescriptor, y as NavigationStates, ak as Navigator, aw as PageLinkDescriptor, al as PatchRoutesOnNavigationFunction, am as PatchRoutesOnNavigationFunctionArgs, a0 as PathParam, a1 as RedirectFunction, an as RouteMatch, K as RouterFetchOptions, z as RouterInit, J as RouterNavigateOptions, E as RouterSubscriber, a2 as ShouldRevalidateFunction, a3 as ShouldRevalidateFunctionArgs, aD as UNSAFE_DataRouterContext, aE as UNSAFE_DataRouterStateContext, W as UNSAFE_DataWithResponseInit, aC as UNSAFE_ErrorResponseImpl, aF as UNSAFE_FetchersContext, aG as UNSAFE_LocationContext, aH as UNSAFE_NavigationContext, aI as UNSAFE_RouteContext, aJ as UNSAFE_ViewTransitionContext, az as UNSAFE_createBrowserHistory, aB as UNSAFE_createRouter, aA as UNSAFE_invariant, a4 as createPath, a9 as data, aa as generatePath, ab as isRouteErrorResponse, ac as matchPath, ad as matchRoutes, a5 as parsePath, ae as redirect, af as redirectDocument, ag as replace, ah as resolvePath } from './route-data-Cq_b5feC.js';
3import { A as AssetsManifest, a as Route, F as FutureConfig, E as EntryContext } from './fog-of-war-CCAcUMgB.js';
4export { f as Await, b as AwaitProps, J as BrowserRouter, B as BrowserRouterProps, v as FetcherFormProps, z as FetcherSubmitFunction, a4 as FetcherSubmitOptions, C as FetcherWithComponents, V as Form, w as FormProps, K as HashRouter, H as HashRouterProps, q as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, Q as Link, s as LinkProps, ab as Links, g as MemoryRouter, M as MemoryRouterProps, aa as Meta, U as NavLink, t as NavLinkProps, u as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a5 as ParamKeyValuePair, P as PathRouteProps, ad as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ac as Scripts, ae as ScriptsProps, W as ScrollRestoration, S as ScrollRestorationProps, x as SetURLSearchParams, y as SubmitFunction, a6 as SubmitOptions, a8 as SubmitTarget, ag as UNSAFE_FrameworkContext, aj as UNSAFE_createClientRoutes, ak as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ah as UNSAFE_getPatchRoutesOnNavigationFunction, af as UNSAFE_mapRouteProperties, al as UNSAFE_shouldHydrateRouteLoader, ai as UNSAFE_useFogOFWarDiscovery, am as UNSAFE_useScrollRestoration, a7 as URLSearchParamsInit, D as createBrowserRouter, G as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, a9 as createSearchParams, r as renderMatches, T as unstable_HistoryRouter, a2 as unstable_usePrompt, a1 as useBeforeUnload, $ as useFetcher, a0 as useFetchers, _ as useFormAction, X as useLinkClickHandler, Y as useSearchParams, Z as useSubmit, a3 as useViewTransitionState } from './fog-of-war-CCAcUMgB.js';
5import * as React from 'react';
6import { ReactElement } from 'react';
7import { ParseOptions, SerializeOptions } from 'cookie';
8export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
9import { A as AppLoadContext$1 } from './data-CQbyyGzl.js';
10
11declare const SingleFetchRedirectSymbol: unique symbol;
12declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules, getRouter: () => Router): DataStrategyFunction;
13declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
14 done: Promise<undefined>;
15 value: unknown;
16}>;
17
18/**
19 * The mode to use when running the server.
20 */
21declare enum ServerMode {
22 Development = "development",
23 Production = "production",
24 Test = "test"
25}
26
27type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
28interface ServerRoute extends Route {
29 children: ServerRoute[];
30 module: ServerRouteModule;
31}
32
33/**
34 * The output of the compiler for the server build.
35 */
36interface ServerBuild {
37 entry: {
38 module: ServerEntryModule;
39 };
40 routes: ServerRouteManifest;
41 assets: AssetsManifest;
42 basename?: string;
43 publicPath: string;
44 assetsBuildDirectory: string;
45 future: FutureConfig;
46 isSpaMode: boolean;
47}
48interface HandleDocumentRequestFunction {
49 (request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: AppLoadContext$1): Promise<Response> | Response;
50}
51interface HandleDataRequestFunction {
52 (response: Response, args: LoaderFunctionArgs | ActionFunctionArgs): Promise<Response> | Response;
53}
54interface HandleErrorFunction {
55 (error: unknown, args: LoaderFunctionArgs | ActionFunctionArgs): void;
56}
57/**
58 * A module that serves as the entry point for a Remix app during server
59 * rendering.
60 */
61interface ServerEntryModule {
62 default: HandleDocumentRequestFunction;
63 handleDataRequest?: HandleDataRequestFunction;
64 handleError?: HandleErrorFunction;
65 streamTimeout?: number;
66}
67
68/**
69 Resolves a URL against the current location.
70
71 ```tsx
72 import { useHref } from "react-router"
73
74 function SomeComponent() {
75 let href = useHref("some/where");
76 // "/resolved/some/where"
77 }
78 ```
79
80 @category Hooks
81 */
82declare function useHref(to: To, { relative }?: {
83 relative?: RelativeRoutingType;
84}): string;
85/**
86 * Returns true if this component is a descendant of a Router, useful to ensure
87 * a component is used within a Router.
88 *
89 * @category Hooks
90 */
91declare function useInRouterContext(): boolean;
92/**
93 Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
94
95 ```tsx
96 import * as React from 'react'
97 import { useLocation } from 'react-router'
98
99 function SomeComponent() {
100 let location = useLocation()
101
102 React.useEffect(() => {
103 // Google Analytics
104 ga('send', 'pageview')
105 }, [location]);
106
107 return (
108 // ...
109 );
110 }
111 ```
112
113 @category Hooks
114 */
115declare function useLocation(): Location;
116/**
117 * Returns the current navigation action which describes how the router came to
118 * the current location, either by a pop, push, or replace on the history stack.
119 *
120 * @category Hooks
121 */
122declare function useNavigationType(): Action;
123/**
124 * Returns a PathMatch object if the given pattern matches the current URL.
125 * This is useful for components that need to know "active" state, e.g.
126 * `<NavLink>`.
127 *
128 * @category Hooks
129 */
130declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
131/**
132 * The interface for the navigate() function returned from useNavigate().
133 */
134interface NavigateFunction {
135 (to: To, options?: NavigateOptions): void | Promise<void>;
136 (delta: number): void | Promise<void>;
137}
138/**
139 Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
140
141 ```tsx
142 import { useNavigate } from "react-router";
143
144 function SomeComponent() {
145 let navigate = useNavigate();
146 return (
147 <button
148 onClick={() => {
149 navigate(-1);
150 }}
151 />
152 );
153 }
154 ```
155
156 It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
157
158 @category Hooks
159 */
160declare function useNavigate(): NavigateFunction;
161/**
162 * Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
163 *
164 * @category Hooks
165 */
166declare function useOutletContext<Context = unknown>(): Context;
167/**
168 * Returns the element for the child route at this level of the route
169 * hierarchy. Used internally by `<Outlet>` to render child routes.
170 *
171 * @category Hooks
172 */
173declare function useOutlet(context?: unknown): React.ReactElement | null;
174/**
175 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.
176
177 ```tsx
178 import { useParams } from "react-router"
179
180 function SomeComponent() {
181 let params = useParams()
182 params.postId
183 }
184 ```
185
186 Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
187
188 @category Hooks
189 */
190declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
191 ParamsOrKey
192] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
193/**
194 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.
195
196 ```tsx
197 import { useResolvedPath } from "react-router"
198
199 function SomeComponent() {
200 // if the user is at /dashboard/profile
201 let path = useResolvedPath("../accounts")
202 path.pathname // "/dashboard/accounts"
203 path.search // ""
204 path.hash // ""
205 }
206 ```
207
208 @category Hooks
209 */
210declare function useResolvedPath(to: To, { relative }?: {
211 relative?: RelativeRoutingType;
212}): Path;
213/**
214 Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
215
216 The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
217
218 ```tsx
219 import * as React from "react";
220 import { useRoutes } from "react-router";
221
222 function App() {
223 let element = useRoutes([
224 {
225 path: "/",
226 element: <Dashboard />,
227 children: [
228 {
229 path: "messages",
230 element: <DashboardMessages />,
231 },
232 { path: "tasks", element: <DashboardTasks /> },
233 ],
234 },
235 { path: "team", element: <AboutPage /> },
236 ]);
237
238 return element;
239 }
240 ```
241
242 @category Hooks
243 */
244declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
245/**
246 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.
247
248 ```tsx
249 import { useNavigation } from "react-router"
250
251 function SomeComponent() {
252 let navigation = useNavigation();
253 navigation.state
254 navigation.formData
255 // etc.
256 }
257 ```
258
259 @category Hooks
260 */
261declare function useNavigation(): Navigation;
262/**
263 Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
264
265 ```tsx
266 import { useRevalidator } from "react-router";
267
268 function WindowFocusRevalidator() {
269 const revalidator = useRevalidator();
270
271 useFakeWindowFocus(() => {
272 revalidator.revalidate();
273 });
274
275 return (
276 <div hidden={revalidator.state === "idle"}>
277 Revalidating...
278 </div>
279 );
280 }
281 ```
282
283 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.
284
285 @category Hooks
286 */
287declare function useRevalidator(): {
288 revalidate(): Promise<void>;
289 state: RevalidationState;
290};
291/**
292 * Returns the active route matches, useful for accessing loaderData for
293 * parent/child routes or the route "handle" property
294 *
295 * @category Hooks
296 */
297declare function useMatches(): UIMatch[];
298/**
299 Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
300
301 ```tsx
302 import { useLoaderData } from "react-router"
303
304 export async function loader() {
305 return await fakeDb.invoices.findAll();
306 }
307
308 export default function Invoices() {
309 let invoices = useLoaderData<typeof loader>();
310 // ...
311 }
312 ```
313
314 @category Hooks
315 */
316declare function useLoaderData<T = any>(): SerializeFrom<T>;
317/**
318 Returns the loader data for a given route by route ID.
319
320 ```tsx
321 import { useRouteLoaderData } from "react-router";
322
323 function SomeComponent() {
324 const { user } = useRouteLoaderData("root");
325 }
326 ```
327
328 Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
329
330 | Route Filename | Route ID |
331 | -------------------------- | -------------------- |
332 | `app/root.tsx` | `"root"` |
333 | `app/routes/teams.tsx` | `"routes/teams"` |
334 | `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
335
336 If you created an ID manually, you can use that instead:
337
338 ```tsx
339 route("/", "containers/app.tsx", { id: "app" }})
340 ```
341
342 @category Hooks
343 */
344declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
345/**
346 Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
347
348 ```tsx
349 import { Form, useActionData } from "react-router"
350
351 export async function action({ request }) {
352 const body = await request.formData()
353 const name = body.get("visitorsName")
354 return { message: `Hello, ${name}` }
355 }
356
357 export default function Invoices() {
358 const data = useActionData()
359 return (
360 <Form method="post">
361 <input type="text" name="visitorsName" />
362 {data ? data.message : "Waiting..."}
363 </Form>
364 )
365 }
366 ```
367
368 @category Hooks
369 */
370declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
371/**
372 Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
373
374 ```tsx
375 export function ErrorBoundary() {
376 const error = useRouteError();
377 return <div>{error.message}</div>;
378 }
379 ```
380
381 @category Hooks
382 */
383declare function useRouteError(): unknown;
384/**
385 Returns the resolved promise value from the closest {@link Await | `<Await>`}.
386
387 ```tsx
388 function SomeDescendant() {
389 const value = useAsyncValue();
390 // ...
391 }
392
393 // somewhere in your app
394 <Await resolve={somePromise}>
395 <SomeDescendant />
396 </Await>
397 ```
398
399 @category Hooks
400 */
401declare function useAsyncValue(): unknown;
402/**
403 Returns the rejection value from the closest {@link Await | `<Await>`}.
404
405 ```tsx
406 import { Await, useAsyncError } from "react-router"
407
408 function ErrorElement() {
409 const error = useAsyncError();
410 return (
411 <p>Uh Oh, something went wrong! {error.message}</p>
412 );
413 }
414
415 // somewhere in your app
416 <Await
417 resolve={promiseThatRejects}
418 errorElement={<ErrorElement />}
419 />
420 ```
421
422 @category Hooks
423 */
424declare function useAsyncError(): unknown;
425/**
426 * Allow the application to block navigations within the SPA and present the
427 * user a confirmation dialog to confirm the navigation. Mostly used to avoid
428 * using half-filled form data. This does not handle hard-reloads or
429 * cross-origin navigations.
430 *
431 * @category Hooks
432 */
433declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
434
435interface StaticRouterProps {
436 basename?: string;
437 children?: React.ReactNode;
438 location: Partial<Location> | string;
439}
440/**
441 * A `<Router>` that may not navigate to any other location. This is useful
442 * on the server where there is no stateful UI.
443 *
444 * @category Component Routers
445 */
446declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
447interface StaticRouterProviderProps {
448 context: StaticHandlerContext;
449 router: Router;
450 hydrate?: boolean;
451 nonce?: string;
452}
453/**
454 * A Data Router that may not navigate to any other location. This is useful
455 * on the server where there is no stateful UI.
456 *
457 * @category Component Routers
458 */
459declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
460type CreateStaticHandlerOptions = Omit<CreateStaticHandlerOptions$1, "mapRouteProperties">;
461/**
462 * @category Utils
463 */
464declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
465/**
466 * @category Data Routers
467 */
468declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
469 future?: Partial<FutureConfig$1>;
470}): Router;
471
472interface ServerRouterProps {
473 context: EntryContext;
474 url: string | URL;
475 nonce?: string;
476}
477/**
478 * The entry point for a Remix app when it is rendered on the server (in
479 * `app/entry.server.js`). This component is used to generate the HTML in the
480 * response from the server.
481 *
482 * @category Components
483 */
484declare function ServerRouter({ context, url, nonce, }: ServerRouterProps): ReactElement;
485
486interface StubIndexRouteObject extends Omit<IndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
487 loader?: LoaderFunction;
488 action?: ActionFunction;
489 children?: StubRouteObject[];
490 meta?: MetaFunction;
491 links?: LinksFunction;
492}
493interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
494 loader?: LoaderFunction;
495 action?: ActionFunction;
496 children?: StubRouteObject[];
497 meta?: MetaFunction;
498 links?: LinksFunction;
499}
500type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
501interface AppLoadContext {
502 [key: string]: unknown;
503}
504interface RoutesTestStubProps {
505 /**
506 * The initial entries in the history stack. This allows you to start a test with
507 * multiple locations already in the history stack (for testing a back navigation, etc.)
508 * The test will default to the last entry in initialEntries if no initialIndex is provided.
509 * e.g. initialEntries={["/home", "/about", "/contact"]}
510 */
511 initialEntries?: InitialEntry[];
512 /**
513 * The initial index in the history stack to render. This allows you to start a test at a specific entry.
514 * It defaults to the last entry in initialEntries.
515 * e.g.
516 * initialEntries: ["/", "/events/123"]
517 * initialIndex: 1 // start at "/events/123"
518 */
519 initialIndex?: number;
520 /**
521 * Used to set the route's initial loader and action data.
522 * e.g. hydrationData={{
523 * loaderData: { "/contact": { locale: "en-US" } },
524 * actionData: { "/login": { errors: { email: "invalid email" } }}
525 * }}
526 */
527 hydrationData?: HydrationState;
528 /**
529 * Future flags mimicking the settings in react-router.config.ts
530 */
531 future?: Partial<FutureConfig>;
532}
533/**
534 * @category Utils
535 */
536declare function createRoutesStub(routes: StubRouteObject[], context?: AppLoadContext): ({ initialEntries, initialIndex, hydrationData, future, }: RoutesTestStubProps) => React.JSX.Element;
537
538interface CookieSignatureOptions {
539 /**
540 * An array of secrets that may be used to sign/unsign the value of a cookie.
541 *
542 * The array makes it easy to rotate secrets. New secrets should be added to
543 * the beginning of the array. `cookie.serialize()` will always use the first
544 * value in the array, but `cookie.parse()` may use any of them so that
545 * cookies that were signed with older secrets still work.
546 */
547 secrets?: string[];
548}
549type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
550/**
551 * A HTTP cookie.
552 *
553 * A Cookie is a logical container for metadata about a HTTP cookie; its name
554 * and options. But it doesn't contain a value. Instead, it has `parse()` and
555 * `serialize()` methods that allow a single instance to be reused for
556 * parsing/encoding multiple different values.
557 *
558 * @see https://remix.run/utils/cookies#cookie-api
559 */
560interface Cookie {
561 /**
562 * The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
563 */
564 readonly name: string;
565 /**
566 * True if this cookie uses one or more secrets for verification.
567 */
568 readonly isSigned: boolean;
569 /**
570 * The Date this cookie expires.
571 *
572 * Note: This is calculated at access time using `maxAge` when no `expires`
573 * option is provided to `createCookie()`.
574 */
575 readonly expires?: Date;
576 /**
577 * Parses a raw `Cookie` header and returns the value of this cookie or
578 * `null` if it's not present.
579 */
580 parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;
581 /**
582 * Serializes the given value to a string and returns the `Set-Cookie`
583 * header.
584 */
585 serialize(value: any, options?: SerializeOptions): Promise<string>;
586}
587/**
588 * Creates a logical container for managing a browser cookie from the server.
589 */
590declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
591type IsCookieFunction = (object: any) => object is Cookie;
592/**
593 * Returns true if an object is a Remix cookie container.
594 *
595 * @see https://remix.run/utils/cookies#iscookie
596 */
597declare const isCookie: IsCookieFunction;
598
599type RequestHandler = (request: Request, loadContext?: AppLoadContext$1) => Promise<Response>;
600type CreateRequestHandlerFunction = (build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>), mode?: string) => RequestHandler;
601declare const createRequestHandler: CreateRequestHandlerFunction;
602
603/**
604 * An object of name/value pairs to be used in the session.
605 */
606interface SessionData {
607 [name: string]: any;
608}
609/**
610 * Session persists data across HTTP requests.
611 *
612 * @see https://remix.run/utils/sessions#session-api
613 */
614interface Session<Data = SessionData, FlashData = Data> {
615 /**
616 * A unique identifier for this session.
617 *
618 * Note: This will be the empty string for newly created sessions and
619 * sessions that are not backed by a database (i.e. cookie-based sessions).
620 */
621 readonly id: string;
622 /**
623 * The raw data contained in this session.
624 *
625 * This is useful mostly for SessionStorage internally to access the raw
626 * session data to persist.
627 */
628 readonly data: FlashSessionData<Data, FlashData>;
629 /**
630 * Returns `true` if the session has a value for the given `name`, `false`
631 * otherwise.
632 */
633 has(name: (keyof Data | keyof FlashData) & string): boolean;
634 /**
635 * Returns the value for the given `name` in this session.
636 */
637 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;
638 /**
639 * Sets a value in the session for the given `name`.
640 */
641 set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
642 /**
643 * Sets a value in the session that is only valid until the next `get()`.
644 * This can be useful for temporary values, like error messages.
645 */
646 flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
647 /**
648 * Removes a value from the session.
649 */
650 unset(name: keyof Data & string): void;
651}
652type FlashSessionData<Data, FlashData> = Partial<Data & {
653 [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
654}>;
655type FlashDataKey<Key extends string> = `__flash_${Key}__`;
656type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
657/**
658 * Creates a new Session object.
659 *
660 * Note: This function is typically not invoked directly by application code.
661 * Instead, use a `SessionStorage` object's `getSession` method.
662 *
663 * @see https://remix.run/utils/sessions#createsession
664 */
665declare const createSession: CreateSessionFunction;
666type IsSessionFunction = (object: any) => object is Session;
667/**
668 * Returns true if an object is a Remix session.
669 *
670 * @see https://remix.run/utils/sessions#issession
671 */
672declare const isSession: IsSessionFunction;
673/**
674 * SessionStorage stores session data between HTTP requests and knows how to
675 * parse and create cookies.
676 *
677 * A SessionStorage creates Session objects using a `Cookie` header as input.
678 * Then, later it generates the `Set-Cookie` header to be used in the response.
679 */
680interface SessionStorage<Data = SessionData, FlashData = Data> {
681 /**
682 * Parses a Cookie header from a HTTP request and returns the associated
683 * Session. If there is no session associated with the cookie, this will
684 * return a new Session with no data.
685 */
686 getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>;
687 /**
688 * Stores all data in the Session and returns the Set-Cookie header to be
689 * used in the HTTP response.
690 */
691 commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
692 /**
693 * Deletes all data associated with the Session and returns the Set-Cookie
694 * header to be used in the HTTP response.
695 */
696 destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
697}
698/**
699 * SessionIdStorageStrategy is designed to allow anyone to easily build their
700 * own SessionStorage using `createSessionStorage(strategy)`.
701 *
702 * This strategy describes a common scenario where the session id is stored in
703 * a cookie but the actual session data is stored elsewhere, usually in a
704 * database or on disk. A set of create, read, update, and delete operations
705 * are provided for managing the session data.
706 */
707interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
708 /**
709 * The Cookie used to store the session id, or options used to automatically
710 * create one.
711 */
712 cookie?: Cookie | (CookieOptions & {
713 name?: string;
714 });
715 /**
716 * Creates a new record with the given data and returns the session id.
717 */
718 createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
719 /**
720 * Returns data for a given session id, or `null` if there isn't any.
721 */
722 readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
723 /**
724 * Updates data for the given session id.
725 */
726 updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
727 /**
728 * Deletes data for a given session id from the data store.
729 */
730 deleteData: (id: string) => Promise<void>;
731}
732/**
733 * Creates a SessionStorage object using a SessionIdStorageStrategy.
734 *
735 * Note: This is a low-level API that should only be used if none of the
736 * existing session storage options meet your requirements.
737 */
738declare function createSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg, createData, readData, updateData, deleteData, }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
739
740interface CookieSessionStorageOptions {
741 /**
742 * The Cookie used to store the session data on the client, or options used
743 * to automatically create one.
744 */
745 cookie?: SessionIdStorageStrategy["cookie"];
746}
747/**
748 * Creates and returns a SessionStorage object that stores all session data
749 * directly in the session cookie itself.
750 *
751 * This has the advantage that no database or other backend services are
752 * needed, and can help to simplify some load-balanced scenarios. However, it
753 * also has the limitation that serialized session data may not exceed the
754 * browser's maximum cookie size. Trade-offs!
755 */
756declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
757
758interface MemorySessionStorageOptions {
759 /**
760 * The Cookie used to store the session id on the client, or options used
761 * to automatically create one.
762 */
763 cookie?: SessionIdStorageStrategy["cookie"];
764}
765/**
766 * Creates and returns a simple in-memory SessionStorage object, mostly useful
767 * for testing and as a reference implementation.
768 *
769 * Note: This storage does not scale beyond a single process, so it is not
770 * suitable for most production scenarios.
771 */
772declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
773
774type DevServerHooks = {
775 getCriticalCss?: (build: ServerBuild, pathname: string) => Promise<string | undefined>;
776 processRequestError?: (error: unknown) => void;
777};
778declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
779
780declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
781
782type RemixErrorBoundaryProps = React.PropsWithChildren<{
783 location: Location;
784 isOutsideRemixApp?: boolean;
785 error?: Error;
786}>;
787type RemixErrorBoundaryState = {
788 error: null | Error;
789 location: Location;
790};
791declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps, RemixErrorBoundaryState> {
792 constructor(props: RemixErrorBoundaryProps);
793 static getDerivedStateFromError(error: Error): {
794 error: Error;
795 };
796 static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): {
797 error: Error | null;
798 location: Location<any>;
799 };
800 render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
801}
802
803export { ActionFunction, ActionFunctionArgs, AppLoadContext$1 as AppLoadContext, Blocker, BlockerFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params, Path, PathMatch, PathPattern, RelativeRoutingType, type RequestHandler, RevalidationState, RouteObject, RouterState, type RoutesTestStubProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getSingleFetchDataStrategy as UNSAFE_getSingleFetchDataStrategy, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, isCookie, isSession, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };