react-router 7.18.0 → 8.0.0-pre.1

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 (285) hide show
  1. package/dist/development/dom-export.d.ts +6 -172
  2. package/dist/development/dom-export.js +12 -1009
  3. package/dist/development/index-react-server-client.d.ts +7 -4
  4. package/dist/development/index-react-server-client.js +8 -52
  5. package/dist/development/index-react-server.d.ts +1650 -1641
  6. package/dist/development/index-react-server.js +2882 -3664
  7. package/dist/development/index.d.ts +42 -1476
  8. package/dist/development/index.js +36 -2553
  9. package/dist/development/lib/actions.js +50 -0
  10. package/dist/development/lib/components.d.ts +1030 -0
  11. package/dist/development/lib/components.js +841 -0
  12. package/dist/development/lib/context.d.ts +83 -0
  13. package/dist/development/lib/context.js +41 -0
  14. package/dist/development/lib/dom/dom.d.ts +119 -0
  15. package/dist/development/lib/dom/dom.js +143 -0
  16. package/dist/development/lib/dom/lib.d.ts +2053 -0
  17. package/dist/development/lib/dom/lib.js +1271 -0
  18. package/dist/development/lib/dom/server.d.ts +138 -0
  19. package/dist/development/lib/dom/server.js +301 -0
  20. package/dist/development/lib/dom/ssr/components.d.ts +198 -0
  21. package/dist/development/lib/dom/ssr/components.js +589 -0
  22. package/dist/development/lib/dom/ssr/data.js +29 -0
  23. package/dist/development/lib/dom/ssr/entry.d.ts +60 -0
  24. package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  25. package/dist/development/lib/dom/ssr/errorBoundaries.js +87 -0
  26. package/dist/development/lib/dom/ssr/fallback.js +33 -0
  27. package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
  28. package/dist/development/lib/dom/ssr/fog-of-war.js +180 -0
  29. package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
  30. package/dist/development/lib/dom/ssr/hydration.js +29 -0
  31. package/dist/development/lib/dom/ssr/invariant.js +16 -0
  32. package/dist/development/lib/dom/ssr/links.js +170 -0
  33. package/dist/development/lib/dom/ssr/markup.js +24 -0
  34. package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
  35. package/dist/development/lib/dom/ssr/routeModules.js +31 -0
  36. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  37. package/dist/development/lib/dom/ssr/routes-test-stub.js +108 -0
  38. package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
  39. package/dist/development/lib/dom/ssr/routes.js +303 -0
  40. package/dist/development/lib/dom/ssr/server.d.ts +48 -0
  41. package/dist/development/lib/dom/ssr/server.js +69 -0
  42. package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
  43. package/dist/development/lib/dom/ssr/single-fetch.js +345 -0
  44. package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
  45. package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
  46. package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
  47. package/dist/development/lib/dom-export/hydrated-router.js +150 -0
  48. package/dist/development/lib/errors.js +29 -0
  49. package/dist/development/lib/hooks.d.ts +947 -0
  50. package/dist/development/lib/hooks.js +1388 -0
  51. package/dist/development/lib/href.d.ts +20 -0
  52. package/dist/development/lib/href.js +50 -0
  53. package/dist/development/lib/router/history.d.ts +258 -0
  54. package/dist/development/lib/router/history.js +372 -0
  55. package/dist/development/lib/router/instrumentation.d.ts +86 -0
  56. package/dist/development/lib/router/instrumentation.js +213 -0
  57. package/dist/development/lib/router/links.d.ts +114 -0
  58. package/dist/development/lib/router/router.d.ts +663 -0
  59. package/dist/development/lib/router/router.js +2988 -0
  60. package/dist/development/lib/router/url.js +18 -0
  61. package/dist/development/lib/router/utils.d.ts +948 -0
  62. package/dist/development/lib/router/utils.js +810 -0
  63. package/dist/development/lib/rsc/browser.d.ts +137 -0
  64. package/dist/development/lib/rsc/browser.js +603 -0
  65. package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
  66. package/dist/development/lib/rsc/errorBoundaries.js +90 -0
  67. package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
  68. package/dist/development/lib/rsc/html-stream/browser.js +74 -0
  69. package/dist/development/lib/rsc/html-stream/server.js +78 -0
  70. package/dist/development/lib/rsc/route-modules.js +27 -0
  71. package/dist/development/lib/rsc/server.rsc.d.ts +219 -0
  72. package/dist/development/lib/rsc/server.ssr.d.ts +129 -0
  73. package/dist/development/lib/rsc/server.ssr.js +404 -0
  74. package/dist/development/lib/server-runtime/build.d.ts +66 -0
  75. package/dist/development/lib/server-runtime/cookies.d.ts +66 -0
  76. package/dist/development/lib/server-runtime/cookies.js +139 -0
  77. package/dist/development/lib/server-runtime/crypto.js +43 -0
  78. package/dist/development/lib/server-runtime/data.d.ts +13 -0
  79. package/dist/development/lib/server-runtime/data.js +25 -0
  80. package/dist/development/lib/server-runtime/dev.d.ts +9 -0
  81. package/dist/development/lib/server-runtime/dev.js +26 -0
  82. package/dist/development/lib/server-runtime/entry.js +20 -0
  83. package/dist/development/lib/server-runtime/errors.js +75 -0
  84. package/dist/development/lib/server-runtime/headers.js +73 -0
  85. package/dist/development/lib/server-runtime/invariant.js +19 -0
  86. package/dist/development/lib/server-runtime/mode.d.ts +12 -0
  87. package/dist/development/lib/server-runtime/mode.js +25 -0
  88. package/dist/development/lib/server-runtime/routeMatching.js +28 -0
  89. package/dist/development/lib/server-runtime/routes.d.ts +13 -0
  90. package/dist/development/lib/server-runtime/routes.js +74 -0
  91. package/dist/development/lib/server-runtime/server.d.ts +10 -0
  92. package/dist/development/lib/server-runtime/server.js +345 -0
  93. package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
  94. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  95. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +45 -0
  96. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  97. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +52 -0
  98. package/dist/development/lib/server-runtime/sessions.d.ts +145 -0
  99. package/dist/development/lib/server-runtime/sessions.js +98 -0
  100. package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
  101. package/dist/development/lib/server-runtime/single-fetch.js +215 -0
  102. package/dist/development/lib/server-runtime/urls.js +28 -0
  103. package/dist/development/lib/server-runtime/warnings.js +20 -0
  104. package/dist/development/lib/types/future.d.ts +9 -0
  105. package/dist/development/lib/types/internal.d.ts +26 -177
  106. package/dist/development/lib/types/internal.js +3 -2
  107. package/dist/development/{register-roq_0qYo.d.ts → lib/types/register.d.ts} +9 -15
  108. package/dist/development/lib/types/route-data.d.ts +113 -0
  109. package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
  110. package/dist/development/lib/types/route-module.d.ts +19 -0
  111. package/dist/development/lib/types/serializes-to.d.ts +13 -0
  112. package/dist/development/lib/types/utils.d.ts +11 -0
  113. package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
  114. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +179 -0
  115. package/dist/development/vendor/turbo-stream-v2/unflatten.js +199 -0
  116. package/dist/development/vendor/turbo-stream-v2/utils.js +39 -0
  117. package/dist/production/dom-export.d.ts +6 -172
  118. package/dist/production/dom-export.js +12 -1009
  119. package/dist/production/index-react-server-client.d.ts +7 -4
  120. package/dist/production/index-react-server-client.js +8 -52
  121. package/dist/production/index-react-server.d.ts +1650 -1641
  122. package/dist/production/index-react-server.js +2873 -3664
  123. package/dist/production/index.d.ts +42 -1476
  124. package/dist/production/index.js +36 -2553
  125. package/dist/production/lib/actions.js +50 -0
  126. package/dist/production/lib/components.d.ts +1030 -0
  127. package/dist/production/lib/components.js +841 -0
  128. package/dist/production/lib/context.d.ts +83 -0
  129. package/dist/production/lib/context.js +41 -0
  130. package/dist/production/lib/dom/dom.d.ts +119 -0
  131. package/dist/production/lib/dom/dom.js +143 -0
  132. package/dist/production/lib/dom/lib.d.ts +2053 -0
  133. package/dist/production/lib/dom/lib.js +1271 -0
  134. package/dist/production/lib/dom/server.d.ts +138 -0
  135. package/dist/production/lib/dom/server.js +301 -0
  136. package/dist/production/lib/dom/ssr/components.d.ts +198 -0
  137. package/dist/production/lib/dom/ssr/components.js +589 -0
  138. package/dist/production/lib/dom/ssr/data.js +29 -0
  139. package/dist/production/lib/dom/ssr/entry.d.ts +60 -0
  140. package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  141. package/dist/production/lib/dom/ssr/errorBoundaries.js +87 -0
  142. package/dist/production/lib/dom/ssr/fallback.js +23 -0
  143. package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
  144. package/dist/production/lib/dom/ssr/fog-of-war.js +180 -0
  145. package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
  146. package/dist/production/lib/dom/ssr/hydration.js +29 -0
  147. package/dist/production/lib/dom/ssr/invariant.js +16 -0
  148. package/dist/production/lib/dom/ssr/links.js +170 -0
  149. package/dist/production/lib/dom/ssr/markup.js +24 -0
  150. package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
  151. package/dist/production/lib/dom/ssr/routeModules.js +31 -0
  152. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  153. package/dist/production/lib/dom/ssr/routes-test-stub.js +108 -0
  154. package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
  155. package/dist/production/lib/dom/ssr/routes.js +303 -0
  156. package/dist/production/lib/dom/ssr/server.d.ts +48 -0
  157. package/dist/production/lib/dom/ssr/server.js +69 -0
  158. package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
  159. package/dist/production/lib/dom/ssr/single-fetch.js +345 -0
  160. package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
  161. package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
  162. package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
  163. package/dist/production/lib/dom-export/hydrated-router.js +150 -0
  164. package/dist/production/lib/errors.js +29 -0
  165. package/dist/production/lib/hooks.d.ts +947 -0
  166. package/dist/production/lib/hooks.js +1373 -0
  167. package/dist/production/lib/href.d.ts +20 -0
  168. package/dist/production/lib/href.js +50 -0
  169. package/dist/production/lib/router/history.d.ts +258 -0
  170. package/dist/production/lib/router/history.js +372 -0
  171. package/dist/production/lib/router/instrumentation.d.ts +86 -0
  172. package/dist/production/lib/router/instrumentation.js +213 -0
  173. package/dist/production/lib/router/links.d.ts +114 -0
  174. package/dist/production/lib/router/router.d.ts +663 -0
  175. package/dist/production/lib/router/router.js +2988 -0
  176. package/dist/production/lib/router/url.js +18 -0
  177. package/dist/production/lib/router/utils.d.ts +948 -0
  178. package/dist/production/lib/router/utils.js +801 -0
  179. package/dist/production/lib/rsc/browser.d.ts +137 -0
  180. package/dist/production/lib/rsc/browser.js +603 -0
  181. package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
  182. package/dist/production/lib/rsc/errorBoundaries.js +90 -0
  183. package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
  184. package/dist/production/lib/rsc/html-stream/browser.js +74 -0
  185. package/dist/production/lib/rsc/html-stream/server.js +78 -0
  186. package/dist/production/lib/rsc/route-modules.js +27 -0
  187. package/dist/production/lib/rsc/server.rsc.d.ts +219 -0
  188. package/dist/production/lib/rsc/server.ssr.d.ts +129 -0
  189. package/dist/production/lib/rsc/server.ssr.js +404 -0
  190. package/dist/production/lib/server-runtime/build.d.ts +66 -0
  191. package/dist/production/lib/server-runtime/cookies.d.ts +66 -0
  192. package/dist/production/lib/server-runtime/cookies.js +139 -0
  193. package/dist/production/lib/server-runtime/crypto.js +43 -0
  194. package/dist/production/lib/server-runtime/data.d.ts +13 -0
  195. package/dist/production/lib/server-runtime/data.js +25 -0
  196. package/dist/production/lib/server-runtime/dev.d.ts +9 -0
  197. package/dist/production/lib/server-runtime/dev.js +26 -0
  198. package/dist/production/lib/server-runtime/entry.js +20 -0
  199. package/dist/production/lib/server-runtime/errors.js +75 -0
  200. package/dist/production/lib/server-runtime/headers.js +73 -0
  201. package/dist/production/lib/server-runtime/invariant.js +19 -0
  202. package/dist/production/lib/server-runtime/mode.d.ts +12 -0
  203. package/dist/production/lib/server-runtime/mode.js +25 -0
  204. package/dist/production/lib/server-runtime/routeMatching.js +28 -0
  205. package/dist/production/lib/server-runtime/routes.d.ts +13 -0
  206. package/dist/production/lib/server-runtime/routes.js +74 -0
  207. package/dist/production/lib/server-runtime/server.d.ts +10 -0
  208. package/dist/production/lib/server-runtime/server.js +345 -0
  209. package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
  210. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  211. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +45 -0
  212. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  213. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +52 -0
  214. package/dist/production/lib/server-runtime/sessions.d.ts +145 -0
  215. package/dist/production/lib/server-runtime/sessions.js +98 -0
  216. package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
  217. package/dist/production/lib/server-runtime/single-fetch.js +215 -0
  218. package/dist/production/lib/server-runtime/urls.js +28 -0
  219. package/dist/production/lib/server-runtime/warnings.js +20 -0
  220. package/dist/production/lib/types/future.d.ts +9 -0
  221. package/dist/production/lib/types/internal.d.ts +26 -177
  222. package/dist/production/lib/types/internal.js +3 -2
  223. package/dist/production/{register-roq_0qYo.d.ts → lib/types/register.d.ts} +9 -15
  224. package/dist/production/lib/types/route-data.d.ts +113 -0
  225. package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
  226. package/dist/production/lib/types/route-module.d.ts +19 -0
  227. package/dist/production/lib/types/serializes-to.d.ts +13 -0
  228. package/dist/production/lib/types/utils.d.ts +11 -0
  229. package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
  230. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +179 -0
  231. package/dist/production/vendor/turbo-stream-v2/unflatten.js +199 -0
  232. package/dist/production/vendor/turbo-stream-v2/utils.js +39 -0
  233. package/docs/explanation/code-splitting.md +16 -0
  234. package/docs/how-to/middleware.md +6 -41
  235. package/docs/how-to/react-server-components.md +1 -1
  236. package/docs/upgrading/future.md +0 -249
  237. package/package.json +43 -87
  238. package/dist/development/browser-B2PdsXXH.d.ts +0 -318
  239. package/dist/development/browser-DBmQ1yAR.d.mts +0 -318
  240. package/dist/development/chunk-4ZMWKKQ3.mjs +0 -11606
  241. package/dist/development/chunk-E4MTK73K.mjs +0 -2517
  242. package/dist/development/chunk-U7ORXROY.js +0 -10307
  243. package/dist/development/chunk-WW7PN6QI.js +0 -188
  244. package/dist/development/chunk-YL5M26XI.js +0 -1366
  245. package/dist/development/context-CeD5LmaF.d.mts +0 -1779
  246. package/dist/development/data-CjO11-hU.d.ts +0 -1740
  247. package/dist/development/data-DEjBmEfD.d.mts +0 -1740
  248. package/dist/development/dom-export.d.mts +0 -172
  249. package/dist/development/dom-export.mjs +0 -1010
  250. package/dist/development/index-react-server-client-3ykjivgQ.d.ts +0 -3677
  251. package/dist/development/index-react-server-client-CACgcj2J.d.mts +0 -2614
  252. package/dist/development/index-react-server-client.d.mts +0 -4
  253. package/dist/development/index-react-server-client.mjs +0 -59
  254. package/dist/development/index-react-server.d.mts +0 -2711
  255. package/dist/development/index-react-server.mjs +0 -3803
  256. package/dist/development/index.d.mts +0 -1479
  257. package/dist/development/index.mjs +0 -275
  258. package/dist/development/instrumentation-Dkmpzd13.d.ts +0 -715
  259. package/dist/development/lib/types/internal.d.mts +0 -184
  260. package/dist/development/lib/types/internal.mjs +0 -10
  261. package/dist/development/register-CmkRspdl.d.mts +0 -30
  262. package/dist/production/browser-B2PdsXXH.d.ts +0 -318
  263. package/dist/production/browser-DBmQ1yAR.d.mts +0 -318
  264. package/dist/production/chunk-3Z6WS2WZ.js +0 -188
  265. package/dist/production/chunk-BIP66BKV.js +0 -1366
  266. package/dist/production/chunk-EGOTSXNH.mjs +0 -2517
  267. package/dist/production/chunk-IUPBOWYO.js +0 -10307
  268. package/dist/production/chunk-M7NGGUU6.mjs +0 -11606
  269. package/dist/production/context-CeD5LmaF.d.mts +0 -1779
  270. package/dist/production/data-CjO11-hU.d.ts +0 -1740
  271. package/dist/production/data-DEjBmEfD.d.mts +0 -1740
  272. package/dist/production/dom-export.d.mts +0 -172
  273. package/dist/production/dom-export.mjs +0 -1010
  274. package/dist/production/index-react-server-client-3ykjivgQ.d.ts +0 -3677
  275. package/dist/production/index-react-server-client-CACgcj2J.d.mts +0 -2614
  276. package/dist/production/index-react-server-client.d.mts +0 -4
  277. package/dist/production/index-react-server-client.mjs +0 -59
  278. package/dist/production/index-react-server.d.mts +0 -2711
  279. package/dist/production/index-react-server.mjs +0 -3803
  280. package/dist/production/index.d.mts +0 -1479
  281. package/dist/production/index.mjs +0 -275
  282. package/dist/production/instrumentation-Dkmpzd13.d.ts +0 -715
  283. package/dist/production/lib/types/internal.d.mts +0 -184
  284. package/dist/production/lib/types/internal.mjs +0 -10
  285. package/dist/production/register-CmkRspdl.d.mts +0 -30
@@ -0,0 +1,2053 @@
1
+
2
+ import { History, To } from "../router/history.js";
3
+ import { DataStrategyFunction, HTMLFormMethod, PatchRoutesOnNavigationFunction, RouteObject } from "../router/utils.js";
4
+ import { BlockerFunction, Fetcher, FutureConfig, GetScrollRestorationKeyFunction, HydrationState, RelativeRoutingType, Router, RouterInit } from "../router/router.js";
5
+ import { NavigateOptions } from "../context.js";
6
+ import { FetcherSubmitOptions, SubmitOptions, SubmitTarget, URLSearchParamsInit } from "./dom.js";
7
+ import { DiscoverBehavior, PrefetchBehavior, ScriptsProps } from "./ssr/components.js";
8
+ import { SerializeFrom } from "../types/route-data.js";
9
+ import { ClientInstrumentation } from "../router/instrumentation.js";
10
+ import * as React$1 from "react";
11
+
12
+ //#region lib/dom/lib.d.ts
13
+ /**
14
+ * @category Data Routers
15
+ */
16
+ interface DOMRouterOpts {
17
+ /**
18
+ * Basename path for the application.
19
+ */
20
+ basename?: string;
21
+ /**
22
+ * A function that returns an {@link RouterContextProvider} instance
23
+ * which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
24
+ * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
25
+ * This function is called to generate a fresh `context` instance on each
26
+ * navigation or fetcher call.
27
+ *
28
+ * ```tsx
29
+ * import {
30
+ * createContext,
31
+ * RouterContextProvider,
32
+ * } from "react-router";
33
+ *
34
+ * const apiClientContext = createContext<APIClient>();
35
+ *
36
+ * function createBrowserRouter(routes, {
37
+ * getContext() {
38
+ * let context = new RouterContextProvider();
39
+ * context.set(apiClientContext, getApiClient());
40
+ * return context;
41
+ * }
42
+ * })
43
+ * ```
44
+ */
45
+ getContext?: RouterInit["getContext"];
46
+ /**
47
+ * Future flags to enable for the router.
48
+ */
49
+ future?: Partial<FutureConfig>;
50
+ /**
51
+ * When Server-Rendering and opting-out of automatic hydration, the
52
+ * `hydrationData` option allows you to pass in hydration data from your
53
+ * server-render. This will almost always be a subset of data from the
54
+ * {@link StaticHandlerContext} value you get back from the {@link StaticHandler}'s
55
+ * `query` method:
56
+ *
57
+ * ```tsx
58
+ * const router = createBrowserRouter(routes, {
59
+ * hydrationData: {
60
+ * loaderData: {
61
+ * // [routeId]: serverLoaderData
62
+ * },
63
+ * // may also include `errors` and/or `actionData`
64
+ * },
65
+ * });
66
+ * ```
67
+ *
68
+ * **Partial Hydration Data**
69
+ *
70
+ * You will almost always include a complete set of `loaderData` to hydrate a
71
+ * server-rendered app. But in advanced use-cases (such as Framework Mode's
72
+ * [`clientLoader`](../../start/framework/route-module#clientLoader)), you may
73
+ * want to include `loaderData` for only some routes that were loaded/rendered
74
+ * on the server. This allows you to hydrate _some_ of the routes (such as the
75
+ * app layout/shell) while showing a `HydrateFallback` component and running
76
+ * the [`loader`](../../start/data/route-object#loader)s for other routes
77
+ * during hydration.
78
+ *
79
+ * A route [`loader`](../../start/data/route-object#loader) will run during
80
+ * hydration in two scenarios:
81
+ *
82
+ * 1. No hydration data is provided
83
+ * In these cases the `HydrateFallback` component will render on initial
84
+ * hydration
85
+ * 2. The `loader.hydrate` property is set to `true`
86
+ * This allows you to run the [`loader`](../../start/data/route-object#loader)
87
+ * even if you did not render a fallback on initial hydration (i.e., to
88
+ * prime a cache with hydration data)
89
+ *
90
+ * ```tsx
91
+ * const router = createBrowserRouter(
92
+ * [
93
+ * {
94
+ * id: "root",
95
+ * loader: rootLoader,
96
+ * Component: Root,
97
+ * children: [
98
+ * {
99
+ * id: "index",
100
+ * loader: indexLoader,
101
+ * HydrateFallback: IndexSkeleton,
102
+ * Component: Index,
103
+ * },
104
+ * ],
105
+ * },
106
+ * ],
107
+ * {
108
+ * hydrationData: {
109
+ * loaderData: {
110
+ * root: "ROOT DATA",
111
+ * // No index data provided
112
+ * },
113
+ * },
114
+ * }
115
+ * );
116
+ * ```
117
+ */
118
+ hydrationData?: HydrationState;
119
+ /**
120
+ * Array of instrumentation objects allowing you to instrument the router and
121
+ * individual routes prior to router initialization (and on any subsequently
122
+ * added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
123
+ * mostly useful for observability such as wrapping navigations, fetches,
124
+ * as well as route loaders/actions/middlewares with logging and/or performance
125
+ * tracing. See the [docs](../../how-to/instrumentation) for more information.
126
+ *
127
+ * ```tsx
128
+ * let router = createBrowserRouter(routes, {
129
+ * instrumentations: [logging]
130
+ * });
131
+ *
132
+ *
133
+ * let logging = {
134
+ * router({ instrument }) {
135
+ * instrument({
136
+ * navigate: (impl, info) => logExecution(`navigate ${info.to}`, impl),
137
+ * fetch: (impl, info) => logExecution(`fetch ${info.to}`, impl)
138
+ * });
139
+ * },
140
+ * route({ instrument, id }) {
141
+ * instrument({
142
+ * middleware: (impl, info) => logExecution(
143
+ * `middleware ${info.request.url} (route ${id})`,
144
+ * impl
145
+ * ),
146
+ * loader: (impl, info) => logExecution(
147
+ * `loader ${info.request.url} (route ${id})`,
148
+ * impl
149
+ * ),
150
+ * action: (impl, info) => logExecution(
151
+ * `action ${info.request.url} (route ${id})`,
152
+ * impl
153
+ * ),
154
+ * })
155
+ * }
156
+ * };
157
+ *
158
+ * async function logExecution(label: string, impl: () => Promise<void>) {
159
+ * let start = performance.now();
160
+ * console.log(`start ${label}`);
161
+ * await impl();
162
+ * let duration = Math.round(performance.now() - start);
163
+ * console.log(`end ${label} (${duration}ms)`);
164
+ * }
165
+ * ```
166
+ */
167
+ instrumentations?: ClientInstrumentation[];
168
+ /**
169
+ * Override the default data strategy of running loaders in parallel -
170
+ * see the [docs](../../how-to/data-strategy) for more information.
171
+ *
172
+ * ```tsx
173
+ * let router = createBrowserRouter(routes, {
174
+ * async dataStrategy({
175
+ * matches,
176
+ * request,
177
+ * runClientMiddleware,
178
+ * }) {
179
+ * const matchesToLoad = matches.filter((m) =>
180
+ * m.shouldCallHandler(),
181
+ * );
182
+ *
183
+ * const results: Record<string, DataStrategyResult> = {};
184
+ * await runClientMiddleware(() =>
185
+ * Promise.all(
186
+ * matchesToLoad.map(async (match) => {
187
+ * results[match.route.id] = await match.resolve();
188
+ * }),
189
+ * ),
190
+ * );
191
+ * return results;
192
+ * },
193
+ * });
194
+ * ```
195
+ */
196
+ dataStrategy?: DataStrategyFunction;
197
+ /**
198
+ * Lazily define portions of the route tree on navigations.
199
+ * See {@link PatchRoutesOnNavigationFunction}.
200
+ *
201
+ * By default, React Router wants you to provide a full route tree up front via
202
+ * `createBrowserRouter(routes)`. This allows React Router to perform synchronous
203
+ * route matching, execute loaders, and then render route components in the most
204
+ * optimistic manner without introducing waterfalls. The tradeoff is that your
205
+ * initial JS bundle is larger by definition — which may slow down application
206
+ * start-up times as your application grows.
207
+ *
208
+ * To combat this, we introduced [`route.lazy`](../../start/data/route-object#lazy)
209
+ * in [v6.9.0](https://github.com/remix-run/react-router/blob/main/CHANGELOG.md#v690)
210
+ * which lets you lazily load the route _implementation_ ([`loader`](../../start/data/route-object#loader),
211
+ * [`Component`](../../start/data/route-object#Component), etc.) while still
212
+ * providing the route _definition_ aspects up front (`path`, `index`, etc.).
213
+ * This is a good middle ground. React Router still knows about your route
214
+ * definitions (the lightweight part) up front and can perform synchronous
215
+ * route matching, but then delay loading any of the route implementation
216
+ * aspects (the heavier part) until the route is actually navigated to.
217
+ *
218
+ * In some cases, even this doesn't go far enough. For huge applications,
219
+ * providing all route definitions up front can be prohibitively expensive.
220
+ * Additionally, it might not even be possible to provide all route definitions
221
+ * up front in certain Micro-Frontend or Module-Federation architectures.
222
+ *
223
+ * This is where `patchRoutesOnNavigation` comes in ([RFC](https://github.com/remix-run/react-router/discussions/11113)).
224
+ * This API is for advanced use-cases where you are unable to provide the full
225
+ * route tree up-front and need a way to lazily "discover" portions of the route
226
+ * tree at runtime. This feature is often referred to as ["Fog of War"](https://en.wikipedia.org/wiki/Fog_of_war),
227
+ * because similar to how video games expand the "world" as you move around -
228
+ * the router would be expanding its routing tree as the user navigated around
229
+ * the app - but would only ever end up loading portions of the tree that the
230
+ * user visited.
231
+ *
232
+ * `patchRoutesOnNavigation` will be called anytime React Router is unable to
233
+ * match a `path`. The arguments include the `path`, any partial `matches`,
234
+ * and a `patch` function you can call to patch new routes into the tree at a
235
+ * specific location. This method is executed during the `loading` portion of
236
+ * the navigation for `GET` requests and during the `submitting` portion of
237
+ * the navigation for non-`GET` requests.
238
+ *
239
+ * <details>
240
+ * <summary><b>Example <code>patchRoutesOnNavigation</code> Use Cases</b></summary>
241
+ *
242
+ * **Patching children into an existing route**
243
+ *
244
+ * ```tsx
245
+ * const router = createBrowserRouter(
246
+ * [
247
+ * {
248
+ * id: "root",
249
+ * path: "/",
250
+ * Component: RootComponent,
251
+ * },
252
+ * ],
253
+ * {
254
+ * async patchRoutesOnNavigation({ patch, path }) {
255
+ * if (path === "/a") {
256
+ * // Load/patch the `a` route as a child of the route with id `root`
257
+ * let route = await getARoute();
258
+ * // ^ { path: 'a', Component: A }
259
+ * patch("root", [route]);
260
+ * }
261
+ * },
262
+ * }
263
+ * );
264
+ * ```
265
+ *
266
+ * In the above example, if the user clicks a link to `/a`, React Router
267
+ * won't match any routes initially and will call `patchRoutesOnNavigation`
268
+ * with a `path = "/a"` and a `matches` array containing the root route
269
+ * match. By calling `patch('root', [route])`, the new route will be added
270
+ * to the route tree as a child of the `root` route and React Router will
271
+ * perform matching on the updated routes. This time it will successfully
272
+ * match the `/a` path and the navigation will complete successfully.
273
+ *
274
+ * **Patching new root-level routes**
275
+ *
276
+ * If you need to patch a new route to the top of the tree (i.e., it doesn't
277
+ * have a parent), you can pass `null` as the `routeId`:
278
+ *
279
+ * ```tsx
280
+ * const router = createBrowserRouter(
281
+ * [
282
+ * {
283
+ * id: "root",
284
+ * path: "/",
285
+ * Component: RootComponent,
286
+ * },
287
+ * ],
288
+ * {
289
+ * async patchRoutesOnNavigation({ patch, path }) {
290
+ * if (path === "/root-sibling") {
291
+ * // Load/patch the `/root-sibling` route as a sibling of the root route
292
+ * let route = await getRootSiblingRoute();
293
+ * // ^ { path: '/root-sibling', Component: RootSibling }
294
+ * patch(null, [route]);
295
+ * }
296
+ * },
297
+ * }
298
+ * );
299
+ * ```
300
+ *
301
+ * **Patching subtrees asynchronously**
302
+ *
303
+ * You can also perform asynchronous matching to lazily fetch entire sections
304
+ * of your application:
305
+ *
306
+ * ```tsx
307
+ * let router = createBrowserRouter(
308
+ * [
309
+ * {
310
+ * path: "/",
311
+ * Component: Home,
312
+ * },
313
+ * ],
314
+ * {
315
+ * async patchRoutesOnNavigation({ patch, path }) {
316
+ * if (path.startsWith("/dashboard")) {
317
+ * let children = await import("./dashboard");
318
+ * patch(null, children);
319
+ * }
320
+ * if (path.startsWith("/account")) {
321
+ * let children = await import("./account");
322
+ * patch(null, children);
323
+ * }
324
+ * },
325
+ * }
326
+ * );
327
+ * ```
328
+ *
329
+ * <docs-info>If in-progress execution of `patchRoutesOnNavigation` is
330
+ * interrupted by a later navigation, then any remaining `patch` calls in
331
+ * the interrupted execution will not update the route tree because the
332
+ * operation was cancelled.</docs-info>
333
+ *
334
+ * **Co-locating route discovery with route definition**
335
+ *
336
+ * If you don't wish to perform your own pseudo-matching, you can leverage
337
+ * the partial `matches` array and the [`handle`](../../start/data/route-object#handle)
338
+ * field on a route to keep the children definitions co-located:
339
+ *
340
+ * ```tsx
341
+ * let router = createBrowserRouter(
342
+ * [
343
+ * {
344
+ * path: "/",
345
+ * Component: Home,
346
+ * },
347
+ * {
348
+ * path: "/dashboard",
349
+ * children: [
350
+ * {
351
+ * // If we want to include /dashboard in the critical routes, we need to
352
+ * // also include it's index route since patchRoutesOnNavigation will not be
353
+ * // called on a navigation to `/dashboard` because it will have successfully
354
+ * // matched the `/dashboard` parent route
355
+ * index: true,
356
+ * // ...
357
+ * },
358
+ * ],
359
+ * handle: {
360
+ * lazyChildren: () => import("./dashboard"),
361
+ * },
362
+ * },
363
+ * {
364
+ * path: "/account",
365
+ * children: [
366
+ * {
367
+ * index: true,
368
+ * // ...
369
+ * },
370
+ * ],
371
+ * handle: {
372
+ * lazyChildren: () => import("./account"),
373
+ * },
374
+ * },
375
+ * ],
376
+ * {
377
+ * async patchRoutesOnNavigation({ matches, patch }) {
378
+ * let leafRoute = matches[matches.length - 1]?.route;
379
+ * if (leafRoute?.handle?.lazyChildren) {
380
+ * let children =
381
+ * await leafRoute.handle.lazyChildren();
382
+ * patch(leafRoute.id, children);
383
+ * }
384
+ * },
385
+ * }
386
+ * );
387
+ * ```
388
+ *
389
+ * **A note on routes with parameters**
390
+ *
391
+ * Because React Router uses ranked routes to find the best match for a
392
+ * given path, there is an interesting ambiguity introduced when only a
393
+ * partial route tree is known at any given point in time. If we match a
394
+ * fully static route such as `path: "/about/contact-us"` then we know we've
395
+ * found the right match since it's composed entirely of static URL segments.
396
+ * Thus, we do not need to bother asking for any other potentially
397
+ * higher-scoring routes.
398
+ *
399
+ * However, routes with parameters (dynamic or splat) can't make this
400
+ * assumption because there might be a not-yet-discovered route that scores
401
+ * higher. Consider a full route tree such as:
402
+ *
403
+ * ```tsx
404
+ * // Assume this is the full route tree for your app
405
+ * const routes = [
406
+ * {
407
+ * path: "/",
408
+ * Component: Home,
409
+ * },
410
+ * {
411
+ * id: "blog",
412
+ * path: "/blog",
413
+ * Component: BlogLayout,
414
+ * children: [
415
+ * { path: "new", Component: NewPost },
416
+ * { path: ":slug", Component: BlogPost },
417
+ * ],
418
+ * },
419
+ * ];
420
+ * ```
421
+ *
422
+ * And then assume we want to use `patchRoutesOnNavigation` to fill this in
423
+ * as the user navigates around:
424
+ *
425
+ * ```tsx
426
+ * // Start with only the index route
427
+ * const router = createBrowserRouter(
428
+ * [
429
+ * {
430
+ * path: "/",
431
+ * Component: Home,
432
+ * },
433
+ * ],
434
+ * {
435
+ * async patchRoutesOnNavigation({ patch, path }) {
436
+ * if (path === "/blog/new") {
437
+ * patch("blog", [
438
+ * {
439
+ * path: "new",
440
+ * Component: NewPost,
441
+ * },
442
+ * ]);
443
+ * } else if (path.startsWith("/blog")) {
444
+ * patch("blog", [
445
+ * {
446
+ * path: ":slug",
447
+ * Component: BlogPost,
448
+ * },
449
+ * ]);
450
+ * }
451
+ * },
452
+ * }
453
+ * );
454
+ * ```
455
+ *
456
+ * If the user were to a blog post first (i.e., `/blog/my-post`) we would
457
+ * patch in the `:slug` route. Then, if the user navigated to `/blog/new` to
458
+ * write a new post, we'd match `/blog/:slug` but it wouldn't be the _right_
459
+ * match! We need to call `patchRoutesOnNavigation` just in case there
460
+ * exists a higher-scoring route we've not yet discovered, which in this
461
+ * case there is.
462
+ *
463
+ * So, anytime React Router matches a path that contains at least one param,
464
+ * it will call `patchRoutesOnNavigation` and match routes again just to
465
+ * confirm it has found the best match.
466
+ *
467
+ * If your `patchRoutesOnNavigation` implementation is expensive or making
468
+ * side effect [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch)
469
+ * calls to a backend server, you may want to consider tracking previously
470
+ * seen routes to avoid over-fetching in cases where you know the proper
471
+ * route has already been found. This can usually be as simple as
472
+ * maintaining a small cache of prior `path` values for which you've already
473
+ * patched in the right routes:
474
+ *
475
+ * ```tsx
476
+ * let discoveredRoutes = new Set();
477
+ *
478
+ * const router = createBrowserRouter(routes, {
479
+ * async patchRoutesOnNavigation({ patch, path }) {
480
+ * if (discoveredRoutes.has(path)) {
481
+ * // We've seen this before so nothing to patch in and we can let the router
482
+ * // use the routes it already knows about
483
+ * return;
484
+ * }
485
+ *
486
+ * discoveredRoutes.add(path);
487
+ *
488
+ * // ... patch routes in accordingly
489
+ * },
490
+ * });
491
+ * ```
492
+ * </details>
493
+ */
494
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
495
+ /**
496
+ * [`Window`](https://developer.mozilla.org/en-US/docs/Web/API/Window) object
497
+ * override. Defaults to the global `window` instance.
498
+ */
499
+ window?: Window;
500
+ }
501
+ /**
502
+ * Create a new {@link DataRouter| data router} that manages the application
503
+ * path via [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
504
+ * and [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState).
505
+ *
506
+ * Data Routers should not be held in React state. You should create your router
507
+ * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}.
508
+ * You can use `patchRoutesOnNavigation` to add additional routes programmatically.
509
+ *
510
+ * @public
511
+ * @category Data Routers
512
+ * @mode data
513
+ * @param routes Application routes
514
+ * @param opts Options
515
+ * @param {DOMRouterOpts.basename} opts.basename n/a
516
+ * @param {DOMRouterOpts.dataStrategy} opts.dataStrategy n/a
517
+ * @param {DOMRouterOpts.future} opts.future n/a
518
+ * @param {DOMRouterOpts.getContext} opts.getContext n/a
519
+ * @param {DOMRouterOpts.hydrationData} opts.hydrationData n/a
520
+ * @param {DOMRouterOpts.instrumentations} opts.instrumentations n/a
521
+ * @param {DOMRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
522
+ * @param {DOMRouterOpts.window} opts.window n/a
523
+ * @returns An initialized {@link DataRouter| data router} to pass to {@link RouterProvider | `<RouterProvider>`}
524
+ */
525
+ declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
526
+ /**
527
+ * Create a new {@link DataRouter| data router} that manages the application
528
+ * path via the URL [`hash`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hash).
529
+ *
530
+ * Data Routers should not be held in React state. You should create your router
531
+ * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}.
532
+ * You can use `patchRoutesOnNavigation` to add additional routes programmatically.
533
+ *
534
+ * @public
535
+ * @category Data Routers
536
+ * @mode data
537
+ * @param routes Application routes
538
+ * @param opts Options
539
+ * @param {DOMRouterOpts.basename} opts.basename n/a
540
+ * @param {DOMRouterOpts.future} opts.future n/a
541
+ * @param {DOMRouterOpts.getContext} opts.getContext n/a
542
+ * @param {DOMRouterOpts.hydrationData} opts.hydrationData n/a
543
+ * @param {DOMRouterOpts.instrumentations} opts.instrumentations n/a
544
+ * @param {DOMRouterOpts.dataStrategy} opts.dataStrategy n/a
545
+ * @param {DOMRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
546
+ * @param {DOMRouterOpts.window} opts.window n/a
547
+ * @returns An initialized {@link DataRouter| data router} to pass to {@link RouterProvider | `<RouterProvider>`}
548
+ */
549
+ declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
550
+ /**
551
+ * @category Types
552
+ */
553
+ interface BrowserRouterProps {
554
+ /**
555
+ * Application basename
556
+ */
557
+ basename?: string;
558
+ /**
559
+ * {@link Route | `<Route>`} components describing your route configuration
560
+ */
561
+ children?: React$1.ReactNode;
562
+ /**
563
+ * Control whether router state updates are internally wrapped in
564
+ * [`React.startTransition`](https://react.dev/reference/react/startTransition).
565
+ *
566
+ * - When left `undefined`, all router state updates are wrapped in
567
+ * `React.startTransition`
568
+ * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
569
+ * in `React.startTransition` and all router state updates are wrapped in
570
+ * `React.startTransition`
571
+ * - When set to `false`, the router will not leverage `React.startTransition`
572
+ * on any navigations or state changes.
573
+ *
574
+ * For more information, please see the [docs](../../explanation/react-transitions).
575
+ */
576
+ useTransitions?: boolean;
577
+ /**
578
+ * [`Window`](https://developer.mozilla.org/en-US/docs/Web/API/Window) object
579
+ * override. Defaults to the global `window` instance
580
+ */
581
+ window?: Window;
582
+ }
583
+ /**
584
+ * A declarative {@link Router | `<Router>`} using the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
585
+ * API for client-side routing.
586
+ *
587
+ * @public
588
+ * @category Declarative Routers
589
+ * @mode declarative
590
+ * @param props Props
591
+ * @param {BrowserRouterProps.basename} props.basename n/a
592
+ * @param {BrowserRouterProps.children} props.children n/a
593
+ * @param {BrowserRouterProps.useTransitions} props.useTransitions n/a
594
+ * @param {BrowserRouterProps.window} props.window n/a
595
+ * @returns A declarative {@link Router | `<Router>`} using the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
596
+ * API for client-side routing.
597
+ */
598
+ declare function BrowserRouter({
599
+ basename,
600
+ children,
601
+ useTransitions,
602
+ window
603
+ }: BrowserRouterProps): React$1.JSX.Element;
604
+ /**
605
+ * @category Types
606
+ */
607
+ interface HashRouterProps {
608
+ /**
609
+ * Application basename
610
+ */
611
+ basename?: string;
612
+ /**
613
+ * {@link Route | `<Route>`} components describing your route configuration
614
+ */
615
+ children?: React$1.ReactNode;
616
+ /**
617
+ * Control whether router state updates are internally wrapped in
618
+ * [`React.startTransition`](https://react.dev/reference/react/startTransition).
619
+ *
620
+ * - When left `undefined`, all router state updates are wrapped in
621
+ * `React.startTransition`
622
+ * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
623
+ * in `React.startTransition` and all router state updates are wrapped in
624
+ * `React.startTransition`
625
+ * - When set to `false`, the router will not leverage `React.startTransition`
626
+ * on any navigations or state changes.
627
+ *
628
+ * For more information, please see the [docs](../../explanation/react-transitions).
629
+ */
630
+ useTransitions?: boolean;
631
+ /**
632
+ * [`Window`](https://developer.mozilla.org/en-US/docs/Web/API/Window) object
633
+ * override. Defaults to the global `window` instance
634
+ */
635
+ window?: Window;
636
+ }
637
+ /**
638
+ * A declarative {@link Router | `<Router>`} that stores the location in the
639
+ * [`hash`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hash) portion
640
+ * of the URL so it is not sent to the server.
641
+ *
642
+ * @public
643
+ * @category Declarative Routers
644
+ * @mode declarative
645
+ * @param props Props
646
+ * @param {HashRouterProps.basename} props.basename n/a
647
+ * @param {HashRouterProps.children} props.children n/a
648
+ * @param {HashRouterProps.useTransitions} props.useTransitions n/a
649
+ * @param {HashRouterProps.window} props.window n/a
650
+ * @returns A declarative {@link Router | `<Router>`} using the URL [`hash`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hash)
651
+ * for client-side routing.
652
+ */
653
+ declare function HashRouter({
654
+ basename,
655
+ children,
656
+ useTransitions,
657
+ window
658
+ }: HashRouterProps): React$1.JSX.Element;
659
+ /**
660
+ * @category Types
661
+ */
662
+ interface HistoryRouterProps {
663
+ /**
664
+ * Application basename
665
+ */
666
+ basename?: string;
667
+ /**
668
+ * {@link Route | `<Route>`} components describing your route configuration
669
+ */
670
+ children?: React$1.ReactNode;
671
+ /**
672
+ * A {@link History} implementation for use by the router
673
+ */
674
+ history: History;
675
+ /**
676
+ * Control whether router state updates are internally wrapped in
677
+ * [`React.startTransition`](https://react.dev/reference/react/startTransition).
678
+ *
679
+ * - When left `undefined`, all router state updates are wrapped in
680
+ * `React.startTransition`
681
+ * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
682
+ * in `React.startTransition` and all router state updates are wrapped in
683
+ * `React.startTransition`
684
+ * - When set to `false`, the router will not leverage `React.startTransition`
685
+ * on any navigations or state changes.
686
+ *
687
+ * For more information, please see the [docs](../../explanation/react-transitions).
688
+ */
689
+ useTransitions?: boolean;
690
+ }
691
+ /**
692
+ * A declarative {@link Router | `<Router>`} that accepts a pre-instantiated
693
+ * `history` object.
694
+ * It's important to note that using your own `history` object is highly discouraged
695
+ * and may add two versions of the `history` library to your bundles unless you use
696
+ * the same version of the `history` library that React Router uses internally.
697
+ *
698
+ * @name unstable_HistoryRouter
699
+ * @public
700
+ * @category Declarative Routers
701
+ * @mode declarative
702
+ * @param props Props
703
+ * @param {HistoryRouterProps.basename} props.basename n/a
704
+ * @param {HistoryRouterProps.children} props.children n/a
705
+ * @param {HistoryRouterProps.history} props.history n/a
706
+ * @param {HistoryRouterProps.useTransitions} props.useTransitions n/a
707
+ * @returns A declarative {@link Router | `<Router>`} using the provided history
708
+ * implementation for client-side routing.
709
+ */
710
+ declare function HistoryRouter({
711
+ basename,
712
+ children,
713
+ history,
714
+ useTransitions
715
+ }: HistoryRouterProps): React$1.JSX.Element;
716
+ declare namespace HistoryRouter {
717
+ var displayName: string;
718
+ }
719
+ /**
720
+ * @category Types
721
+ */
722
+ interface LinkProps extends Omit<React$1.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
723
+ /**
724
+ * Defines the link [lazy route discovery](../../explanation/lazy-route-discovery) behavior.
725
+ *
726
+ * - **render** — default, discover the route when the link renders
727
+ * - **none** — don't eagerly discover, only discover if the link is clicked
728
+ *
729
+ * ```tsx
730
+ * <Link /> // default ("render")
731
+ * <Link discover="render" />
732
+ * <Link discover="none" />
733
+ * ```
734
+ */
735
+ discover?: DiscoverBehavior;
736
+ /**
737
+ * Defines the data and module prefetching behavior for the link.
738
+ *
739
+ * ```tsx
740
+ * <Link /> // default
741
+ * <Link prefetch="none" />
742
+ * <Link prefetch="intent" />
743
+ * <Link prefetch="render" />
744
+ * <Link prefetch="viewport" />
745
+ * ```
746
+ *
747
+ * - **none** — default, no prefetching
748
+ * - **intent** — prefetches when the user hovers or focuses the link
749
+ * - **render** — prefetches when the link renders
750
+ * - **viewport** — prefetches when the link is in the viewport, very useful for mobile
751
+ *
752
+ * Prefetching is done with HTML [`<link rel="prefetch">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
753
+ * tags. They are inserted after the link.
754
+ *
755
+ * ```tsx
756
+ * <a href="..." />
757
+ * <a href="..." />
758
+ * <link rel="prefetch" /> // might conditionally render
759
+ * ```
760
+ *
761
+ * Because of this, if you are using `nav :last-child` you will need to use
762
+ * `nav :last-of-type` so the styles don't conditionally fall off your last link
763
+ * (and any other similar selectors).
764
+ */
765
+ prefetch?: PrefetchBehavior;
766
+ /**
767
+ * Will use document navigation instead of client side routing when the link is
768
+ * clicked: the browser will handle the transition normally (as if it were an
769
+ * [`<a href>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)).
770
+ *
771
+ * ```tsx
772
+ * <Link to="/logout" reloadDocument />
773
+ * ```
774
+ */
775
+ reloadDocument?: boolean;
776
+ /**
777
+ * Replaces the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
778
+ * stack instead of pushing a new one onto it.
779
+ *
780
+ * ```tsx
781
+ * <Link replace />
782
+ * ```
783
+ *
784
+ * ```
785
+ * # with a history stack like this
786
+ * A -> B
787
+ *
788
+ * # normal link click pushes a new entry
789
+ * A -> B -> C
790
+ *
791
+ * # but with `replace`, B is replaced by C
792
+ * A -> C
793
+ * ```
794
+ */
795
+ replace?: boolean;
796
+ /**
797
+ * Adds persistent client side routing state to the next location.
798
+ *
799
+ * ```tsx
800
+ * <Link to="/somewhere/else" state={{ some: "value" }} />
801
+ * ```
802
+ *
803
+ * The location state is accessed from the `location`.
804
+ *
805
+ * ```tsx
806
+ * function SomeComp() {
807
+ * const location = useLocation();
808
+ * location.state; // { some: "value" }
809
+ * }
810
+ * ```
811
+ *
812
+ * This state is inaccessible on the server as it is implemented on top of
813
+ * [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
814
+ */
815
+ state?: any;
816
+ /**
817
+ * Prevents the scroll position from being reset to the top of the window when
818
+ * the link is clicked and the app is using {@link ScrollRestoration}. This only
819
+ * prevents new locations resetting scroll to the top, scroll position will be
820
+ * restored for back/forward button navigation.
821
+ *
822
+ * ```tsx
823
+ * <Link to="?tab=one" preventScrollReset />
824
+ * ```
825
+ */
826
+ preventScrollReset?: boolean;
827
+ /**
828
+ * Defines the relative path behavior for the link.
829
+ *
830
+ * ```tsx
831
+ * <Link to=".." /> // default: "route"
832
+ * <Link relative="route" />
833
+ * <Link relative="path" />
834
+ * ```
835
+ *
836
+ * Consider a route hierarchy where a parent route pattern is `"blog"` and a child
837
+ * route pattern is `"blog/:slug/edit"`.
838
+ *
839
+ * - **route** — default, resolves the link relative to the route pattern. In the
840
+ * example above, a relative link of `"..."` will remove both `:slug/edit` segments
841
+ * back to `"/blog"`.
842
+ * - **path** — relative to the path so `"..."` will only remove one URL segment up
843
+ * to `"/blog/:slug"`
844
+ *
845
+ * Note that index routes and layout routes do not have paths so they are not
846
+ * included in the relative path calculation.
847
+ */
848
+ relative?: RelativeRoutingType;
849
+ /**
850
+ * Can be a string or a partial {@link Path}:
851
+ *
852
+ * ```tsx
853
+ * <Link to="/some/path" />
854
+ *
855
+ * <Link
856
+ * to={{
857
+ * pathname: "/some/path",
858
+ * search: "?query=string",
859
+ * hash: "#hash",
860
+ * }}
861
+ * />
862
+ * ```
863
+ */
864
+ to: To;
865
+ /**
866
+ * Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
867
+ * for this navigation.
868
+ *
869
+ * ```jsx
870
+ * <Link to={to} viewTransition>
871
+ * Click me
872
+ * </Link>
873
+ * ```
874
+ *
875
+ * To apply specific styles for the transition, see {@link useViewTransitionState}
876
+ */
877
+ viewTransition?: boolean;
878
+ /**
879
+ * Specify the default revalidation behavior for the navigation.
880
+ *
881
+ * ```tsx
882
+ * <Link to="/some/path" defaultShouldRevalidate={false} />
883
+ * ```
884
+ *
885
+ * If no `shouldRevalidate` functions are present on the active routes, then this
886
+ * value will be used directly. Otherwise it will be passed into `shouldRevalidate`
887
+ * so the route can make the final determination on revalidation. This can be
888
+ * useful when updating search params and you don't want to trigger a revalidation.
889
+ *
890
+ * By default (when not specified), loaders will revalidate according to the routers
891
+ * standard revalidation behavior.
892
+ */
893
+ defaultShouldRevalidate?: boolean;
894
+ /**
895
+ * Masked path for this navigation, when you want to navigate the router to
896
+ * one location but display a separate location in the URL bar.
897
+ *
898
+ * This is useful for contextual navigations such as opening an image in a modal
899
+ * on top of a gallery while keeping the underlying gallery active. If a user
900
+ * shares the masked URL, or opens the link in a new tab, they will only load
901
+ * the masked location without the underlying contextual location.
902
+ *
903
+ * This feature relies on `history.state` and is thus only intended for SPA uses
904
+ * and SSR renders will not respect the masking.
905
+ *
906
+ * ```tsx
907
+ * // routes/gallery.tsx
908
+ * export function clientLoader({ request }: Route.LoaderArgs) {
909
+ * let sp = new URL(request.url).searchParams;
910
+ * return {
911
+ * images: getImages(),
912
+ * modalImage: sp.has("image") ? getImage(sp.get("image")!) : null,
913
+ * };
914
+ * }
915
+ *
916
+ * export default function Gallery({ loaderData }: Route.ComponentProps) {
917
+ * return (
918
+ * <>
919
+ * <GalleryGrid>
920
+ * {loaderData.images.map((image) => (
921
+ * <Link
922
+ * key={image.id}
923
+ * to={`/gallery?image=${image.id}`}
924
+ * mask={`/images/${image.id}`}
925
+ * >
926
+ * <img src={image.url} alt={image.alt} />
927
+ * </Link>
928
+ * ))}
929
+ * </GalleryGrid>
930
+ *
931
+ * {data.modalImage ? (
932
+ * <dialog open>
933
+ * <img src={data.modalImage.url} alt={data.modalImage.alt} />
934
+ * </dialog>
935
+ * ) : null}
936
+ * </>
937
+ * );
938
+ * }
939
+ * ```
940
+ */
941
+ mask?: To;
942
+ }
943
+ /**
944
+ * A progressively enhanced [`<a href>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)
945
+ * wrapper to enable navigation with client-side routing.
946
+ *
947
+ * @example
948
+ * import { Link } from "react-router";
949
+ *
950
+ * <Link to="/dashboard">Dashboard</Link>;
951
+ *
952
+ * <Link
953
+ * to={{
954
+ * pathname: "/some/path",
955
+ * search: "?query=string",
956
+ * hash: "#hash",
957
+ * }}
958
+ * />;
959
+ *
960
+ * @public
961
+ * @category Components
962
+ * @param {LinkProps.discover} props.discover [modes: framework] n/a
963
+ * @param {LinkProps.prefetch} props.prefetch [modes: framework] n/a
964
+ * @param {LinkProps.preventScrollReset} props.preventScrollReset [modes: framework, data] n/a
965
+ * @param {LinkProps.relative} props.relative n/a
966
+ * @param {LinkProps.reloadDocument} props.reloadDocument n/a
967
+ * @param {LinkProps.replace} props.replace n/a
968
+ * @param {LinkProps.state} props.state n/a
969
+ * @param {LinkProps.to} props.to n/a
970
+ * @param {LinkProps.viewTransition} props.viewTransition [modes: framework, data] n/a
971
+ * @param {LinkProps.defaultShouldRevalidate} props.defaultShouldRevalidate n/a
972
+ * @param {LinkProps.mask} props.mask [modes: framework, data] n/a
973
+ */
974
+ declare const Link: React$1.ForwardRefExoticComponent<LinkProps & React$1.RefAttributes<HTMLAnchorElement>>;
975
+ /**
976
+ * The object passed to {@link NavLink} `children`, `className`, and `style` prop
977
+ * callbacks to render and style the link based on its state.
978
+ *
979
+ * ```
980
+ * // className
981
+ * <NavLink
982
+ * to="/messages"
983
+ * className={({ isActive, isPending }) =>
984
+ * isPending ? "pending" : isActive ? "active" : ""
985
+ * }
986
+ * >
987
+ * Messages
988
+ * </NavLink>
989
+ *
990
+ * // style
991
+ * <NavLink
992
+ * to="/messages"
993
+ * style={({ isActive, isPending }) => {
994
+ * return {
995
+ * fontWeight: isActive ? "bold" : "",
996
+ * color: isPending ? "red" : "black",
997
+ * }
998
+ * )}
999
+ * />
1000
+ *
1001
+ * // children
1002
+ * <NavLink to="/tasks">
1003
+ * {({ isActive, isPending }) => (
1004
+ * <span className={isActive ? "active" : ""}>Tasks</span>
1005
+ * )}
1006
+ * </NavLink>
1007
+ * ```
1008
+ *
1009
+ */
1010
+ type NavLinkRenderProps = {
1011
+ /**
1012
+ * Indicates if the link's URL matches the current {@link Location}.
1013
+ */
1014
+ isActive: boolean;
1015
+ /**
1016
+ * Indicates if the pending {@link Location} matches the link's URL. Only
1017
+ * available in Framework/Data modes.
1018
+ */
1019
+ isPending: boolean;
1020
+ /**
1021
+ * Indicates if a view transition to the link's URL is in progress.
1022
+ * See {@link useViewTransitionState}
1023
+ */
1024
+ isTransitioning: boolean;
1025
+ };
1026
+ /**
1027
+ * @category Types
1028
+ */
1029
+ interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
1030
+ /**
1031
+ * Can be regular React children or a function that receives an object with the
1032
+ * `active` and `pending` states of the link.
1033
+ *
1034
+ * ```tsx
1035
+ * <NavLink to="/tasks">
1036
+ * {({ isActive }) => (
1037
+ * <span className={isActive ? "active" : ""}>Tasks</span>
1038
+ * )}
1039
+ * </NavLink>
1040
+ * ```
1041
+ */
1042
+ children?: React$1.ReactNode | ((props: NavLinkRenderProps) => React$1.ReactNode);
1043
+ /**
1044
+ * Changes the matching logic to make it case-sensitive:
1045
+ *
1046
+ * | Link | URL | isActive |
1047
+ * | -------------------------------------------- | ------------- | -------- |
1048
+ * | `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
1049
+ * | `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
1050
+ */
1051
+ caseSensitive?: boolean;
1052
+ /**
1053
+ * Classes are automatically applied to `NavLink` that correspond to the state.
1054
+ *
1055
+ * ```css
1056
+ * a.active {
1057
+ * color: red;
1058
+ * }
1059
+ * a.pending {
1060
+ * color: blue;
1061
+ * }
1062
+ * a.transitioning {
1063
+ * view-transition-name: my-transition;
1064
+ * }
1065
+ * ```
1066
+ *
1067
+ * Or you can specify a function that receives {@link NavLinkRenderProps} and
1068
+ * returns the `className`:
1069
+ *
1070
+ * ```tsx
1071
+ * <NavLink className={({ isActive, isPending }) => (
1072
+ * isActive ? "my-active-class" :
1073
+ * isPending ? "my-pending-class" :
1074
+ * ""
1075
+ * )} />
1076
+ * ```
1077
+ */
1078
+ className?: string | ((props: NavLinkRenderProps) => string | undefined);
1079
+ /**
1080
+ * Changes the matching logic for the `active` and `pending` states to only match
1081
+ * to the "end" of the {@link NavLinkProps.to}. If the URL is longer, it will no
1082
+ * longer be considered active.
1083
+ *
1084
+ * | Link | URL | isActive |
1085
+ * | ----------------------------- | ------------ | -------- |
1086
+ * | `<NavLink to="/tasks" />` | `/tasks` | true |
1087
+ * | `<NavLink to="/tasks" />` | `/tasks/123` | true |
1088
+ * | `<NavLink to="/tasks" end />` | `/tasks` | true |
1089
+ * | `<NavLink to="/tasks" end />` | `/tasks/123` | false |
1090
+ *
1091
+ * `<NavLink to="/">` is an exceptional case because _every_ URL matches `/`.
1092
+ * To avoid this matching every single route by default, it effectively ignores
1093
+ * the `end` prop and only matches when you're at the root route.
1094
+ */
1095
+ end?: boolean;
1096
+ /**
1097
+ * Styles can also be applied dynamically via a function that receives
1098
+ * {@link NavLinkRenderProps} and returns the styles:
1099
+ *
1100
+ * ```tsx
1101
+ * <NavLink to="/tasks" style={{ color: "red" }} />
1102
+ * <NavLink to="/tasks" style={({ isActive, isPending }) => ({
1103
+ * color:
1104
+ * isActive ? "red" :
1105
+ * isPending ? "blue" : "black"
1106
+ * })} />
1107
+ * ```
1108
+ */
1109
+ style?: React$1.CSSProperties | ((props: NavLinkRenderProps) => React$1.CSSProperties | undefined);
1110
+ }
1111
+ /**
1112
+ * Wraps {@link Link | `<Link>`} with additional props for styling active and
1113
+ * pending states.
1114
+ *
1115
+ * - Automatically applies classes to the link based on its `active` and `pending`
1116
+ * states, see {@link NavLinkProps.className}
1117
+ * - Note that `pending` is only available with Framework and Data modes.
1118
+ * - Automatically applies `aria-current="page"` to the link when the link is active.
1119
+ * See [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
1120
+ * on MDN.
1121
+ * - States are additionally available through the className, style, and children
1122
+ * render props. See {@link NavLinkRenderProps}.
1123
+ *
1124
+ * @example
1125
+ * <NavLink to="/message">Messages</NavLink>
1126
+ *
1127
+ * // Using render props
1128
+ * <NavLink
1129
+ * to="/messages"
1130
+ * className={({ isActive, isPending }) =>
1131
+ * isPending ? "pending" : isActive ? "active" : ""
1132
+ * }
1133
+ * >
1134
+ * Messages
1135
+ * </NavLink>
1136
+ *
1137
+ * @public
1138
+ * @category Components
1139
+ * @param {NavLinkProps.caseSensitive} props.caseSensitive n/a
1140
+ * @param {NavLinkProps.children} props.children n/a
1141
+ * @param {NavLinkProps.className} props.className n/a
1142
+ * @param {NavLinkProps.discover} props.discover [modes: framework] n/a
1143
+ * @param {NavLinkProps.end} props.end n/a
1144
+ * @param {NavLinkProps.prefetch} props.prefetch [modes: framework] n/a
1145
+ * @param {NavLinkProps.preventScrollReset} props.preventScrollReset [modes: framework, data] n/a
1146
+ * @param {NavLinkProps.relative} props.relative n/a
1147
+ * @param {NavLinkProps.reloadDocument} props.reloadDocument n/a
1148
+ * @param {NavLinkProps.replace} props.replace n/a
1149
+ * @param {NavLinkProps.state} props.state n/a
1150
+ * @param {NavLinkProps.style} props.style n/a
1151
+ * @param {NavLinkProps.to} props.to n/a
1152
+ * @param {NavLinkProps.viewTransition} props.viewTransition [modes: framework, data] n/a
1153
+ */
1154
+ declare const NavLink: React$1.ForwardRefExoticComponent<NavLinkProps & React$1.RefAttributes<HTMLAnchorElement>>;
1155
+ /**
1156
+ * Form props shared by navigations and fetchers
1157
+ */
1158
+ interface SharedFormProps extends React$1.FormHTMLAttributes<HTMLFormElement> {
1159
+ /**
1160
+ * The HTTP verb to use when the form is submitted. Supports `"delete"`,
1161
+ * `"get"`, `"patch"`, `"post"`, and `"put"`.
1162
+ *
1163
+ * Native [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
1164
+ * only supports `"get"` and `"post"`, avoid the other verbs if you'd like to
1165
+ * support progressive enhancement
1166
+ */
1167
+ method?: HTMLFormMethod;
1168
+ /**
1169
+ * The encoding type to use for the form submission.
1170
+ *
1171
+ * ```tsx
1172
+ * <Form encType="application/x-www-form-urlencoded"/> // Default
1173
+ * <Form encType="multipart/form-data"/>
1174
+ * <Form encType="text/plain"/>
1175
+ * ```
1176
+ */
1177
+ encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
1178
+ /**
1179
+ * The URL to submit the form data to. If `undefined`, this defaults to the
1180
+ * closest route in context.
1181
+ */
1182
+ action?: string;
1183
+ /**
1184
+ * Determines whether the form action is relative to the route hierarchy or
1185
+ * the pathname. Use this if you want to opt out of navigating the route
1186
+ * hierarchy and want to instead route based on slash-delimited URL segments.
1187
+ * See {@link RelativeRoutingType}.
1188
+ */
1189
+ relative?: RelativeRoutingType;
1190
+ /**
1191
+ * Prevent the scroll position from resetting to the top of the viewport on
1192
+ * completion of the navigation when using the
1193
+ * {@link ScrollRestoration | `<ScrollRestoration>`} component
1194
+ */
1195
+ preventScrollReset?: boolean;
1196
+ /**
1197
+ * Specify the default revalidation behavior after this submission
1198
+ *
1199
+ * If no `shouldRevalidate` functions are present on the active routes, then this
1200
+ * value will be used directly. Otherwise it will be passed into `shouldRevalidate`
1201
+ * so the route can make the final determination on revalidation. This can be
1202
+ * useful when updating search params and you don't want to trigger a revalidation.
1203
+ *
1204
+ * By default (when not specified), loaders will revalidate according to the routers
1205
+ * standard revalidation behavior.
1206
+ */
1207
+ defaultShouldRevalidate?: boolean;
1208
+ }
1209
+ /**
1210
+ * Form props available to fetchers
1211
+ * @category Types
1212
+ */
1213
+ interface FetcherFormProps extends SharedFormProps {}
1214
+ /**
1215
+ * Form props available to navigations
1216
+ * @category Types
1217
+ */
1218
+ interface FormProps extends SharedFormProps {
1219
+ /**
1220
+ * Defines the form [lazy route discovery](../../explanation/lazy-route-discovery) behavior.
1221
+ *
1222
+ * - **render** — default, discover the route when the form renders
1223
+ * - **none** — don't eagerly discover, only discover if the form is submitted
1224
+ *
1225
+ * ```tsx
1226
+ * <Form /> // default ("render")
1227
+ * <Form discover="render" />
1228
+ * <Form discover="none" />
1229
+ * ```
1230
+ */
1231
+ discover?: DiscoverBehavior;
1232
+ /**
1233
+ * Indicates a specific fetcherKey to use when using `navigate={false}` so you
1234
+ * can pick up the fetcher's state in a different component in a {@link useFetcher}.
1235
+ */
1236
+ fetcherKey?: string;
1237
+ /**
1238
+ * When `false`, skips the navigation and submits via a fetcher internally.
1239
+ * This is essentially a shorthand for {@link useFetcher} + `<fetcher.Form>` where
1240
+ * you don't care about the resulting data in this component.
1241
+ */
1242
+ navigate?: boolean;
1243
+ /**
1244
+ * Forces a full document navigation instead of client side routing and data
1245
+ * fetch.
1246
+ */
1247
+ reloadDocument?: boolean;
1248
+ /**
1249
+ * Replaces the current entry in the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1250
+ * stack when the form navigates. Use this if you don't want the user to be
1251
+ * able to click "back" to the page with the form on it.
1252
+ */
1253
+ replace?: boolean;
1254
+ /**
1255
+ * State object to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1256
+ * stack entry for this navigation
1257
+ */
1258
+ state?: any;
1259
+ /**
1260
+ * Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1261
+ * for this navigation. To apply specific styles during the transition, see
1262
+ * {@link useViewTransitionState}.
1263
+ */
1264
+ viewTransition?: boolean;
1265
+ }
1266
+ /**
1267
+ * A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
1268
+ * that submits data to actions via [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch),
1269
+ * activating pending states in {@link useNavigation} which enables advanced
1270
+ * user interfaces beyond a basic HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
1271
+ * After a form's `action` completes, all data on the page is automatically
1272
+ * revalidated to keep the UI in sync with the data.
1273
+ *
1274
+ * Because it uses the HTML form API, server rendered pages are interactive at a
1275
+ * basic level before JavaScript loads. Instead of React Router managing the
1276
+ * submission, the browser manages the submission as well as the pending states
1277
+ * (like the spinning favicon). After JavaScript loads, React Router takes over
1278
+ * enabling web application user experiences.
1279
+ *
1280
+ * `Form` is most useful for submissions that should also change the URL or
1281
+ * otherwise add an entry to the browser history stack. For forms that shouldn't
1282
+ * manipulate the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1283
+ * stack, use {@link FetcherWithComponents.Form | `<fetcher.Form>`}.
1284
+ *
1285
+ * @example
1286
+ * import { Form } from "react-router";
1287
+ *
1288
+ * function NewEvent() {
1289
+ * return (
1290
+ * <Form action="/events" method="post">
1291
+ * <input name="title" type="text" />
1292
+ * <input name="description" type="text" />
1293
+ * </Form>
1294
+ * );
1295
+ * }
1296
+ *
1297
+ * @public
1298
+ * @category Components
1299
+ * @mode framework
1300
+ * @mode data
1301
+ * @param {FormProps.action} action n/a
1302
+ * @param {FormProps.discover} discover n/a
1303
+ * @param {FormProps.encType} encType n/a
1304
+ * @param {FormProps.fetcherKey} fetcherKey n/a
1305
+ * @param {FormProps.method} method n/a
1306
+ * @param {FormProps.navigate} navigate n/a
1307
+ * @param {FormProps.preventScrollReset} preventScrollReset n/a
1308
+ * @param {FormProps.relative} relative n/a
1309
+ * @param {FormProps.reloadDocument} reloadDocument n/a
1310
+ * @param {FormProps.replace} replace n/a
1311
+ * @param {FormProps.state} state n/a
1312
+ * @param {FormProps.viewTransition} viewTransition n/a
1313
+ * @param {FormProps.defaultShouldRevalidate} defaultShouldRevalidate n/a
1314
+ * @returns A progressively enhanced [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) component
1315
+ */
1316
+ declare const Form: React$1.ForwardRefExoticComponent<FormProps & React$1.RefAttributes<HTMLFormElement>>;
1317
+ type ScrollRestorationProps = ScriptsProps & {
1318
+ /**
1319
+ * A function that returns a key to use for scroll restoration. This is useful
1320
+ * for custom scroll restoration logic, such as using only the pathname so
1321
+ * that later navigations to prior paths will restore the scroll. Defaults to
1322
+ * `location.key`. See {@link GetScrollRestorationKeyFunction}.
1323
+ *
1324
+ * ```tsx
1325
+ * <ScrollRestoration
1326
+ * getKey={(location, matches) => {
1327
+ * // Restore based on a unique location key (default behavior)
1328
+ * return location.key
1329
+ *
1330
+ * // Restore based on pathname
1331
+ * return location.pathname
1332
+ * }}
1333
+ * />
1334
+ * ```
1335
+ */
1336
+ getKey?: GetScrollRestorationKeyFunction;
1337
+ /**
1338
+ * The key to use for storing scroll positions in [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).
1339
+ * Defaults to `"react-router-scroll-positions"`.
1340
+ */
1341
+ storageKey?: string;
1342
+ };
1343
+ /**
1344
+ * Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
1345
+ *
1346
+ * ```tsx
1347
+ * import { ScrollRestoration } from "react-router";
1348
+ *
1349
+ * export default function Root() {
1350
+ * return (
1351
+ * <html>
1352
+ * <body>
1353
+ * <ScrollRestoration />
1354
+ * <Scripts />
1355
+ * </body>
1356
+ * </html>
1357
+ * );
1358
+ * }
1359
+ * ```
1360
+ *
1361
+ * This component renders an inline `<script>` to prevent scroll flashing. The
1362
+ * `nonce` prop will be passed down to the script tag to allow CSP nonce usage.
1363
+ * If not provided in Framework Mode, it will default to any
1364
+ * {@link ServerRouter | `<ServerRouter nonce>`} prop.
1365
+ *
1366
+ * ```tsx
1367
+ * <ScrollRestoration nonce={cspNonce} />
1368
+ * ```
1369
+ *
1370
+ * @public
1371
+ * @category Components
1372
+ * @mode framework
1373
+ * @mode data
1374
+ * @param props Props
1375
+ * @param {ScrollRestorationProps.getKey} props.getKey n/a
1376
+ * @param {ScriptsProps.nonce} props.nonce n/a
1377
+ * @param {ScrollRestorationProps.storageKey} props.storageKey n/a
1378
+ * @returns A [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
1379
+ * tag that restores scroll positions on navigation.
1380
+ */
1381
+ declare function ScrollRestoration({
1382
+ getKey,
1383
+ storageKey,
1384
+ ...props
1385
+ }: ScrollRestorationProps): React$1.JSX.Element | null;
1386
+ declare namespace ScrollRestoration {
1387
+ var displayName: string;
1388
+ }
1389
+ /**
1390
+ * Handles the click behavior for router {@link Link | `<Link>`} components.This
1391
+ * is useful if you need to create custom {@link Link | `<Link>`} components with
1392
+ * the same click behavior we use in our exported {@link Link | `<Link>`}.
1393
+ *
1394
+ * @public
1395
+ * @category Hooks
1396
+ * @param to The URL to navigate to, can be a string or a partial {@link Path}.
1397
+ * @param options Options
1398
+ * @param options.preventScrollReset Whether to prevent the scroll position from
1399
+ * being reset to the top of the viewport on completion of the navigation when
1400
+ * using the {@link ScrollRestoration} component. Defaults to `false`.
1401
+ * @param options.relative The {@link RelativeRoutingType | relative routing type}
1402
+ * to use for the link. Defaults to `"route"`.
1403
+ * @param options.replace Whether to replace the current [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1404
+ * entry instead of pushing a new one. Defaults to `false`.
1405
+ * @param options.state The state to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1406
+ * entry for this navigation. Defaults to `undefined`.
1407
+ * @param options.target The target attribute for the link. Defaults to `undefined`.
1408
+ * @param options.viewTransition Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1409
+ * for this navigation. To apply specific styles during the transition, see
1410
+ * {@link useViewTransitionState}. Defaults to `false`.
1411
+ * @param options.defaultShouldRevalidate Specify the default revalidation
1412
+ * behavior for the navigation. Defaults to `true`.
1413
+ * @param options.mask Masked location to display in the browser instead
1414
+ * of the router location. Defaults to `undefined`.
1415
+ * @param options.useTransitions Wraps the navigation in
1416
+ * [`React.startTransition`](https://react.dev/reference/react/startTransition)
1417
+ * for concurrent rendering. Defaults to `false`.
1418
+ * @returns A click handler function that can be used in a custom {@link Link} component.
1419
+ */
1420
+ declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, {
1421
+ target,
1422
+ replace: replaceProp,
1423
+ mask,
1424
+ state,
1425
+ preventScrollReset,
1426
+ relative,
1427
+ viewTransition,
1428
+ defaultShouldRevalidate,
1429
+ useTransitions
1430
+ }?: {
1431
+ target?: React$1.HTMLAttributeAnchorTarget;
1432
+ replace?: boolean;
1433
+ mask?: To;
1434
+ state?: any;
1435
+ preventScrollReset?: boolean;
1436
+ relative?: RelativeRoutingType;
1437
+ viewTransition?: boolean;
1438
+ defaultShouldRevalidate?: boolean;
1439
+ useTransitions?: boolean;
1440
+ }): (event: React$1.MouseEvent<E, MouseEvent>) => void;
1441
+ /**
1442
+ * Returns a tuple of the current URL's [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
1443
+ * and a function to update them. Setting the search params causes a navigation.
1444
+ *
1445
+ * ```tsx
1446
+ * import { useSearchParams } from "react-router";
1447
+ *
1448
+ * export function SomeComponent() {
1449
+ * const [searchParams, setSearchParams] = useSearchParams();
1450
+ * // ...
1451
+ * }
1452
+ * ```
1453
+ *
1454
+ * ### `setSearchParams` function
1455
+ *
1456
+ * The second element of the tuple is a function that can be used to update the
1457
+ * search params. It accepts the same types as `defaultInit` and will cause a
1458
+ * navigation to the new URL.
1459
+ *
1460
+ * ```tsx
1461
+ * let [searchParams, setSearchParams] = useSearchParams();
1462
+ *
1463
+ * // a search param string
1464
+ * setSearchParams("?tab=1");
1465
+ *
1466
+ * // a shorthand object
1467
+ * setSearchParams({ tab: "1" });
1468
+ *
1469
+ * // object keys can be arrays for multiple values on the key
1470
+ * setSearchParams({ brand: ["nike", "reebok"] });
1471
+ *
1472
+ * // an array of tuples
1473
+ * setSearchParams([["tab", "1"]]);
1474
+ *
1475
+ * // a `URLSearchParams` object
1476
+ * setSearchParams(new URLSearchParams("?tab=1"));
1477
+ * ```
1478
+ *
1479
+ * It also supports a function callback like React's
1480
+ * [`setState`](https://react.dev/reference/react/useState#setstate):
1481
+ *
1482
+ * ```tsx
1483
+ * setSearchParams((searchParams) => {
1484
+ * searchParams.set("tab", "2");
1485
+ * return searchParams;
1486
+ * });
1487
+ * ```
1488
+ *
1489
+ * <docs-warning>The function callback version of `setSearchParams` does not support
1490
+ * the [queueing](https://react.dev/reference/react/useState#setstate-parameters)
1491
+ * logic that React's `setState` implements. Multiple calls to `setSearchParams`
1492
+ * in the same tick will not build on the prior value. If you need this behavior,
1493
+ * you can use `setState` manually.</docs-warning>
1494
+ *
1495
+ * ### Notes
1496
+ *
1497
+ * Note that `searchParams` is a stable reference, so you can reliably use it
1498
+ * as a dependency in React's [`useEffect`](https://react.dev/reference/react/useEffect)
1499
+ * hooks.
1500
+ *
1501
+ * ```tsx
1502
+ * useEffect(() => {
1503
+ * console.log(searchParams.get("tab"));
1504
+ * }, [searchParams]);
1505
+ * ```
1506
+ *
1507
+ * However, this also means it's mutable. If you change the object without
1508
+ * calling `setSearchParams`, its values will change between renders if some
1509
+ * other state causes the component to re-render and URL will not reflect the
1510
+ * values.
1511
+ *
1512
+ * @public
1513
+ * @category Hooks
1514
+ * @param defaultInit
1515
+ * You can initialize the search params with a default value, though it **will
1516
+ * not** change the URL on the first render.
1517
+ *
1518
+ * ```tsx
1519
+ * // a search param string
1520
+ * useSearchParams("?tab=1");
1521
+ *
1522
+ * // a shorthand object
1523
+ * useSearchParams({ tab: "1" });
1524
+ *
1525
+ * // object keys can be arrays for multiple values on the key
1526
+ * useSearchParams({ brand: ["nike", "reebok"] });
1527
+ *
1528
+ * // an array of tuples
1529
+ * useSearchParams([["tab", "1"]]);
1530
+ *
1531
+ * // a `URLSearchParams` object
1532
+ * useSearchParams(new URLSearchParams("?tab=1"));
1533
+ * ```
1534
+ * @returns A tuple of the current [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
1535
+ * and a function to update them.
1536
+ */
1537
+ declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
1538
+ /**
1539
+ * Sets new search params and causes a navigation when called.
1540
+ *
1541
+ * ```tsx
1542
+ * <button
1543
+ * onClick={() => {
1544
+ * const params = new URLSearchParams();
1545
+ * params.set("someKey", "someValue");
1546
+ * setSearchParams(params, {
1547
+ * preventScrollReset: true,
1548
+ * });
1549
+ * }}
1550
+ * />
1551
+ * ```
1552
+ *
1553
+ * It also supports a function for setting new search params.
1554
+ *
1555
+ * ```tsx
1556
+ * <button
1557
+ * onClick={() => {
1558
+ * setSearchParams((prev) => {
1559
+ * prev.set("someKey", "someValue");
1560
+ * return prev;
1561
+ * });
1562
+ * }}
1563
+ * />
1564
+ * ```
1565
+ */
1566
+ type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
1567
+ /**
1568
+ * Submits a HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
1569
+ * to the server without reloading the page.
1570
+ */
1571
+ interface SubmitFunction {
1572
+ (
1573
+ /**
1574
+ * Can be multiple types of elements and objects
1575
+ *
1576
+ * **[`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)**
1577
+ *
1578
+ * ```tsx
1579
+ * <Form
1580
+ * onSubmit={(event) => {
1581
+ * submit(event.currentTarget);
1582
+ * }}
1583
+ * />
1584
+ * ```
1585
+ *
1586
+ * **[`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
1587
+ *
1588
+ * ```tsx
1589
+ * const formData = new FormData();
1590
+ * formData.append("myKey", "myValue");
1591
+ * submit(formData, { method: "post" });
1592
+ * ```
1593
+ *
1594
+ * **Plain object that will be serialized as [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
1595
+ *
1596
+ * ```tsx
1597
+ * submit({ myKey: "myValue" }, { method: "post" });
1598
+ * ```
1599
+ *
1600
+ * **Plain object that will be serialized as JSON**
1601
+ *
1602
+ * ```tsx
1603
+ * submit(
1604
+ * { myKey: "myValue" },
1605
+ * { method: "post", encType: "application/json" }
1606
+ * );
1607
+ * ```
1608
+ */
1609
+ target: SubmitTarget,
1610
+ /**
1611
+ * Options that override the [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)'s
1612
+ * own attributes. Required when submitting arbitrary data without a backing
1613
+ * [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
1614
+ */
1615
+ options?: SubmitOptions): Promise<void>;
1616
+ }
1617
+ /**
1618
+ * Submits a fetcher [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) to the server without reloading the page.
1619
+ */
1620
+ interface FetcherSubmitFunction {
1621
+ (
1622
+ /**
1623
+ * Can be multiple types of elements and objects
1624
+ *
1625
+ * **[`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)**
1626
+ *
1627
+ * ```tsx
1628
+ * <fetcher.Form
1629
+ * onSubmit={(event) => {
1630
+ * fetcher.submit(event.currentTarget);
1631
+ * }}
1632
+ * />
1633
+ * ```
1634
+ *
1635
+ * **[`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
1636
+ *
1637
+ * ```tsx
1638
+ * const formData = new FormData();
1639
+ * formData.append("myKey", "myValue");
1640
+ * fetcher.submit(formData, { method: "post" });
1641
+ * ```
1642
+ *
1643
+ * **Plain object that will be serialized as [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
1644
+ *
1645
+ * ```tsx
1646
+ * fetcher.submit({ myKey: "myValue" }, { method: "post" });
1647
+ * ```
1648
+ *
1649
+ * **Plain object that will be serialized as JSON**
1650
+ *
1651
+ * ```tsx
1652
+ * fetcher.submit(
1653
+ * { myKey: "myValue" },
1654
+ * { method: "post", encType: "application/json" }
1655
+ * );
1656
+ * ```
1657
+ */
1658
+ target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
1659
+ }
1660
+ /**
1661
+ * The imperative version of {@link Form | `<Form>`} that lets you submit a form
1662
+ * from code instead of a user interaction.
1663
+ *
1664
+ * @example
1665
+ * import { useSubmit } from "react-router";
1666
+ *
1667
+ * function SomeComponent() {
1668
+ * const submit = useSubmit();
1669
+ * return (
1670
+ * <Form onChange={(event) => submit(event.currentTarget)} />
1671
+ * );
1672
+ * }
1673
+ *
1674
+ * @public
1675
+ * @category Hooks
1676
+ * @mode framework
1677
+ * @mode data
1678
+ * @returns A function that can be called to submit a {@link Form} imperatively.
1679
+ */
1680
+ declare function useSubmit(): SubmitFunction;
1681
+ /**
1682
+ * Resolves the URL to the closest route in the component hierarchy instead of
1683
+ * the current URL of the app.
1684
+ *
1685
+ * This is used internally by {@link Form} to resolve the `action` to the closest
1686
+ * route, but can be used generically as well.
1687
+ *
1688
+ * ```ts
1689
+ * import { useFormAction } from "react-router";
1690
+ *
1691
+ * function SomeComponent() {
1692
+ * // closest route URL
1693
+ * let action = useFormAction();
1694
+ *
1695
+ * // closest route URL + "destroy"
1696
+ * let destroyAction = useFormAction("destroy");
1697
+ * }
1698
+ * ```
1699
+ *
1700
+ * <docs-info>This hook adds a `basename` if your app specifies one, so that it
1701
+ * can be used with raw `<form>` elements in a progressively enhanced way. If
1702
+ * you are using this to provide an `action` to `<Form>` or `fetcher.submit`, you
1703
+ * will need to remove the `basename` since both of those will prepend it
1704
+ * internally.</docs-info>
1705
+ *
1706
+ *
1707
+ * @public
1708
+ * @category Hooks
1709
+ * @mode framework
1710
+ * @mode data
1711
+ * @param action The action to append to the closest route URL. Defaults to the
1712
+ * closest route URL.
1713
+ * @param options Options
1714
+ * @param options.relative The relative routing type to use when resolving the
1715
+ * action. Defaults to `"route"`.
1716
+ * @returns The resolved action URL.
1717
+ */
1718
+ declare function useFormAction(action?: string, {
1719
+ relative
1720
+ }?: {
1721
+ relative?: RelativeRoutingType;
1722
+ }): string;
1723
+ /**
1724
+ * The return value {@link useFetcher} that keeps track of the state of a fetcher.
1725
+ *
1726
+ * ```tsx
1727
+ * let fetcher = useFetcher();
1728
+ * ```
1729
+ */
1730
+ type FetcherWithComponents<TData> = Fetcher<TData> & {
1731
+ /**
1732
+ * Just like {@link Form} except it doesn't cause a navigation.
1733
+ *
1734
+ * ```tsx
1735
+ * function SomeComponent() {
1736
+ * const fetcher = useFetcher()
1737
+ * return (
1738
+ * <fetcher.Form method="post" action="/some/route">
1739
+ * <input type="text" />
1740
+ * </fetcher.Form>
1741
+ * )
1742
+ * }
1743
+ * ```
1744
+ */
1745
+ Form: React$1.ForwardRefExoticComponent<FetcherFormProps & React$1.RefAttributes<HTMLFormElement>>;
1746
+ /**
1747
+ * Loads data from a route. Useful for loading data imperatively inside user
1748
+ * events outside a normal button or form, like a combobox or search input.
1749
+ *
1750
+ * ```tsx
1751
+ * let fetcher = useFetcher()
1752
+ *
1753
+ * <input onChange={e => {
1754
+ * fetcher.load(`/search?q=${e.target.value}`)
1755
+ * }} />
1756
+ * ```
1757
+ */
1758
+ load: (href: string, opts?: {
1759
+ /**
1760
+ * Wraps the initial state update for this `fetcher.load` in a
1761
+ * [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
1762
+ * call instead of the default [`React.startTransition`](https://react.dev/reference/react/startTransition).
1763
+ * This allows you to perform synchronous DOM actions immediately after the
1764
+ * update is flushed to the DOM.
1765
+ */
1766
+ flushSync?: boolean;
1767
+ }) => Promise<void>;
1768
+ /**
1769
+ * Reset a fetcher back to an empty/idle state.
1770
+ *
1771
+ * If the fetcher is currently in-flight, the
1772
+ * [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
1773
+ * will be aborted with the `reason`, if provided.
1774
+ * @param opts Options for resetting the fetcher.
1775
+ * @param opts.reason Optional `reason` to provide to [`AbortController.abort()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort)
1776
+ * @returns void
1777
+ */
1778
+ reset: (opts?: {
1779
+ reason?: unknown;
1780
+ }) => void;
1781
+ /**
1782
+ * Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
1783
+ *
1784
+ * The `formData` can be multiple types:
1785
+ *
1786
+ * - [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
1787
+ * A `FormData` instance.
1788
+ * - [`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)
1789
+ * A [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) DOM element.
1790
+ * - `Object`
1791
+ * An object of key/value-pairs that will be converted to a [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
1792
+ * instance by default. You can pass a more complex object and serialize it
1793
+ * as JSON by specifying `encType: "application/json"`. See
1794
+ * {@link useSubmit} for more details.
1795
+ *
1796
+ * If the method is `GET`, then the route [`loader`](../../start/framework/route-module#loader)
1797
+ * is being called and with the `formData` serialized to the url as [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
1798
+ * If `DELETE`, `PATCH`, `POST`, or `PUT`, then the route [`action`](../../start/framework/route-module#action)
1799
+ * is being called with `formData` as the body.
1800
+ *
1801
+ * ```tsx
1802
+ * // Submit a FormData instance (GET request)
1803
+ * const formData = new FormData();
1804
+ * fetcher.submit(formData);
1805
+ *
1806
+ * // Submit the HTML form element
1807
+ * fetcher.submit(event.currentTarget.form, {
1808
+ * method: "POST",
1809
+ * });
1810
+ *
1811
+ * // Submit key/value JSON as a FormData instance
1812
+ * fetcher.submit(
1813
+ * { serialized: "values" },
1814
+ * { method: "POST" }
1815
+ * );
1816
+ *
1817
+ * // Submit raw JSON
1818
+ * fetcher.submit(
1819
+ * {
1820
+ * deeply: {
1821
+ * nested: {
1822
+ * json: "values",
1823
+ * },
1824
+ * },
1825
+ * },
1826
+ * {
1827
+ * method: "POST",
1828
+ * encType: "application/json",
1829
+ * }
1830
+ * );
1831
+ * ```
1832
+ */
1833
+ submit: FetcherSubmitFunction;
1834
+ };
1835
+ /**
1836
+ * Useful for creating complex, dynamic user interfaces that require multiple,
1837
+ * concurrent data interactions without causing a navigation.
1838
+ *
1839
+ * Fetchers track their own, independent state and can be used to load data, submit
1840
+ * forms, and generally interact with [`action`](../../start/framework/route-module#action)
1841
+ * and [`loader`](../../start/framework/route-module#loader) functions.
1842
+ *
1843
+ * @example
1844
+ * import { useFetcher } from "react-router"
1845
+ *
1846
+ * function SomeComponent() {
1847
+ * let fetcher = useFetcher()
1848
+ *
1849
+ * // states are available on the fetcher
1850
+ * fetcher.state // "idle" | "loading" | "submitting"
1851
+ * fetcher.data // the data returned from the action or loader
1852
+ *
1853
+ * // render a form
1854
+ * <fetcher.Form method="post" />
1855
+ *
1856
+ * // load data
1857
+ * fetcher.load("/some/route")
1858
+ *
1859
+ * // submit data
1860
+ * fetcher.submit(someFormRef, { method: "post" })
1861
+ * fetcher.submit(someData, {
1862
+ * method: "post",
1863
+ * encType: "application/json"
1864
+ * })
1865
+ *
1866
+ * // reset fetcher
1867
+ * fetcher.reset()
1868
+ * }
1869
+ *
1870
+ * @public
1871
+ * @category Hooks
1872
+ * @mode framework
1873
+ * @mode data
1874
+ * @param options Options
1875
+ * @param options.key A unique key to identify the fetcher.
1876
+ *
1877
+ *
1878
+ * By default, `useFetcher` generates a unique fetcher scoped to that component.
1879
+ * If you want to identify a fetcher with your own key such that you can access
1880
+ * it from elsewhere in your app, you can do that with the `key` option:
1881
+ *
1882
+ * ```tsx
1883
+ * function SomeComp() {
1884
+ * let fetcher = useFetcher({ key: "my-key" })
1885
+ * // ...
1886
+ * }
1887
+ *
1888
+ * // Somewhere else
1889
+ * function AnotherComp() {
1890
+ * // this will be the same fetcher, sharing the state across the app
1891
+ * let fetcher = useFetcher({ key: "my-key" });
1892
+ * // ...
1893
+ * }
1894
+ * ```
1895
+ * @returns A {@link FetcherWithComponents} object that contains the fetcher's state, data, and components for submitting forms and loading data.
1896
+ */
1897
+ declare function useFetcher<T = any>({
1898
+ key
1899
+ }?: {
1900
+ key?: string;
1901
+ }): FetcherWithComponents<SerializeFrom<T>>;
1902
+ /**
1903
+ * Returns an array of all in-flight {@link Fetcher}s. This is useful for components
1904
+ * throughout the app that didn't create the fetchers but want to use their submissions
1905
+ * to participate in optimistic UI.
1906
+ *
1907
+ * @example
1908
+ * import { useFetchers } from "react-router";
1909
+ *
1910
+ * function SomeComponent() {
1911
+ * const fetchers = useFetchers();
1912
+ * fetchers[0].formData; // FormData
1913
+ * fetchers[0].state; // etc.
1914
+ * // ...
1915
+ * }
1916
+ *
1917
+ * @public
1918
+ * @category Hooks
1919
+ * @mode framework
1920
+ * @mode data
1921
+ * @returns An array of all in-flight {@link Fetcher}s, each with a unique `key`
1922
+ * property.
1923
+ */
1924
+ declare function useFetchers(): (Fetcher & {
1925
+ key: string;
1926
+ })[];
1927
+ /**
1928
+ * When rendered inside a {@link RouterProvider}, will restore scroll positions
1929
+ * on navigations
1930
+ *
1931
+ * <!--
1932
+ * Not marked `@public` because we only export as UNSAFE_ and therefore we don't
1933
+ * maintain an .md file for this hook
1934
+ * -->
1935
+ *
1936
+ * @name UNSAFE_useScrollRestoration
1937
+ * @category Hooks
1938
+ * @mode framework
1939
+ * @mode data
1940
+ * @param options Options
1941
+ * @param options.getKey A function that returns a key to use for scroll restoration.
1942
+ * This is useful for custom scroll restoration logic, such as using only the pathname
1943
+ * so that subsequent navigations to prior paths will restore the scroll. Defaults
1944
+ * to `location.key`.
1945
+ * @param options.storageKey The key to use for storing scroll positions in
1946
+ * `sessionStorage`. Defaults to `"react-router-scroll-positions"`.
1947
+ * @returns {void}
1948
+ */
1949
+ declare function useScrollRestoration({
1950
+ getKey,
1951
+ storageKey
1952
+ }?: {
1953
+ getKey?: GetScrollRestorationKeyFunction;
1954
+ storageKey?: string;
1955
+ }): void;
1956
+ /**
1957
+ * Set up a callback to be fired on [Window's `beforeunload` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event).
1958
+ *
1959
+ * @public
1960
+ * @category Hooks
1961
+ * @param callback The callback to be called when the [`beforeunload` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event)
1962
+ * is fired.
1963
+ * @param options Options
1964
+ * @param options.capture If `true`, the event will be captured during the capture
1965
+ * phase. Defaults to `false`.
1966
+ * @returns {void}
1967
+ */
1968
+ declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
1969
+ capture?: boolean;
1970
+ }): void;
1971
+ /**
1972
+ * Wrapper around {@link useBlocker} to show a [`window.confirm`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm)
1973
+ * prompt to users instead of building a custom UI with {@link useBlocker}.
1974
+ *
1975
+ * The `unstable_` flag will not be removed because this technique has a lot of
1976
+ * rough edges and behaves very differently (and incorrectly sometimes) across
1977
+ * browsers if users click addition back/forward navigations while the
1978
+ * confirmation is open. Use at your own risk.
1979
+ *
1980
+ * @example
1981
+ * function ImportantForm() {
1982
+ * let [value, setValue] = React.useState("");
1983
+ *
1984
+ * // Block navigating elsewhere when data has been entered into the input
1985
+ * unstable_usePrompt({
1986
+ * message: "Are you sure?",
1987
+ * when: ({ currentLocation, nextLocation }) =>
1988
+ * value !== "" &&
1989
+ * currentLocation.pathname !== nextLocation.pathname,
1990
+ * });
1991
+ *
1992
+ * return (
1993
+ * <Form method="post">
1994
+ * <label>
1995
+ * Enter some important data:
1996
+ * <input
1997
+ * name="data"
1998
+ * value={value}
1999
+ * onChange={(e) => setValue(e.target.value)}
2000
+ * />
2001
+ * </label>
2002
+ * <button type="submit">Save</button>
2003
+ * </Form>
2004
+ * );
2005
+ * }
2006
+ *
2007
+ * @name unstable_usePrompt
2008
+ * @public
2009
+ * @category Hooks
2010
+ * @mode framework
2011
+ * @mode data
2012
+ * @param options Options
2013
+ * @param options.message The message to show in the confirmation dialog.
2014
+ * @param options.when A boolean or a function that returns a boolean indicating
2015
+ * whether to block the navigation. If a function is provided, it will receive an
2016
+ * object with `currentLocation` and `nextLocation` properties.
2017
+ * @returns {void}
2018
+ */
2019
+ declare function usePrompt({
2020
+ when,
2021
+ message
2022
+ }: {
2023
+ when: boolean | BlockerFunction;
2024
+ message: string;
2025
+ }): void;
2026
+ /**
2027
+ * This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
2028
+ * and the specified location matches either side of the navigation (the URL you are
2029
+ * navigating **to** or the URL you are navigating **from**). This can be used to apply finer-grained styles to
2030
+ * elements to further customize the view transition. This requires that view
2031
+ * transitions have been enabled for the given navigation via {@link LinkProps.viewTransition}
2032
+ * (or the `Form`, `submit`, or `navigate` call)
2033
+ *
2034
+ * @public
2035
+ * @category Hooks
2036
+ * @mode framework
2037
+ * @mode data
2038
+ * @param to The {@link To} location to compare against the active transition's current
2039
+ * and next URLs.
2040
+ * @param options Options
2041
+ * @param options.relative The relative routing type to use when resolving the
2042
+ * `to` location, defaults to `"route"`. See {@link RelativeRoutingType} for
2043
+ * more details.
2044
+ * @returns `true` if there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
2045
+ * and the resolved path matches the transition's destination or source pathname, otherwise `false`.
2046
+ */
2047
+ declare function useViewTransitionState(to: To, {
2048
+ relative
2049
+ }?: {
2050
+ relative?: RelativeRoutingType;
2051
+ }): boolean;
2052
+ //#endregion
2053
+ export { BrowserRouter, BrowserRouterProps, DOMRouterOpts, FetcherFormProps, FetcherSubmitFunction, FetcherWithComponents, Form, FormProps, HashRouter, HashRouterProps, HistoryRouter, HistoryRouterProps, Link, LinkProps, NavLink, NavLinkProps, NavLinkRenderProps, ScrollRestoration, ScrollRestorationProps, SetURLSearchParams, SubmitFunction, createBrowserRouter, createHashRouter, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLinkClickHandler, usePrompt, useScrollRestoration, useSearchParams, useSubmit, useViewTransitionState };