react-router 7.7.0-pre.1 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +9 -7
  2. package/dist/development/{browser-BSrXyLft.d.mts → browser-CcxeZJcQ.d.mts} +3 -30
  3. package/dist/development/{chunk-6ZHKKNZG.js → chunk-4ADB4KIO.js} +170 -140
  4. package/dist/development/{chunk-YNUF36W5.mjs → chunk-EF7DTUVF.mjs} +52 -22
  5. package/dist/{production/chunk-KZZC37RO.mjs → development/chunk-T3VM44WY.mjs} +31 -26
  6. package/dist/development/{chunk-Z7T4GLA7.js → chunk-V6PEDDZI.js} +1 -1
  7. package/dist/development/components-DzqPLVI1.d.mts +464 -0
  8. package/dist/development/dom-export.d.mts +3 -3
  9. package/dist/development/dom-export.js +3 -3
  10. package/dist/development/dom-export.mjs +3 -3
  11. package/dist/{production/index-react-server-client-DOK8MfYF.d.mts → development/index-react-server-client-CUidsuu_.d.mts} +2 -2
  12. package/dist/development/{index-react-server-client-LrDNRnlX.d.ts → index-react-server-client-kY8DvDF3.d.ts} +177 -529
  13. package/dist/development/index-react-server-client.d.mts +3 -3
  14. package/dist/development/index-react-server-client.d.ts +2 -2
  15. package/dist/development/index-react-server-client.js +10 -4
  16. package/dist/development/index-react-server-client.mjs +9 -3
  17. package/dist/development/index-react-server.js +20 -6
  18. package/dist/development/index-react-server.mjs +21 -6
  19. package/dist/development/index.d.mts +396 -9
  20. package/dist/development/index.d.ts +372 -12
  21. package/dist/development/index.js +131 -120
  22. package/dist/development/index.mjs +9 -3
  23. package/dist/development/lib/types/internal.d.mts +1 -1
  24. package/dist/development/lib/types/internal.d.ts +1 -1
  25. package/dist/development/lib/types/internal.js +1 -1
  26. package/dist/development/lib/types/internal.mjs +1 -1
  27. package/dist/{production/route-data-DAw7Esur.d.mts → development/route-data-DjzmHYNR.d.mts} +1 -1
  28. package/dist/{production/route-data-7aXBQ4I3.d.ts → development/routeModules-g5PTiDfO.d.ts} +156 -156
  29. package/dist/production/{browser-BSrXyLft.d.mts → browser-CcxeZJcQ.d.mts} +3 -30
  30. package/dist/production/{chunk-W77PDD2Y.js → chunk-2TYFPE3B.js} +170 -140
  31. package/dist/production/{chunk-SH44XSL4.js → chunk-5KHO4FML.js} +1 -1
  32. package/dist/{development/chunk-YP7CIEHK.mjs → production/chunk-GNZILI6H.mjs} +31 -26
  33. package/dist/production/{chunk-4FKAWASN.mjs → chunk-WPPIQDYG.mjs} +52 -22
  34. package/dist/production/components-DzqPLVI1.d.mts +464 -0
  35. package/dist/production/dom-export.d.mts +3 -3
  36. package/dist/production/dom-export.js +3 -3
  37. package/dist/production/dom-export.mjs +3 -3
  38. package/dist/{development/index-react-server-client-DOK8MfYF.d.mts → production/index-react-server-client-CUidsuu_.d.mts} +2 -2
  39. package/dist/production/{index-react-server-client-LrDNRnlX.d.ts → index-react-server-client-kY8DvDF3.d.ts} +177 -529
  40. package/dist/production/index-react-server-client.d.mts +3 -3
  41. package/dist/production/index-react-server-client.d.ts +2 -2
  42. package/dist/production/index-react-server-client.js +10 -4
  43. package/dist/production/index-react-server-client.mjs +9 -3
  44. package/dist/production/index-react-server.js +20 -6
  45. package/dist/production/index-react-server.mjs +21 -6
  46. package/dist/production/index.d.mts +396 -9
  47. package/dist/production/index.d.ts +372 -12
  48. package/dist/production/index.js +131 -120
  49. package/dist/production/index.mjs +9 -3
  50. package/dist/production/lib/types/internal.d.mts +1 -1
  51. package/dist/production/lib/types/internal.d.ts +1 -1
  52. package/dist/production/lib/types/internal.js +1 -1
  53. package/dist/production/lib/types/internal.mjs +1 -1
  54. package/dist/{development/route-data-DAw7Esur.d.mts → production/route-data-DjzmHYNR.d.mts} +1 -1
  55. package/dist/{development/route-data-7aXBQ4I3.d.ts → production/routeModules-g5PTiDfO.d.ts} +156 -156
  56. package/package.json +1 -1
  57. package/dist/development/components-IaVqGBuO.d.mts +0 -816
  58. package/dist/production/components-IaVqGBuO.d.mts +0 -816
@@ -1,17 +1,17 @@
1
- import { h as Router, W as RouteModules, D as DataStrategyFunction, I as InitialEntry, H as HydrationState, l as IndexRouteObject, t as LoaderFunction, p as ActionFunction, M as MetaFunction, s as LinksFunction, j as NonIndexRouteObject, X as AppLoadContext, u as unstable_RouterContextProvider, Y as MiddlewareEnabled, Z as unstable_InitialContext, _ as Equal, $ as RouterState, L as Location, n as PatchRoutesOnNavigationFunction, a0 as DataRouteObject, q as ClientLoaderFunction, c as Path } from './route-data-DAw7Esur.mjs';
2
- export { ab as ActionFunctionArgs, a as Blocker, B as BlockerFunction, C as ClientActionFunction, aH as ClientActionFunctionArgs, aI as ClientLoaderFunctionArgs, aF as DataRouteMatch, ac as DataStrategyFunctionArgs, ad as DataStrategyMatch, ae as DataStrategyResult, ag as ErrorResponse, a5 as Fetcher, ah as FormEncType, ai as FormMethod, aN as Future, a2 as GetScrollPositionFunction, a3 as GetScrollRestorationKeyFunction, aj as HTMLFormMethod, aJ as HeadersArgs, r as HeadersFunction, aM as HtmlLinkDescriptor, av as IDLE_BLOCKER, au as IDLE_FETCHER, at as IDLE_NAVIGATION, k as LazyRouteFunction, x as LinkDescriptor, ak as LoaderFunctionArgs, aK as MetaArgs, z as MetaDescriptor, N as NavigateOptions, f as Navigation, a6 as NavigationStates, A as NavigationType, m as Navigator, aL as PageLinkDescriptor, P as ParamParseKey, g as Params, aG as PatchRoutesOnNavigationFunctionArgs, e as PathMatch, am as PathParam, d as PathPattern, an as RedirectFunction, b as RelativeRoutingType, aa as RevalidationState, o as RouteMatch, i as RouteObject, a9 as RouterFetchOptions, R as RouterInit, a8 as RouterNavigateOptions, a7 as RouterSubscriber, v as ShouldRevalidateFunction, ap as ShouldRevalidateFunctionArgs, a1 as StaticHandler, a4 as StaticHandlerContext, T as To, U as UIMatch, aT as UNSAFE_DataRouterContext, aU as UNSAFE_DataRouterStateContext, af as UNSAFE_DataWithResponseInit, aS as UNSAFE_ErrorResponseImpl, aV as UNSAFE_FetchersContext, aW as UNSAFE_LocationContext, aX as UNSAFE_NavigationContext, aY as UNSAFE_RouteContext, aZ as UNSAFE_ViewTransitionContext, aP as UNSAFE_createBrowserHistory, aR as UNSAFE_createRouter, aQ as UNSAFE_invariant, ar as createPath, aw as data, ax as generatePath, ay as isRouteErrorResponse, az as matchPath, aA as matchRoutes, as as parsePath, aB as redirect, aC as redirectDocument, aD as replace, aE as resolvePath, al as unstable_MiddlewareFunction, ao as unstable_RouterContext, aO as unstable_SerializesTo, aq as unstable_createContext } from './route-data-DAw7Esur.mjs';
3
- import { a as RouteComponentType, H as HydrateFallbackType, E as ErrorBoundaryType } from './components-IaVqGBuO.mjs';
4
- export { f as Await, A as AwaitProps, I as IndexRouteProps, L as LayoutRouteProps, g as MemoryRouter, M as MemoryRouterOpts, b as MemoryRouterProps, h as Navigate, q as NavigateFunction, N as NavigateProps, i as Outlet, O as OutletProps, P as PathRouteProps, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, X as UNSAFE_hydrationRouteProperties, Y as UNSAFE_mapRouteProperties, Z as UNSAFE_withComponentProps, $ as UNSAFE_withErrorBoundaryProps, _ as UNSAFE_withHydrateFallbackProps, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, r as renderMatches, s as useActionData, t as useAsyncError, v as useAsyncValue, u as useBlocker, w as useHref, x as useInRouterContext, y as useLoaderData, z as useLocation, B as useMatch, C as useMatches, D as useNavigate, F as useNavigation, G as useNavigationType, J as useOutlet, K as useOutletContext, Q as useParams, S as useResolvedPath, T as useRevalidator, U as useRouteError, V as useRouteLoaderData, W as useRoutes } from './components-IaVqGBuO.mjs';
5
- import { A as AssetsManifest, E as EntryContext, F as FutureConfig, S as ServerBuild } from './index-react-server-client-DOK8MfYF.mjs';
6
- export { l as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, c as FetcherFormProps, h as FetcherSubmitFunction, G as FetcherSubmitOptions, i as FetcherWithComponents, q as Form, d as FormProps, $ as HandleDataRequestFunction, a0 as HandleDocumentRequestFunction, a1 as HandleErrorFunction, m as HashRouter, H as HashRouterProps, a as HistoryRouterProps, n as Link, L as LinkProps, X as Links, W as Meta, p as NavLink, N as NavLinkProps, b as NavLinkRenderProps, P as ParamKeyValuePair, Z as PrefetchPageLinks, Y as Scripts, _ as ScriptsProps, r as ScrollRestoration, e as ScrollRestorationProps, a2 as ServerEntryModule, f as SetURLSearchParams, T as StaticRouter, M as StaticRouterProps, V as StaticRouterProvider, O as StaticRouterProviderProps, g as SubmitFunction, I as SubmitOptions, J as SubmitTarget, a3 as UNSAFE_FrameworkContext, a4 as UNSAFE_createClientRoutes, a5 as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, a6 as UNSAFE_shouldHydrateRouteLoader, a7 as UNSAFE_useScrollRestoration, U as URLSearchParamsInit, j as createBrowserRouter, k as createHashRouter, K as createSearchParams, Q as createStaticHandler, R as createStaticRouter, o as unstable_HistoryRouter, z as unstable_usePrompt, y as useBeforeUnload, w as useFetcher, x as useFetchers, v as useFormAction, u as useLinkClickHandler, s as useSearchParams, t as useSubmit, C as useViewTransitionState } from './index-react-server-client-DOK8MfYF.mjs';
1
+ import { R as Router, y as RouteModules, D as DataStrategyFunction, T as To, z as NavigateOptions, B as BlockerFunction, E as Blocker, J as SerializeFrom, a as RelativeRoutingType, c as Location, K as ParamParseKey, O as Path, Q as PathPattern, V as PathMatch, U as UIMatch, W as Navigation, A as Action, h as Params, f as RouteObject, I as InitialEntry, H as HydrationState, b as IndexRouteObject, m as LoaderFunction, i as ActionFunction, M as MetaFunction, l as LinksFunction, N as NonIndexRouteObject, X as AppLoadContext, u as unstable_RouterContextProvider, Y as MiddlewareEnabled, Z as unstable_InitialContext, _ as Equal, e as RouterInit, $ as RouterState, P as PatchRoutesOnNavigationFunction, a0 as DataRouteObject, j as ClientLoaderFunction } from './route-data-DjzmHYNR.mjs';
2
+ export { ab as ActionFunctionArgs, C as ClientActionFunction, aH as ClientActionFunctionArgs, aI as ClientLoaderFunctionArgs, aF as DataRouteMatch, ac as DataStrategyFunctionArgs, ad as DataStrategyMatch, ae as DataStrategyResult, ag as ErrorResponse, a5 as Fetcher, ah as FormEncType, ai as FormMethod, aN as Future, a2 as GetScrollPositionFunction, a3 as GetScrollRestorationKeyFunction, aj as HTMLFormMethod, aJ as HeadersArgs, k as HeadersFunction, aM as HtmlLinkDescriptor, av as IDLE_BLOCKER, au as IDLE_FETCHER, at as IDLE_NAVIGATION, L as LazyRouteFunction, o as LinkDescriptor, ak as LoaderFunctionArgs, aK as MetaArgs, q as MetaDescriptor, a6 as NavigationStates, d as Navigator, aL as PageLinkDescriptor, aG as PatchRoutesOnNavigationFunctionArgs, am as PathParam, an as RedirectFunction, aa as RevalidationState, g as RouteMatch, a9 as RouterFetchOptions, a8 as RouterNavigateOptions, a7 as RouterSubscriber, S as ShouldRevalidateFunction, ap as ShouldRevalidateFunctionArgs, a1 as StaticHandler, a4 as StaticHandlerContext, aT as UNSAFE_DataRouterContext, aU as UNSAFE_DataRouterStateContext, af as UNSAFE_DataWithResponseInit, aS as UNSAFE_ErrorResponseImpl, aV as UNSAFE_FetchersContext, aW as UNSAFE_LocationContext, aX as UNSAFE_NavigationContext, aY as UNSAFE_RouteContext, aZ as UNSAFE_ViewTransitionContext, aP as UNSAFE_createBrowserHistory, aR as UNSAFE_createRouter, aQ as UNSAFE_invariant, ar as createPath, aw as data, ax as generatePath, ay as isRouteErrorResponse, az as matchPath, aA as matchRoutes, as as parsePath, aB as redirect, aC as redirectDocument, aD as replace, aE as resolvePath, al as unstable_MiddlewareFunction, ao as unstable_RouterContext, aO as unstable_SerializesTo, aq as unstable_createContext } from './route-data-DjzmHYNR.mjs';
3
+ import { a as RouteComponentType, H as HydrateFallbackType, E as ErrorBoundaryType } from './components-DzqPLVI1.mjs';
4
+ export { f as Await, A as AwaitProps, I as IndexRouteProps, L as LayoutRouteProps, g as MemoryRouter, M as MemoryRouterOpts, b as MemoryRouterProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, P as PathRouteProps, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, W as UNSAFE_WithComponentProps, v as UNSAFE_WithErrorBoundaryProps, t as UNSAFE_WithHydrateFallbackProps, q as UNSAFE_hydrationRouteProperties, s as UNSAFE_mapRouteProperties, w as UNSAFE_withComponentProps, x as UNSAFE_withErrorBoundaryProps, u as UNSAFE_withHydrateFallbackProps, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, r as renderMatches } from './components-DzqPLVI1.mjs';
7
5
  import * as React from 'react';
8
6
  import React__default, { ReactElement } from 'react';
7
+ import { A as AssetsManifest, E as EntryContext, F as FutureConfig, S as ServerBuild } from './index-react-server-client-CUidsuu_.mjs';
8
+ export { l as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, c as FetcherFormProps, h as FetcherSubmitFunction, G as FetcherSubmitOptions, i as FetcherWithComponents, q as Form, d as FormProps, $ as HandleDataRequestFunction, a0 as HandleDocumentRequestFunction, a1 as HandleErrorFunction, m as HashRouter, H as HashRouterProps, a as HistoryRouterProps, n as Link, L as LinkProps, X as Links, W as Meta, p as NavLink, N as NavLinkProps, b as NavLinkRenderProps, P as ParamKeyValuePair, Z as PrefetchPageLinks, Y as Scripts, _ as ScriptsProps, r as ScrollRestoration, e as ScrollRestorationProps, a2 as ServerEntryModule, f as SetURLSearchParams, T as StaticRouter, M as StaticRouterProps, V as StaticRouterProvider, O as StaticRouterProviderProps, g as SubmitFunction, I as SubmitOptions, J as SubmitTarget, a3 as UNSAFE_FrameworkContext, a4 as UNSAFE_createClientRoutes, a5 as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, a6 as UNSAFE_shouldHydrateRouteLoader, a7 as UNSAFE_useScrollRestoration, U as URLSearchParamsInit, j as createBrowserRouter, k as createHashRouter, K as createSearchParams, Q as createStaticHandler, R as createStaticRouter, o as unstable_HistoryRouter, z as unstable_usePrompt, y as useBeforeUnload, w as useFetcher, x as useFetchers, v as useFormAction, u as useLinkClickHandler, s as useSearchParams, t as useSubmit, C as useViewTransitionState } from './index-react-server-client-CUidsuu_.mjs';
9
9
  import { ParseOptions, SerializeOptions } from 'cookie';
10
10
  export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
11
11
  import { P as Pages } from './register-DiOIlEq5.mjs';
12
12
  export { a as Register } from './register-DiOIlEq5.mjs';
13
- import { R as RSCPayload, m as matchRSCServerRequest } from './browser-BSrXyLft.mjs';
14
- export { B as unstable_BrowserCreateFromReadableStreamFunction, D as unstable_DecodeActionFunction, b as unstable_DecodeFormStateFunction, d as unstable_DecodeReplyFunction, E as unstable_EncodeReplyFunction, L as unstable_LoadServerActionFunction, a as unstable_RSCHydratedRouter, e as unstable_RSCManifestPayload, f as unstable_RSCMatch, h as unstable_RSCRenderPayload, l as unstable_RSCRouteConfig, k as unstable_RSCRouteConfigEntry, i as unstable_RSCRouteManifest, j as unstable_RSCRouteMatch, c as unstable_createCallServer, g as unstable_getRSCStream } from './browser-BSrXyLft.mjs';
13
+ import { R as RSCPayload, m as matchRSCServerRequest } from './browser-CcxeZJcQ.mjs';
14
+ export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, L as unstable_LoadServerActionFunction, c as unstable_RSCManifestPayload, d as unstable_RSCMatch, e as unstable_RSCRenderPayload, j as unstable_RSCRouteConfig, i as unstable_RSCRouteConfigEntry, f as unstable_RSCRouteManifest, h as unstable_RSCRouteMatch, g as unstable_getRSCStream } from './browser-CcxeZJcQ.mjs';
15
15
  import 'node:async_hooks';
16
16
 
17
17
  declare const SingleFetchRedirectSymbol: unique symbol;
@@ -30,6 +30,373 @@ declare enum ServerMode {
30
30
  Test = "test"
31
31
  }
32
32
 
33
+ /**
34
+ Resolves a URL against the current location.
35
+
36
+ ```tsx
37
+ import { useHref } from "react-router"
38
+
39
+ function SomeComponent() {
40
+ let href = useHref("some/where");
41
+ // "/resolved/some/where"
42
+ }
43
+ ```
44
+
45
+ @category Hooks
46
+ */
47
+ declare function useHref(to: To, { relative }?: {
48
+ relative?: RelativeRoutingType;
49
+ }): string;
50
+ /**
51
+ * Returns true if this component is a descendant of a Router, useful to ensure
52
+ * a component is used within a Router.
53
+ *
54
+ * @category Hooks
55
+ */
56
+ declare function useInRouterContext(): boolean;
57
+ /**
58
+ Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
59
+
60
+ ```tsx
61
+ import * as React from 'react'
62
+ import { useLocation } from 'react-router'
63
+
64
+ function SomeComponent() {
65
+ let location = useLocation()
66
+
67
+ React.useEffect(() => {
68
+ // Google Analytics
69
+ ga('send', 'pageview')
70
+ }, [location]);
71
+
72
+ return (
73
+ // ...
74
+ );
75
+ }
76
+ ```
77
+
78
+ @category Hooks
79
+ */
80
+ declare function useLocation(): Location;
81
+ /**
82
+ * Returns the current navigation action which describes how the router came to
83
+ * the current location, either by a pop, push, or replace on the history stack.
84
+ *
85
+ * @category Hooks
86
+ */
87
+ declare function useNavigationType(): Action;
88
+ /**
89
+ * Returns a PathMatch object if the given pattern matches the current URL.
90
+ * This is useful for components that need to know "active" state, e.g.
91
+ * `<NavLink>`.
92
+ *
93
+ * @category Hooks
94
+ */
95
+ declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
96
+ /**
97
+ * The interface for the navigate() function returned from useNavigate().
98
+ */
99
+ interface NavigateFunction {
100
+ (to: To, options?: NavigateOptions): void | Promise<void>;
101
+ (delta: number): void | Promise<void>;
102
+ }
103
+ /**
104
+ Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
105
+
106
+ ```tsx
107
+ import { useNavigate } from "react-router";
108
+
109
+ function SomeComponent() {
110
+ let navigate = useNavigate();
111
+ return (
112
+ <button
113
+ onClick={() => {
114
+ navigate(-1);
115
+ }}
116
+ />
117
+ );
118
+ }
119
+ ```
120
+
121
+ It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
122
+
123
+ @category Hooks
124
+ */
125
+ declare function useNavigate(): NavigateFunction;
126
+ /**
127
+ * Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
128
+ *
129
+ * @category Hooks
130
+ */
131
+ declare function useOutletContext<Context = unknown>(): Context;
132
+ /**
133
+ * Returns the element for the child route at this level of the route
134
+ * hierarchy. Used internally by `<Outlet>` to render child routes.
135
+ *
136
+ * @category Hooks
137
+ */
138
+ declare function useOutlet(context?: unknown): React.ReactElement | null;
139
+ /**
140
+ 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.
141
+
142
+ ```tsx
143
+ import { useParams } from "react-router"
144
+
145
+ function SomeComponent() {
146
+ let params = useParams()
147
+ params.postId
148
+ }
149
+ ```
150
+
151
+ Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
152
+
153
+ @category Hooks
154
+ */
155
+ declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
156
+ ParamsOrKey
157
+ ] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
158
+ /**
159
+ 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.
160
+
161
+ ```tsx
162
+ import { useResolvedPath } from "react-router"
163
+
164
+ function SomeComponent() {
165
+ // if the user is at /dashboard/profile
166
+ let path = useResolvedPath("../accounts")
167
+ path.pathname // "/dashboard/accounts"
168
+ path.search // ""
169
+ path.hash // ""
170
+ }
171
+ ```
172
+
173
+ @category Hooks
174
+ */
175
+ declare function useResolvedPath(to: To, { relative }?: {
176
+ relative?: RelativeRoutingType;
177
+ }): Path;
178
+ /**
179
+ Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
180
+
181
+ The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
182
+
183
+ ```tsx
184
+ import * as React from "react";
185
+ import { useRoutes } from "react-router";
186
+
187
+ function App() {
188
+ let element = useRoutes([
189
+ {
190
+ path: "/",
191
+ element: <Dashboard />,
192
+ children: [
193
+ {
194
+ path: "messages",
195
+ element: <DashboardMessages />,
196
+ },
197
+ { path: "tasks", element: <DashboardTasks /> },
198
+ ],
199
+ },
200
+ { path: "team", element: <AboutPage /> },
201
+ ]);
202
+
203
+ return element;
204
+ }
205
+ ```
206
+
207
+ @category Hooks
208
+ */
209
+ declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
210
+ /**
211
+ 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.
212
+
213
+ ```tsx
214
+ import { useNavigation } from "react-router"
215
+
216
+ function SomeComponent() {
217
+ let navigation = useNavigation();
218
+ navigation.state
219
+ navigation.formData
220
+ // etc.
221
+ }
222
+ ```
223
+
224
+ @category Hooks
225
+ */
226
+ declare function useNavigation(): Navigation;
227
+ /**
228
+ Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
229
+
230
+ ```tsx
231
+ import { useRevalidator } from "react-router";
232
+
233
+ function WindowFocusRevalidator() {
234
+ const revalidator = useRevalidator();
235
+
236
+ useFakeWindowFocus(() => {
237
+ revalidator.revalidate();
238
+ });
239
+
240
+ return (
241
+ <div hidden={revalidator.state === "idle"}>
242
+ Revalidating...
243
+ </div>
244
+ );
245
+ }
246
+ ```
247
+
248
+ 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.
249
+
250
+ @category Hooks
251
+ */
252
+ declare function useRevalidator(): {
253
+ revalidate: () => Promise<void>;
254
+ state: Router["state"]["revalidation"];
255
+ };
256
+ /**
257
+ * Returns the active route matches, useful for accessing loaderData for
258
+ * parent/child routes or the route "handle" property
259
+ *
260
+ * @category Hooks
261
+ */
262
+ declare function useMatches(): UIMatch[];
263
+ /**
264
+ Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
265
+
266
+ ```tsx
267
+ import { useLoaderData } from "react-router"
268
+
269
+ export async function loader() {
270
+ return await fakeDb.invoices.findAll();
271
+ }
272
+
273
+ export default function Invoices() {
274
+ let invoices = useLoaderData<typeof loader>();
275
+ // ...
276
+ }
277
+ ```
278
+
279
+ @category Hooks
280
+ */
281
+ declare function useLoaderData<T = any>(): SerializeFrom<T>;
282
+ /**
283
+ Returns the loader data for a given route by route ID.
284
+
285
+ ```tsx
286
+ import { useRouteLoaderData } from "react-router";
287
+
288
+ function SomeComponent() {
289
+ const { user } = useRouteLoaderData("root");
290
+ }
291
+ ```
292
+
293
+ Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
294
+
295
+ | Route Filename | Route ID |
296
+ | -------------------------- | -------------------- |
297
+ | `app/root.tsx` | `"root"` |
298
+ | `app/routes/teams.tsx` | `"routes/teams"` |
299
+ | `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
300
+
301
+ If you created an ID manually, you can use that instead:
302
+
303
+ ```tsx
304
+ route("/", "containers/app.tsx", { id: "app" }})
305
+ ```
306
+
307
+ @category Hooks
308
+ */
309
+ declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
310
+ /**
311
+ Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
312
+
313
+ ```tsx
314
+ import { Form, useActionData } from "react-router"
315
+
316
+ export async function action({ request }) {
317
+ const body = await request.formData()
318
+ const name = body.get("visitorsName")
319
+ return { message: `Hello, ${name}` }
320
+ }
321
+
322
+ export default function Invoices() {
323
+ const data = useActionData()
324
+ return (
325
+ <Form method="post">
326
+ <input type="text" name="visitorsName" />
327
+ {data ? data.message : "Waiting..."}
328
+ </Form>
329
+ )
330
+ }
331
+ ```
332
+
333
+ @category Hooks
334
+ */
335
+ declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
336
+ /**
337
+ Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
338
+
339
+ ```tsx
340
+ export function ErrorBoundary() {
341
+ const error = useRouteError();
342
+ return <div>{error.message}</div>;
343
+ }
344
+ ```
345
+
346
+ @category Hooks
347
+ */
348
+ declare function useRouteError(): unknown;
349
+ /**
350
+ Returns the resolved promise value from the closest {@link Await | `<Await>`}.
351
+
352
+ ```tsx
353
+ function SomeDescendant() {
354
+ const value = useAsyncValue();
355
+ // ...
356
+ }
357
+
358
+ // somewhere in your app
359
+ <Await resolve={somePromise}>
360
+ <SomeDescendant />
361
+ </Await>
362
+ ```
363
+
364
+ @category Hooks
365
+ */
366
+ declare function useAsyncValue(): unknown;
367
+ /**
368
+ Returns the rejection value from the closest {@link Await | `<Await>`}.
369
+
370
+ ```tsx
371
+ import { Await, useAsyncError } from "react-router"
372
+
373
+ function ErrorElement() {
374
+ const error = useAsyncError();
375
+ return (
376
+ <p>Uh Oh, something went wrong! {error.message}</p>
377
+ );
378
+ }
379
+
380
+ // somewhere in your app
381
+ <Await
382
+ resolve={promiseThatRejects}
383
+ errorElement={<ErrorElement />}
384
+ />
385
+ ```
386
+
387
+ @category Hooks
388
+ */
389
+ declare function useAsyncError(): unknown;
390
+ /**
391
+ * Allow the application to block navigations within the SPA and present the
392
+ * user a confirmation dialog to confirm the navigation. Mostly used to avoid
393
+ * using half-filled form data. This does not handle hard-reloads or
394
+ * cross-origin navigations.
395
+ *
396
+ * @category Hooks
397
+ */
398
+ declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
399
+
33
400
  interface ServerRouterProps {
34
401
  context: EntryContext;
35
402
  url: string | URL;
@@ -351,6 +718,26 @@ type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {
351
718
  */
352
719
  declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
353
720
 
721
+ type BrowserCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>, { temporaryReferences, }: {
722
+ temporaryReferences: unknown;
723
+ }) => Promise<unknown>;
724
+ type EncodeReplyFunction = (args: unknown[], options: {
725
+ temporaryReferences: unknown;
726
+ }) => Promise<BodyInit>;
727
+ declare function createCallServer({ createFromReadableStream, createTemporaryReferenceSet, encodeReply, fetch: fetchImplementation, }: {
728
+ createFromReadableStream: BrowserCreateFromReadableStreamFunction;
729
+ createTemporaryReferenceSet: () => unknown;
730
+ encodeReply: EncodeReplyFunction;
731
+ fetch?: (request: Request) => Promise<Response>;
732
+ }): (id: string, args: unknown[]) => Promise<unknown>;
733
+ declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload, routeDiscovery, unstable_getContext, }: {
734
+ createFromReadableStream: BrowserCreateFromReadableStreamFunction;
735
+ fetch?: (request: Request) => Promise<Response>;
736
+ payload: RSCPayload;
737
+ routeDiscovery?: "eager" | "lazy";
738
+ unstable_getContext?: RouterInit["unstable_getContext"];
739
+ }): React.JSX.Element;
740
+
354
741
  type SSRCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>) => Promise<unknown>;
355
742
  declare function routeRSCServerRequest({ request, fetchServer, createFromReadableStream, renderHTML, hydrate, }: {
356
743
  request: Request;
@@ -405,4 +792,4 @@ declare function getHydrationData(state: {
405
792
 
406
793
  declare const unstable_matchRSCServerRequest: typeof matchRSCServerRequest;
407
794
 
408
- export { ActionFunction, AppLoadContext, 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, NonIndexRouteObject, PatchRoutesOnNavigationFunction, Path, type RequestHandler, RouterState, type RoutesTestStubProps, ServerBuild, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, 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, unstable_InitialContext, RSCPayload as unstable_RSCPayload, RSCStaticRouter as unstable_RSCStaticRouter, unstable_RouterContextProvider, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks };
795
+ export { 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, RouterInit, 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, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, unstable_InitialContext, RSCHydratedRouter as unstable_RSCHydratedRouter, RSCPayload as unstable_RSCPayload, RSCStaticRouter as unstable_RSCStaticRouter, unstable_RouterContextProvider, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, createCallServer as unstable_createCallServer, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, 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 };