react-router 7.16.0 → 8.0.0-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/development/dom-export.d.ts +6 -172
  3. package/dist/development/dom-export.js +12 -1007
  4. package/dist/development/index-react-server-client.d.ts +7 -4
  5. package/dist/development/index-react-server-client.js +8 -52
  6. package/dist/development/index-react-server.d.ts +1645 -1635
  7. package/dist/development/index-react-server.js +2880 -3642
  8. package/dist/development/index.d.ts +43 -1475
  9. package/dist/development/index.js +37 -2621
  10. package/dist/development/lib/actions.js +62 -0
  11. package/dist/development/lib/components.d.ts +1022 -0
  12. package/dist/development/lib/components.js +835 -0
  13. package/dist/development/lib/context.d.ts +83 -0
  14. package/dist/development/lib/context.js +41 -0
  15. package/dist/development/lib/dom/dom.d.ts +119 -0
  16. package/dist/development/lib/dom/dom.js +143 -0
  17. package/dist/development/lib/dom/lib.d.ts +2042 -0
  18. package/dist/development/lib/dom/lib.js +1259 -0
  19. package/dist/development/lib/dom/server.d.ts +138 -0
  20. package/dist/development/lib/dom/server.js +301 -0
  21. package/dist/development/lib/dom/ssr/components.d.ts +196 -0
  22. package/dist/development/lib/dom/ssr/components.js +579 -0
  23. package/dist/development/lib/dom/ssr/data.js +29 -0
  24. package/dist/development/lib/dom/ssr/entry.d.ts +59 -0
  25. package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  26. package/dist/development/lib/dom/ssr/errorBoundaries.js +83 -0
  27. package/dist/development/lib/dom/ssr/errors.d.ts +7 -0
  28. package/dist/development/lib/dom/ssr/errors.js +36 -0
  29. package/dist/development/lib/dom/ssr/fallback.js +28 -0
  30. package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
  31. package/dist/development/lib/dom/ssr/fog-of-war.js +170 -0
  32. package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
  33. package/dist/development/lib/dom/ssr/hydration.js +29 -0
  34. package/dist/development/lib/dom/ssr/invariant.js +16 -0
  35. package/dist/development/lib/dom/ssr/links.js +170 -0
  36. package/dist/development/lib/dom/ssr/markup.js +24 -0
  37. package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
  38. package/dist/development/lib/dom/ssr/routeModules.js +31 -0
  39. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  40. package/dist/development/lib/dom/ssr/routes-test-stub.js +108 -0
  41. package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
  42. package/dist/development/lib/dom/ssr/routes.js +303 -0
  43. package/dist/development/lib/dom/ssr/server.d.ts +45 -0
  44. package/dist/development/lib/dom/ssr/server.js +68 -0
  45. package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
  46. package/dist/development/lib/dom/ssr/single-fetch.js +346 -0
  47. package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
  48. package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
  49. package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
  50. package/dist/development/lib/dom-export/hydrated-router.js +153 -0
  51. package/dist/development/lib/errors.js +29 -0
  52. package/dist/development/lib/hooks.d.ts +947 -0
  53. package/dist/development/lib/hooks.js +1386 -0
  54. package/dist/development/lib/href.d.ts +20 -0
  55. package/dist/development/lib/href.js +50 -0
  56. package/dist/development/lib/router/history.d.ts +258 -0
  57. package/dist/development/lib/router/history.js +371 -0
  58. package/dist/development/lib/router/instrumentation.d.ts +86 -0
  59. package/dist/development/lib/router/instrumentation.js +213 -0
  60. package/dist/development/lib/router/links.d.ts +113 -0
  61. package/dist/development/lib/router/router.d.ts +663 -0
  62. package/dist/development/lib/router/router.js +2981 -0
  63. package/dist/development/lib/router/utils.d.ts +942 -0
  64. package/dist/development/lib/router/utils.js +791 -0
  65. package/dist/development/lib/rsc/browser.d.ts +137 -0
  66. package/dist/development/lib/rsc/browser.js +599 -0
  67. package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
  68. package/dist/development/lib/rsc/errorBoundaries.js +90 -0
  69. package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
  70. package/dist/development/lib/rsc/html-stream/browser.js +74 -0
  71. package/dist/development/lib/rsc/html-stream/server.js +78 -0
  72. package/dist/development/lib/rsc/route-modules.js +27 -0
  73. package/dist/development/lib/rsc/server.rsc.d.ts +219 -0
  74. package/dist/development/lib/rsc/server.ssr.d.ts +129 -0
  75. package/dist/development/lib/rsc/server.ssr.js +388 -0
  76. package/dist/development/lib/server-runtime/build.d.ts +66 -0
  77. package/dist/development/lib/server-runtime/cookies.d.ts +66 -0
  78. package/dist/development/lib/server-runtime/cookies.js +139 -0
  79. package/dist/development/lib/server-runtime/crypto.js +43 -0
  80. package/dist/development/lib/server-runtime/data.d.ts +13 -0
  81. package/dist/development/lib/server-runtime/data.js +25 -0
  82. package/dist/development/lib/server-runtime/dev.d.ts +9 -0
  83. package/dist/development/lib/server-runtime/dev.js +26 -0
  84. package/dist/development/lib/server-runtime/entry.js +20 -0
  85. package/dist/development/lib/server-runtime/errors.js +95 -0
  86. package/dist/development/lib/server-runtime/headers.js +73 -0
  87. package/dist/development/lib/server-runtime/invariant.js +19 -0
  88. package/dist/development/lib/server-runtime/mode.d.ts +12 -0
  89. package/dist/development/lib/server-runtime/mode.js +25 -0
  90. package/dist/development/lib/server-runtime/routeMatching.js +28 -0
  91. package/dist/development/lib/server-runtime/routes.d.ts +13 -0
  92. package/dist/development/lib/server-runtime/routes.js +74 -0
  93. package/dist/development/lib/server-runtime/server.d.ts +10 -0
  94. package/dist/development/lib/server-runtime/server.js +351 -0
  95. package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
  96. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  97. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +45 -0
  98. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  99. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +52 -0
  100. package/dist/development/lib/server-runtime/sessions.d.ts +145 -0
  101. package/dist/development/lib/server-runtime/sessions.js +98 -0
  102. package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
  103. package/dist/development/lib/server-runtime/single-fetch.js +215 -0
  104. package/dist/development/lib/server-runtime/urls.js +31 -0
  105. package/dist/development/lib/server-runtime/warnings.js +20 -0
  106. package/dist/development/lib/types/future.d.ts +9 -0
  107. package/dist/development/lib/types/internal.d.ts +26 -177
  108. package/dist/development/lib/types/internal.js +3 -2
  109. package/dist/{production/register-CNAx3TXj.d.ts → development/lib/types/register.d.ts} +9 -15
  110. package/dist/development/lib/types/route-data.d.ts +113 -0
  111. package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
  112. package/dist/development/lib/types/route-module.d.ts +19 -0
  113. package/dist/development/lib/types/serializes-to.d.ts +13 -0
  114. package/dist/development/lib/types/utils.d.ts +11 -0
  115. package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
  116. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +178 -0
  117. package/dist/development/vendor/turbo-stream-v2/unflatten.js +198 -0
  118. package/dist/development/vendor/turbo-stream-v2/utils.js +47 -0
  119. package/dist/production/dom-export.d.ts +6 -172
  120. package/dist/production/dom-export.js +12 -1007
  121. package/dist/production/index-react-server-client.d.ts +7 -4
  122. package/dist/production/index-react-server-client.js +8 -52
  123. package/dist/production/index-react-server.d.ts +1645 -1635
  124. package/dist/production/index-react-server.js +2871 -3642
  125. package/dist/production/index.d.ts +43 -1475
  126. package/dist/production/index.js +37 -2621
  127. package/dist/production/lib/actions.js +62 -0
  128. package/dist/production/lib/components.d.ts +1022 -0
  129. package/dist/production/lib/components.js +835 -0
  130. package/dist/production/lib/context.d.ts +83 -0
  131. package/dist/production/lib/context.js +41 -0
  132. package/dist/production/lib/dom/dom.d.ts +119 -0
  133. package/dist/production/lib/dom/dom.js +143 -0
  134. package/dist/production/lib/dom/lib.d.ts +2042 -0
  135. package/dist/production/lib/dom/lib.js +1259 -0
  136. package/dist/production/lib/dom/server.d.ts +138 -0
  137. package/dist/production/lib/dom/server.js +301 -0
  138. package/dist/production/lib/dom/ssr/components.d.ts +196 -0
  139. package/dist/production/lib/dom/ssr/components.js +579 -0
  140. package/dist/production/lib/dom/ssr/data.js +29 -0
  141. package/dist/production/lib/dom/ssr/entry.d.ts +59 -0
  142. package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  143. package/dist/production/lib/dom/ssr/errorBoundaries.js +83 -0
  144. package/dist/production/lib/dom/ssr/errors.d.ts +7 -0
  145. package/dist/production/lib/dom/ssr/errors.js +36 -0
  146. package/dist/production/lib/dom/ssr/fallback.js +21 -0
  147. package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
  148. package/dist/production/lib/dom/ssr/fog-of-war.js +170 -0
  149. package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
  150. package/dist/production/lib/dom/ssr/hydration.js +29 -0
  151. package/dist/production/lib/dom/ssr/invariant.js +16 -0
  152. package/dist/production/lib/dom/ssr/links.js +170 -0
  153. package/dist/production/lib/dom/ssr/markup.js +24 -0
  154. package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
  155. package/dist/production/lib/dom/ssr/routeModules.js +31 -0
  156. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  157. package/dist/production/lib/dom/ssr/routes-test-stub.js +108 -0
  158. package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
  159. package/dist/production/lib/dom/ssr/routes.js +303 -0
  160. package/dist/production/lib/dom/ssr/server.d.ts +45 -0
  161. package/dist/production/lib/dom/ssr/server.js +68 -0
  162. package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
  163. package/dist/production/lib/dom/ssr/single-fetch.js +346 -0
  164. package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
  165. package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
  166. package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
  167. package/dist/production/lib/dom-export/hydrated-router.js +153 -0
  168. package/dist/production/lib/errors.js +29 -0
  169. package/dist/production/lib/hooks.d.ts +947 -0
  170. package/dist/production/lib/hooks.js +1371 -0
  171. package/dist/production/lib/href.d.ts +20 -0
  172. package/dist/production/lib/href.js +50 -0
  173. package/dist/production/lib/router/history.d.ts +258 -0
  174. package/dist/production/lib/router/history.js +371 -0
  175. package/dist/production/lib/router/instrumentation.d.ts +86 -0
  176. package/dist/production/lib/router/instrumentation.js +213 -0
  177. package/dist/production/lib/router/links.d.ts +113 -0
  178. package/dist/production/lib/router/router.d.ts +663 -0
  179. package/dist/production/lib/router/router.js +2981 -0
  180. package/dist/production/lib/router/utils.d.ts +942 -0
  181. package/dist/production/lib/router/utils.js +782 -0
  182. package/dist/production/lib/rsc/browser.d.ts +137 -0
  183. package/dist/production/lib/rsc/browser.js +599 -0
  184. package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
  185. package/dist/production/lib/rsc/errorBoundaries.js +90 -0
  186. package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
  187. package/dist/production/lib/rsc/html-stream/browser.js +74 -0
  188. package/dist/production/lib/rsc/html-stream/server.js +78 -0
  189. package/dist/production/lib/rsc/route-modules.js +27 -0
  190. package/dist/production/lib/rsc/server.rsc.d.ts +219 -0
  191. package/dist/production/lib/rsc/server.ssr.d.ts +129 -0
  192. package/dist/production/lib/rsc/server.ssr.js +388 -0
  193. package/dist/production/lib/server-runtime/build.d.ts +66 -0
  194. package/dist/production/lib/server-runtime/cookies.d.ts +66 -0
  195. package/dist/production/lib/server-runtime/cookies.js +139 -0
  196. package/dist/production/lib/server-runtime/crypto.js +43 -0
  197. package/dist/production/lib/server-runtime/data.d.ts +13 -0
  198. package/dist/production/lib/server-runtime/data.js +25 -0
  199. package/dist/production/lib/server-runtime/dev.d.ts +9 -0
  200. package/dist/production/lib/server-runtime/dev.js +26 -0
  201. package/dist/production/lib/server-runtime/entry.js +20 -0
  202. package/dist/production/lib/server-runtime/errors.js +95 -0
  203. package/dist/production/lib/server-runtime/headers.js +73 -0
  204. package/dist/production/lib/server-runtime/invariant.js +19 -0
  205. package/dist/production/lib/server-runtime/mode.d.ts +12 -0
  206. package/dist/production/lib/server-runtime/mode.js +25 -0
  207. package/dist/production/lib/server-runtime/routeMatching.js +28 -0
  208. package/dist/production/lib/server-runtime/routes.d.ts +13 -0
  209. package/dist/production/lib/server-runtime/routes.js +74 -0
  210. package/dist/production/lib/server-runtime/server.d.ts +10 -0
  211. package/dist/production/lib/server-runtime/server.js +351 -0
  212. package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
  213. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  214. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +45 -0
  215. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  216. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +52 -0
  217. package/dist/production/lib/server-runtime/sessions.d.ts +145 -0
  218. package/dist/production/lib/server-runtime/sessions.js +98 -0
  219. package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
  220. package/dist/production/lib/server-runtime/single-fetch.js +215 -0
  221. package/dist/production/lib/server-runtime/urls.js +31 -0
  222. package/dist/production/lib/server-runtime/warnings.js +20 -0
  223. package/dist/production/lib/types/future.d.ts +9 -0
  224. package/dist/production/lib/types/internal.d.ts +26 -177
  225. package/dist/production/lib/types/internal.js +3 -2
  226. package/dist/{development/register-CNAx3TXj.d.ts → production/lib/types/register.d.ts} +9 -15
  227. package/dist/production/lib/types/route-data.d.ts +113 -0
  228. package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
  229. package/dist/production/lib/types/route-module.d.ts +19 -0
  230. package/dist/production/lib/types/serializes-to.d.ts +13 -0
  231. package/dist/production/lib/types/utils.d.ts +11 -0
  232. package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
  233. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +178 -0
  234. package/dist/production/vendor/turbo-stream-v2/unflatten.js +198 -0
  235. package/dist/production/vendor/turbo-stream-v2/utils.js +47 -0
  236. package/docs/explanation/backend-for-frontend.md +50 -0
  237. package/docs/explanation/code-splitting.md +77 -0
  238. package/docs/explanation/concurrency.md +135 -0
  239. package/docs/explanation/form-vs-fetcher.md +292 -0
  240. package/docs/explanation/hot-module-replacement.md +137 -0
  241. package/docs/explanation/hydration.md +14 -0
  242. package/docs/explanation/index-query-param.md +86 -0
  243. package/docs/explanation/index.md +4 -0
  244. package/docs/explanation/lazy-route-discovery.md +78 -0
  245. package/docs/explanation/location.md +6 -0
  246. package/docs/explanation/progressive-enhancement.md +150 -0
  247. package/docs/explanation/race-conditions.md +88 -0
  248. package/docs/explanation/react-transitions.md +160 -0
  249. package/docs/explanation/route-matching.md +7 -0
  250. package/docs/explanation/server-client-execution.md +4 -0
  251. package/docs/explanation/sessions-and-cookies.md +465 -0
  252. package/docs/explanation/special-files.md +16 -0
  253. package/docs/explanation/state-management.md +524 -0
  254. package/docs/explanation/styling.md +87 -0
  255. package/docs/explanation/type-safety.md +82 -0
  256. package/docs/how-to/accessibility.md +44 -0
  257. package/docs/how-to/client-data.md +199 -0
  258. package/docs/how-to/data-strategy.md +317 -0
  259. package/docs/how-to/error-boundary.md +231 -0
  260. package/docs/how-to/error-reporting.md +134 -0
  261. package/docs/how-to/fetchers.md +307 -0
  262. package/docs/how-to/file-route-conventions.md +410 -0
  263. package/docs/how-to/file-uploads.md +217 -0
  264. package/docs/how-to/form-validation.md +120 -0
  265. package/docs/how-to/headers.md +164 -0
  266. package/docs/how-to/index.md +4 -0
  267. package/docs/how-to/instrumentation.md +556 -0
  268. package/docs/how-to/meta.md +40 -0
  269. package/docs/how-to/middleware.md +728 -0
  270. package/docs/how-to/navigation-blocking.md +233 -0
  271. package/docs/how-to/optimize-revalidation.md +12 -0
  272. package/docs/how-to/pre-rendering.md +225 -0
  273. package/docs/how-to/presets.md +103 -0
  274. package/docs/how-to/react-server-components.md +899 -0
  275. package/docs/how-to/resource-routes.md +126 -0
  276. package/docs/how-to/route-module-type-safety.md +100 -0
  277. package/docs/how-to/search-params.md +4 -0
  278. package/docs/how-to/security.md +30 -0
  279. package/docs/how-to/server-bundles.md +66 -0
  280. package/docs/how-to/spa.md +120 -0
  281. package/docs/how-to/status.md +63 -0
  282. package/docs/how-to/suspense.md +132 -0
  283. package/docs/how-to/using-handle.md +117 -0
  284. package/docs/how-to/view-transitions.md +237 -0
  285. package/docs/how-to/webhook.md +50 -0
  286. package/docs/index.md +39 -0
  287. package/docs/start/data/actions.md +138 -0
  288. package/docs/start/data/custom.md +198 -0
  289. package/docs/start/data/data-loading.md +44 -0
  290. package/docs/start/data/index.md +4 -0
  291. package/docs/start/data/installation.md +52 -0
  292. package/docs/start/data/navigating.md +12 -0
  293. package/docs/start/data/pending-ui.md +12 -0
  294. package/docs/start/data/route-object.md +248 -0
  295. package/docs/start/data/routing.md +281 -0
  296. package/docs/start/data/testing.md +8 -0
  297. package/docs/start/declarative/index.md +4 -0
  298. package/docs/start/declarative/installation.md +43 -0
  299. package/docs/start/declarative/navigating.md +133 -0
  300. package/docs/start/declarative/routing.md +237 -0
  301. package/docs/start/declarative/url-values.md +65 -0
  302. package/docs/start/framework/actions.md +175 -0
  303. package/docs/start/framework/data-loading.md +201 -0
  304. package/docs/start/framework/deploying.md +96 -0
  305. package/docs/start/framework/index.md +4 -0
  306. package/docs/start/framework/installation.md +42 -0
  307. package/docs/start/framework/navigating.md +182 -0
  308. package/docs/start/framework/pending-ui.md +142 -0
  309. package/docs/start/framework/rendering.md +59 -0
  310. package/docs/start/framework/route-module.md +527 -0
  311. package/docs/start/framework/routing.md +362 -0
  312. package/docs/start/framework/testing.md +133 -0
  313. package/docs/start/index.md +4 -0
  314. package/docs/start/modes.md +201 -0
  315. package/docs/upgrading/component-routes.md +363 -0
  316. package/docs/upgrading/future.md +31 -0
  317. package/docs/upgrading/index.md +4 -0
  318. package/docs/upgrading/remix.md +403 -0
  319. package/docs/upgrading/router-provider.md +442 -0
  320. package/docs/upgrading/v6.md +379 -0
  321. package/package.json +44 -87
  322. package/dist/development/browser-D3uq9sI1.d.ts +0 -318
  323. package/dist/development/browser-nIQ4Nsyi.d.mts +0 -318
  324. package/dist/development/chunk-IBI7OMNB.js +0 -1363
  325. package/dist/development/chunk-QUQL4437.mjs +0 -11529
  326. package/dist/development/chunk-S54KXAEJ.mjs +0 -2585
  327. package/dist/development/chunk-SRID2YZ2.js +0 -10229
  328. package/dist/development/chunk-XEJDWL2B.js +0 -188
  329. package/dist/development/context-m8rizgnE.d.mts +0 -1771
  330. package/dist/development/data-D4xhSy90.d.ts +0 -1732
  331. package/dist/development/data-U8FS-wNn.d.mts +0 -1732
  332. package/dist/development/dom-export.d.mts +0 -172
  333. package/dist/development/dom-export.mjs +0 -1008
  334. package/dist/development/index-react-server-client-BLiUx67a.d.ts +0 -3655
  335. package/dist/development/index-react-server-client-CdKROblb.d.mts +0 -2600
  336. package/dist/development/index-react-server-client.d.mts +0 -4
  337. package/dist/development/index-react-server-client.mjs +0 -59
  338. package/dist/development/index-react-server.d.mts +0 -2703
  339. package/dist/development/index-react-server.mjs +0 -3780
  340. package/dist/development/index.d.mts +0 -1478
  341. package/dist/development/index.mjs +0 -277
  342. package/dist/development/instrumentation-1q4YhLGP.d.ts +0 -715
  343. package/dist/development/lib/types/internal.d.mts +0 -184
  344. package/dist/development/lib/types/internal.mjs +0 -10
  345. package/dist/development/register-CqK96Zfk.d.mts +0 -30
  346. package/dist/production/browser-D3uq9sI1.d.ts +0 -318
  347. package/dist/production/browser-nIQ4Nsyi.d.mts +0 -318
  348. package/dist/production/chunk-EAQNHM3N.js +0 -188
  349. package/dist/production/chunk-NALGHHKE.mjs +0 -2585
  350. package/dist/production/chunk-Q65P7S7Y.mjs +0 -11529
  351. package/dist/production/chunk-SKEDDLRM.js +0 -1363
  352. package/dist/production/chunk-Y7DNFQZP.js +0 -10229
  353. package/dist/production/context-m8rizgnE.d.mts +0 -1771
  354. package/dist/production/data-D4xhSy90.d.ts +0 -1732
  355. package/dist/production/data-U8FS-wNn.d.mts +0 -1732
  356. package/dist/production/dom-export.d.mts +0 -172
  357. package/dist/production/dom-export.mjs +0 -1008
  358. package/dist/production/index-react-server-client-BLiUx67a.d.ts +0 -3655
  359. package/dist/production/index-react-server-client-CdKROblb.d.mts +0 -2600
  360. package/dist/production/index-react-server-client.d.mts +0 -4
  361. package/dist/production/index-react-server-client.mjs +0 -59
  362. package/dist/production/index-react-server.d.mts +0 -2703
  363. package/dist/production/index-react-server.mjs +0 -3780
  364. package/dist/production/index.d.mts +0 -1478
  365. package/dist/production/index.mjs +0 -277
  366. package/dist/production/instrumentation-1q4YhLGP.d.ts +0 -715
  367. package/dist/production/lib/types/internal.d.mts +0 -184
  368. package/dist/production/lib/types/internal.mjs +0 -10
  369. package/dist/production/register-CqK96Zfk.d.mts +0 -30
@@ -1,1771 +0,0 @@
1
- import { m as HTMLFormMethod, n as FormEncType, o as LoaderFunctionArgs, p as MiddlewareEnabled, c as RouterContextProvider, q as AppLoadContext, r as RouteObject, s as History, t as MaybePromise, u as MapRoutePropertiesFunction, v as Action, L as Location, w as DataRouteMatch, x as Submission, y as RouteData, z as DataStrategyFunction, B as PatchRoutesOnNavigationFunction, E as DataRouteObject, I as RouteBranch, J as RouteManifest, U as UIMatch, T as To, K as Path, P as Params, O as InitialEntry, Q as NonIndexRouteObject, V as LazyRouteFunction, W as IndexRouteObject, X as RouteMatch, Y as TrackedPromise } from './data-U8FS-wNn.mjs';
2
- import * as React from 'react';
3
-
4
- type ServerInstrumentation = {
5
- handler?: InstrumentRequestHandlerFunction;
6
- route?: InstrumentRouteFunction;
7
- };
8
- type ClientInstrumentation = {
9
- router?: InstrumentRouterFunction;
10
- route?: InstrumentRouteFunction;
11
- };
12
- type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
13
- type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
14
- type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
15
- type InstrumentationHandlerResult = {
16
- status: "success";
17
- error: undefined;
18
- } | {
19
- status: "error";
20
- error: Error;
21
- };
22
- type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>;
23
- type ReadonlyRequest = {
24
- method: string;
25
- url: string;
26
- headers: Pick<Headers, "get">;
27
- };
28
- type ReadonlyContext = MiddlewareEnabled extends true ? Pick<RouterContextProvider, "get"> : Readonly<AppLoadContext>;
29
- type InstrumentableRoute = {
30
- id: string;
31
- index: boolean | undefined;
32
- path: string | undefined;
33
- instrument(instrumentations: RouteInstrumentations): void;
34
- };
35
- type RouteInstrumentations = {
36
- lazy?: InstrumentFunction<RouteLazyInstrumentationInfo>;
37
- "lazy.loader"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
38
- "lazy.action"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
39
- "lazy.middleware"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
40
- middleware?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
41
- loader?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
42
- action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
43
- };
44
- type RouteLazyInstrumentationInfo = undefined;
45
- type RouteHandlerInstrumentationInfo = Readonly<{
46
- request: ReadonlyRequest;
47
- params: LoaderFunctionArgs["params"];
48
- pattern: string;
49
- context: ReadonlyContext;
50
- }>;
51
- type InstrumentableRouter = {
52
- instrument(instrumentations: RouterInstrumentations): void;
53
- };
54
- type RouterInstrumentations = {
55
- navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
56
- fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
57
- };
58
- type RouterNavigationInstrumentationInfo = Readonly<{
59
- to: string | number;
60
- currentUrl: string;
61
- formMethod?: HTMLFormMethod;
62
- formEncType?: FormEncType;
63
- formData?: FormData;
64
- body?: any;
65
- }>;
66
- type RouterFetchInstrumentationInfo = Readonly<{
67
- href: string;
68
- currentUrl: string;
69
- fetcherKey: string;
70
- formMethod?: HTMLFormMethod;
71
- formEncType?: FormEncType;
72
- formData?: FormData;
73
- body?: any;
74
- }>;
75
- type InstrumentableRequestHandler = {
76
- instrument(instrumentations: RequestHandlerInstrumentations): void;
77
- };
78
- type RequestHandlerInstrumentations = {
79
- request?: InstrumentFunction<RequestHandlerInstrumentationInfo>;
80
- };
81
- type RequestHandlerInstrumentationInfo = Readonly<{
82
- request: ReadonlyRequest;
83
- context: ReadonlyContext | undefined;
84
- }>;
85
-
86
- /**
87
- * A Router instance manages all navigation and data loading/mutations
88
- */
89
- interface Router$1 {
90
- /**
91
- * @private
92
- * PRIVATE - DO NOT USE
93
- *
94
- * Return the basename for the router
95
- */
96
- get basename(): RouterInit["basename"];
97
- /**
98
- * @private
99
- * PRIVATE - DO NOT USE
100
- *
101
- * Return the future config for the router
102
- */
103
- get future(): FutureConfig;
104
- /**
105
- * @private
106
- * PRIVATE - DO NOT USE
107
- *
108
- * Return the current state of the router
109
- */
110
- get state(): RouterState;
111
- /**
112
- * @private
113
- * PRIVATE - DO NOT USE
114
- *
115
- * Return the routes for this router instance
116
- */
117
- get routes(): DataRouteObject[];
118
- /**
119
- * @private
120
- * PRIVATE - DO NOT USE
121
- *
122
- * Return the route branches for this router instance
123
- */
124
- get branches(): RouteBranch<DataRouteObject>[] | undefined;
125
- /**
126
- * @private
127
- * PRIVATE - DO NOT USE
128
- *
129
- * Return the manifest for this router instance
130
- */
131
- get manifest(): RouteManifest;
132
- /**
133
- * @private
134
- * PRIVATE - DO NOT USE
135
- *
136
- * Return the window associated with the router
137
- */
138
- get window(): RouterInit["window"];
139
- /**
140
- * @private
141
- * PRIVATE - DO NOT USE
142
- *
143
- * Initialize the router, including adding history listeners and kicking off
144
- * initial data fetches. Returns a function to cleanup listeners and abort
145
- * any in-progress loads
146
- */
147
- initialize(): Router$1;
148
- /**
149
- * @private
150
- * PRIVATE - DO NOT USE
151
- *
152
- * Subscribe to router.state updates
153
- *
154
- * @param fn function to call with the new state
155
- */
156
- subscribe(fn: RouterSubscriber): () => void;
157
- /**
158
- * @private
159
- * PRIVATE - DO NOT USE
160
- *
161
- * Enable scroll restoration behavior in the router
162
- *
163
- * @param savedScrollPositions Object that will manage positions, in case
164
- * it's being restored from sessionStorage
165
- * @param getScrollPosition Function to get the active Y scroll position
166
- * @param getKey Function to get the key to use for restoration
167
- */
168
- enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
169
- /**
170
- * @private
171
- * PRIVATE - DO NOT USE
172
- *
173
- * Navigate forward/backward in the history stack
174
- * @param to Delta to move in the history stack
175
- */
176
- navigate(to: number): Promise<void>;
177
- /**
178
- * Navigate to the given path
179
- * @param to Path to navigate to
180
- * @param opts Navigation options (method, submission, etc.)
181
- */
182
- navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
183
- /**
184
- * @private
185
- * PRIVATE - DO NOT USE
186
- *
187
- * Trigger a fetcher load/submission
188
- *
189
- * @param key Fetcher key
190
- * @param routeId Route that owns the fetcher
191
- * @param href href to fetch
192
- * @param opts Fetcher options, (method, submission, etc.)
193
- */
194
- fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
195
- /**
196
- * @private
197
- * PRIVATE - DO NOT USE
198
- *
199
- * Trigger a revalidation of all current route loaders and fetcher loads
200
- */
201
- revalidate(): Promise<void>;
202
- /**
203
- * @private
204
- * PRIVATE - DO NOT USE
205
- *
206
- * Utility function to create an href for the given location
207
- * @param location
208
- */
209
- createHref(location: Location | URL): string;
210
- /**
211
- * @private
212
- * PRIVATE - DO NOT USE
213
- *
214
- * Utility function to URL encode a destination path according to the internal
215
- * history implementation
216
- * @param to
217
- */
218
- encodeLocation(to: To): Path;
219
- /**
220
- * @private
221
- * PRIVATE - DO NOT USE
222
- *
223
- * Get/create a fetcher for the given key
224
- * @param key
225
- */
226
- getFetcher<TData = any>(key: string): Fetcher<TData>;
227
- /**
228
- * @internal
229
- * PRIVATE - DO NOT USE
230
- *
231
- * Reset the fetcher for a given key
232
- * @param key
233
- */
234
- resetFetcher(key: string, opts?: {
235
- reason?: unknown;
236
- }): void;
237
- /**
238
- * @private
239
- * PRIVATE - DO NOT USE
240
- *
241
- * Delete the fetcher for a given key
242
- * @param key
243
- */
244
- deleteFetcher(key: string): void;
245
- /**
246
- * @private
247
- * PRIVATE - DO NOT USE
248
- *
249
- * Cleanup listeners and abort any in-progress loads
250
- */
251
- dispose(): void;
252
- /**
253
- * @private
254
- * PRIVATE - DO NOT USE
255
- *
256
- * Get a navigation blocker
257
- * @param key The identifier for the blocker
258
- * @param fn The blocker function implementation
259
- */
260
- getBlocker(key: string, fn: BlockerFunction): Blocker;
261
- /**
262
- * @private
263
- * PRIVATE - DO NOT USE
264
- *
265
- * Delete a navigation blocker
266
- * @param key The identifier for the blocker
267
- */
268
- deleteBlocker(key: string): void;
269
- /**
270
- * @private
271
- * PRIVATE DO NOT USE
272
- *
273
- * Patch additional children routes into an existing parent route
274
- * @param routeId The parent route id or a callback function accepting `patch`
275
- * to perform batch patching
276
- * @param children The additional children routes
277
- * @param unstable_allowElementMutations Allow mutation or route elements on
278
- * existing routes. Intended for RSC-usage
279
- * only.
280
- */
281
- patchRoutes(routeId: string | null, children: RouteObject[], unstable_allowElementMutations?: boolean): void;
282
- /**
283
- * @private
284
- * PRIVATE - DO NOT USE
285
- *
286
- * HMR needs to pass in-flight route updates to React Router
287
- * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
288
- */
289
- _internalSetRoutes(routes: RouteObject[]): void;
290
- /**
291
- * @private
292
- * PRIVATE - DO NOT USE
293
- *
294
- * Cause subscribers to re-render. This is used to force a re-render.
295
- */
296
- _internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
297
- /**
298
- * @private
299
- * PRIVATE - DO NOT USE
300
- *
301
- * Internal fetch AbortControllers accessed by unit tests
302
- */
303
- _internalFetchControllers: Map<string, AbortController>;
304
- }
305
- /**
306
- * State maintained internally by the router. During a navigation, all states
307
- * reflect the "old" location unless otherwise noted.
308
- */
309
- interface RouterState {
310
- /**
311
- * The action of the most recent navigation
312
- */
313
- historyAction: Action;
314
- /**
315
- * The current location reflected by the router
316
- */
317
- location: Location;
318
- /**
319
- * The current set of route matches
320
- */
321
- matches: DataRouteMatch[];
322
- /**
323
- * Tracks whether we've completed our initial data load
324
- */
325
- initialized: boolean;
326
- /**
327
- * Tracks whether we should be rendering a HydrateFallback during hydration
328
- */
329
- renderFallback: boolean;
330
- /**
331
- * Current scroll position we should start at for a new view
332
- * - number -> scroll position to restore to
333
- * - false -> do not restore scroll at all (used during submissions/revalidations)
334
- * - null -> don't have a saved position, scroll to hash or top of page
335
- */
336
- restoreScrollPosition: number | false | null;
337
- /**
338
- * Indicate whether this navigation should skip resetting the scroll position
339
- * if we are unable to restore the scroll position
340
- */
341
- preventScrollReset: boolean;
342
- /**
343
- * Tracks the state of the current navigation
344
- */
345
- navigation: Navigation;
346
- /**
347
- * Tracks any in-progress revalidations
348
- */
349
- revalidation: RevalidationState;
350
- /**
351
- * Data from the loaders for the current matches
352
- */
353
- loaderData: RouteData;
354
- /**
355
- * Data from the action for the current matches
356
- */
357
- actionData: RouteData | null;
358
- /**
359
- * Errors caught from loaders for the current matches
360
- */
361
- errors: RouteData | null;
362
- /**
363
- * Map of current fetchers
364
- */
365
- fetchers: Map<string, Fetcher>;
366
- /**
367
- * Map of current blockers
368
- */
369
- blockers: Map<string, Blocker>;
370
- }
371
- /**
372
- * Data that can be passed into hydrate a Router from SSR
373
- */
374
- type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
375
- /**
376
- * Future flags to toggle new feature behavior
377
- */
378
- interface FutureConfig {
379
- }
380
- /**
381
- * Initialization options for createRouter
382
- */
383
- interface RouterInit {
384
- routes: RouteObject[];
385
- history: History;
386
- basename?: string;
387
- getContext?: () => MaybePromise<RouterContextProvider>;
388
- instrumentations?: ClientInstrumentation[];
389
- mapRouteProperties?: MapRoutePropertiesFunction;
390
- future?: Partial<FutureConfig>;
391
- hydrationRouteProperties?: string[];
392
- hydrationData?: HydrationState;
393
- window?: Window;
394
- dataStrategy?: DataStrategyFunction;
395
- patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
396
- }
397
- /**
398
- * State returned from a server-side query() call
399
- */
400
- interface StaticHandlerContext {
401
- basename: Router$1["basename"];
402
- location: RouterState["location"];
403
- matches: RouterState["matches"];
404
- loaderData: RouterState["loaderData"];
405
- actionData: RouterState["actionData"];
406
- errors: RouterState["errors"];
407
- statusCode: number;
408
- loaderHeaders: Record<string, Headers>;
409
- actionHeaders: Record<string, Headers>;
410
- _deepestRenderedBoundaryId?: string | null;
411
- }
412
- /**
413
- * A StaticHandler instance manages a singular SSR navigation/fetch event
414
- */
415
- interface StaticHandler {
416
- /**
417
- * The set of data routes managed by this handler
418
- */
419
- dataRoutes: DataRouteObject[];
420
- /**
421
- * @private
422
- * PRIVATE - DO NOT USE
423
- *
424
- * The route branches derived from the data routes, used for internal route
425
- * matching in Framework Mode
426
- */
427
- _internalRouteBranches: RouteBranch<DataRouteObject>[];
428
- /**
429
- * Perform a query for a given request - executing all matched route
430
- * loaders/actions. Used for document requests.
431
- *
432
- * @param request The request to query
433
- * @param opts Optional query options
434
- * @param opts.dataStrategy Alternate dataStrategy implementation
435
- * @param opts.filterMatchesToLoad Predicate function to filter which matches should be loaded
436
- * @param opts.generateMiddlewareResponse To enable middleware, provide a function
437
- * to generate a response to bubble back up the middleware chain
438
- * @param opts.requestContext Context object to pass to loaders/actions
439
- * @param opts.skipLoaderErrorBubbling Skip loader error bubbling
440
- * @param opts.skipRevalidation Skip revalidation after action submission
441
- * @param opts.normalizePath Normalize the request path
442
- */
443
- query(request: Request, opts?: {
444
- requestContext?: unknown;
445
- filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
446
- skipLoaderErrorBubbling?: boolean;
447
- skipRevalidation?: boolean;
448
- dataStrategy?: DataStrategyFunction<unknown>;
449
- generateMiddlewareResponse?: (query: (r: Request, args?: {
450
- filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
451
- }) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
452
- normalizePath?: (request: Request) => Path;
453
- }): Promise<StaticHandlerContext | Response>;
454
- /**
455
- * Perform a query for a specific route. Used for resource requests.
456
- *
457
- * @param request The request to query
458
- * @param opts Optional queryRoute options
459
- * @param opts.dataStrategy Alternate dataStrategy implementation
460
- * @param opts.generateMiddlewareResponse To enable middleware, provide a function
461
- * to generate a response to bubble back up the middleware chain
462
- * @param opts.requestContext Context object to pass to loaders/actions
463
- * @param opts.routeId The ID of the route to query
464
- * @param opts.normalizePath Normalize the request path
465
-
466
- */
467
- queryRoute(request: Request, opts?: {
468
- routeId?: string;
469
- requestContext?: unknown;
470
- dataStrategy?: DataStrategyFunction<unknown>;
471
- generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
472
- normalizePath?: (request: Request) => Path;
473
- }): Promise<any>;
474
- }
475
- type ViewTransitionOpts = {
476
- currentLocation: Location;
477
- nextLocation: Location;
478
- };
479
- /**
480
- * Subscriber function signature for changes to router state
481
- */
482
- interface RouterSubscriber {
483
- (state: RouterState, opts: {
484
- deletedFetchers: string[];
485
- newErrors: RouteData | null;
486
- viewTransitionOpts?: ViewTransitionOpts;
487
- flushSync: boolean;
488
- }): void;
489
- }
490
- /**
491
- * Function signature for determining the key to be used in scroll restoration
492
- * for a given location
493
- */
494
- interface GetScrollRestorationKeyFunction {
495
- (location: Location, matches: UIMatch[]): string | null;
496
- }
497
- /**
498
- * Function signature for determining the current scroll position
499
- */
500
- interface GetScrollPositionFunction {
501
- (): number;
502
- }
503
- /**
504
- * - "route": relative to the route hierarchy so `..` means remove all segments
505
- * of the current route even if it has many. For example, a `route("posts/:id")`
506
- * would have both `:id` and `posts` removed from the url.
507
- * - "path": relative to the pathname so `..` means remove one segment of the
508
- * pathname. For example, a `route("posts/:id")` would have only `:id` removed
509
- * from the url.
510
- */
511
- type RelativeRoutingType = "route" | "path";
512
- type BaseNavigateOrFetchOptions = {
513
- preventScrollReset?: boolean;
514
- relative?: RelativeRoutingType;
515
- flushSync?: boolean;
516
- defaultShouldRevalidate?: boolean;
517
- };
518
- type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
519
- replace?: boolean;
520
- state?: any;
521
- fromRouteId?: string;
522
- viewTransition?: boolean;
523
- mask?: To;
524
- };
525
- type BaseSubmissionOptions = {
526
- formMethod?: HTMLFormMethod;
527
- formEncType?: FormEncType;
528
- } & ({
529
- formData: FormData;
530
- body?: undefined;
531
- } | {
532
- formData?: undefined;
533
- body: any;
534
- });
535
- /**
536
- * Options for a navigate() call for a normal (non-submission) navigation
537
- */
538
- type LinkNavigateOptions = BaseNavigateOptions;
539
- /**
540
- * Options for a navigate() call for a submission navigation
541
- */
542
- type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
543
- /**
544
- * Options to pass to navigate() for a navigation
545
- */
546
- type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
547
- /**
548
- * Options for a fetch() load
549
- */
550
- type LoadFetchOptions = BaseNavigateOrFetchOptions;
551
- /**
552
- * Options for a fetch() submission
553
- */
554
- type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
555
- /**
556
- * Options to pass to fetch()
557
- */
558
- type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
559
- /**
560
- * Potential states for state.navigation
561
- */
562
- type NavigationStates = {
563
- Idle: {
564
- state: "idle";
565
- location: undefined;
566
- matches: undefined;
567
- historyAction: undefined;
568
- formMethod: undefined;
569
- formAction: undefined;
570
- formEncType: undefined;
571
- formData: undefined;
572
- json: undefined;
573
- text: undefined;
574
- };
575
- Loading: {
576
- state: "loading";
577
- location: Location;
578
- matches: DataRouteMatch[];
579
- historyAction: Action;
580
- formMethod: Submission["formMethod"] | undefined;
581
- formAction: Submission["formAction"] | undefined;
582
- formEncType: Submission["formEncType"] | undefined;
583
- formData: Submission["formData"] | undefined;
584
- json: Submission["json"] | undefined;
585
- text: Submission["text"] | undefined;
586
- };
587
- Submitting: {
588
- state: "submitting";
589
- location: Location;
590
- matches: DataRouteMatch[];
591
- historyAction: Action;
592
- formMethod: Submission["formMethod"];
593
- formAction: Submission["formAction"];
594
- formEncType: Submission["formEncType"];
595
- formData: Submission["formData"];
596
- json: Submission["json"];
597
- text: Submission["text"];
598
- };
599
- };
600
- type Navigation = NavigationStates[keyof NavigationStates];
601
- type RevalidationState = "idle" | "loading";
602
- /**
603
- * Potential states for fetchers
604
- */
605
- type FetcherStates<TData = any> = {
606
- /**
607
- * The fetcher is not calling a loader or action
608
- *
609
- * ```tsx
610
- * fetcher.state === "idle"
611
- * ```
612
- */
613
- Idle: {
614
- state: "idle";
615
- formMethod: undefined;
616
- formAction: undefined;
617
- formEncType: undefined;
618
- text: undefined;
619
- formData: undefined;
620
- json: undefined;
621
- /**
622
- * If the fetcher has never been called, this will be undefined.
623
- */
624
- data: TData | undefined;
625
- };
626
- /**
627
- * The fetcher is loading data from a {@link LoaderFunction | loader} from a
628
- * call to {@link FetcherWithComponents.load | `fetcher.load`}.
629
- *
630
- * ```tsx
631
- * // somewhere
632
- * <button onClick={() => fetcher.load("/some/route") }>Load</button>
633
- *
634
- * // the state will update
635
- * fetcher.state === "loading"
636
- * ```
637
- */
638
- Loading: {
639
- state: "loading";
640
- formMethod: Submission["formMethod"] | undefined;
641
- formAction: Submission["formAction"] | undefined;
642
- formEncType: Submission["formEncType"] | undefined;
643
- text: Submission["text"] | undefined;
644
- formData: Submission["formData"] | undefined;
645
- json: Submission["json"] | undefined;
646
- data: TData | undefined;
647
- };
648
- /**
649
- The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
650
-
651
- ```tsx
652
- // somewhere
653
- <input
654
- onChange={e => {
655
- fetcher.submit(event.currentTarget.form, { method: "post" });
656
- }}
657
- />
658
-
659
- // the state will update
660
- fetcher.state === "submitting"
661
-
662
- // and formData will be available
663
- fetcher.formData
664
- ```
665
- */
666
- Submitting: {
667
- state: "submitting";
668
- formMethod: Submission["formMethod"];
669
- formAction: Submission["formAction"];
670
- formEncType: Submission["formEncType"];
671
- text: Submission["text"];
672
- formData: Submission["formData"];
673
- json: Submission["json"];
674
- data: TData | undefined;
675
- };
676
- };
677
- type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
678
- interface BlockerBlocked {
679
- state: "blocked";
680
- reset: () => void;
681
- proceed: () => void;
682
- location: Location;
683
- }
684
- interface BlockerUnblocked {
685
- state: "unblocked";
686
- reset: undefined;
687
- proceed: undefined;
688
- location: undefined;
689
- }
690
- interface BlockerProceeding {
691
- state: "proceeding";
692
- reset: undefined;
693
- proceed: undefined;
694
- location: Location;
695
- }
696
- type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
697
- type BlockerFunction = (args: {
698
- currentLocation: Location;
699
- nextLocation: Location;
700
- historyAction: Action;
701
- }) => boolean;
702
- declare const IDLE_NAVIGATION: NavigationStates["Idle"];
703
- declare const IDLE_FETCHER: FetcherStates["Idle"];
704
- declare const IDLE_BLOCKER: BlockerUnblocked;
705
- /**
706
- * Create a router and listen to history POP navigations
707
- */
708
- declare function createRouter(init: RouterInit): Router$1;
709
- interface CreateStaticHandlerOptions {
710
- basename?: string;
711
- mapRouteProperties?: MapRoutePropertiesFunction;
712
- instrumentations?: Pick<ServerInstrumentation, "route">[];
713
- future?: Partial<FutureConfig>;
714
- }
715
-
716
- declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
717
- hasErrorBoundary: boolean;
718
- };
719
- declare const hydrationRouteProperties: (keyof RouteObject)[];
720
- /**
721
- * @category Data Routers
722
- */
723
- interface MemoryRouterOpts {
724
- /**
725
- * Basename path for the application.
726
- */
727
- basename?: string;
728
- /**
729
- * A function that returns an {@link RouterContextProvider} instance
730
- * which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
731
- * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
732
- * This function is called to generate a fresh `context` instance on each
733
- * navigation or fetcher call.
734
- */
735
- getContext?: RouterInit["getContext"];
736
- /**
737
- * Future flags to enable for the router.
738
- */
739
- future?: Partial<FutureConfig>;
740
- /**
741
- * Hydration data to initialize the router with if you have already performed
742
- * data loading on the server.
743
- */
744
- hydrationData?: HydrationState;
745
- /**
746
- * Initial entries in the in-memory history stack
747
- */
748
- initialEntries?: InitialEntry[];
749
- /**
750
- * Index of `initialEntries` the application should initialize to
751
- */
752
- initialIndex?: number;
753
- /**
754
- * Array of instrumentation objects allowing you to instrument the router and
755
- * individual routes prior to router initialization (and on any subsequently
756
- * added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
757
- * mostly useful for observability such as wrapping navigations, fetches,
758
- * as well as route loaders/actions/middlewares with logging and/or performance
759
- * tracing. See the [docs](../../how-to/instrumentation) for more information.
760
- *
761
- * ```tsx
762
- * let router = createBrowserRouter(routes, {
763
- * instrumentations: [logging]
764
- * });
765
- *
766
- *
767
- * let logging = {
768
- * router({ instrument }) {
769
- * instrument({
770
- * navigate: (impl, info) => logExecution(`navigate ${info.to}`, impl),
771
- * fetch: (impl, info) => logExecution(`fetch ${info.to}`, impl)
772
- * });
773
- * },
774
- * route({ instrument, id }) {
775
- * instrument({
776
- * middleware: (impl, info) => logExecution(
777
- * `middleware ${info.request.url} (route ${id})`,
778
- * impl
779
- * ),
780
- * loader: (impl, info) => logExecution(
781
- * `loader ${info.request.url} (route ${id})`,
782
- * impl
783
- * ),
784
- * action: (impl, info) => logExecution(
785
- * `action ${info.request.url} (route ${id})`,
786
- * impl
787
- * ),
788
- * })
789
- * }
790
- * };
791
- *
792
- * async function logExecution(label: string, impl: () => Promise<void>) {
793
- * let start = performance.now();
794
- * console.log(`start ${label}`);
795
- * await impl();
796
- * let duration = Math.round(performance.now() - start);
797
- * console.log(`end ${label} (${duration}ms)`);
798
- * }
799
- * ```
800
- */
801
- instrumentations?: ClientInstrumentation[];
802
- /**
803
- * Override the default data strategy of running loaders in parallel -
804
- * see the [docs](../../how-to/data-strategy) for more information.
805
- *
806
- * ```tsx
807
- * let router = createBrowserRouter(routes, {
808
- * async dataStrategy({
809
- * matches,
810
- * request,
811
- * runClientMiddleware,
812
- * }) {
813
- * const matchesToLoad = matches.filter((m) =>
814
- * m.shouldCallHandler(),
815
- * );
816
- *
817
- * const results: Record<string, DataStrategyResult> = {};
818
- * await runClientMiddleware(() =>
819
- * Promise.all(
820
- * matchesToLoad.map(async (match) => {
821
- * results[match.route.id] = await match.resolve();
822
- * }),
823
- * ),
824
- * );
825
- * return results;
826
- * },
827
- * });
828
- * ```
829
- */
830
- dataStrategy?: DataStrategyFunction;
831
- /**
832
- * Lazily define portions of the route tree on navigations.
833
- */
834
- patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
835
- }
836
- /**
837
- * Create a new {@link DataRouter} that manages the application path using an
838
- * in-memory [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
839
- * stack. Useful for non-browser environments without a DOM API.
840
- *
841
- * @public
842
- * @category Data Routers
843
- * @mode data
844
- * @param routes Application routes
845
- * @param opts Options
846
- * @param {MemoryRouterOpts.basename} opts.basename n/a
847
- * @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
848
- * @param {MemoryRouterOpts.future} opts.future n/a
849
- * @param {MemoryRouterOpts.getContext} opts.getContext n/a
850
- * @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
851
- * @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
852
- * @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
853
- * @param {MemoryRouterOpts.instrumentations} opts.instrumentations n/a
854
- * @param {MemoryRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
855
- * @returns An initialized {@link DataRouter} to pass to {@link RouterProvider | `<RouterProvider>`}
856
- */
857
- declare function createMemoryRouter(routes: RouteObject[], opts?: MemoryRouterOpts): Router$1;
858
- /**
859
- * Function signature for client side error handling for loader/actions errors
860
- * and rendering errors via `componentDidCatch`
861
- */
862
- interface ClientOnErrorFunction {
863
- (error: unknown, info: {
864
- location: Location;
865
- params: Params;
866
- pattern: string;
867
- errorInfo?: React.ErrorInfo;
868
- }): void;
869
- }
870
- /**
871
- * @category Types
872
- */
873
- interface RouterProviderProps {
874
- /**
875
- * The {@link DataRouter} instance to use for navigation and data fetching.
876
- */
877
- router: Router$1;
878
- /**
879
- * The [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
880
- * implementation to use for flushing updates.
881
- *
882
- * You usually don't have to worry about this:
883
- * - The `RouterProvider` exported from `react-router/dom` handles this internally for you
884
- * - If you are rendering in a non-DOM environment, you can import
885
- * `RouterProvider` from `react-router` and ignore this prop
886
- */
887
- flushSync?: (fn: () => unknown) => undefined;
888
- /**
889
- * An error handler function that will be called for any middleware, loader, action,
890
- * or render errors that are encountered in your application. This is useful for
891
- * logging or reporting errors instead of in the {@link ErrorBoundary} because it's not
892
- * subject to re-rendering and will only run one time per error.
893
- *
894
- * The `errorInfo` parameter is passed along from
895
- * [`componentDidCatch`](https://react.dev/reference/react/Component#componentdidcatch)
896
- * and is only present for render errors.
897
- *
898
- * ```tsx
899
- * <RouterProvider onError=(error, info) => {
900
- * let { location, params, pattern, errorInfo } = info;
901
- * console.error(error, location, errorInfo);
902
- * reportToErrorService(error, location, errorInfo);
903
- * }} />
904
- * ```
905
- */
906
- onError?: ClientOnErrorFunction;
907
- /**
908
- * Control whether router state updates are internally wrapped in
909
- * [`React.startTransition`](https://react.dev/reference/react/startTransition).
910
- *
911
- * - When left `undefined`, all state updates are wrapped in
912
- * `React.startTransition`
913
- * - This can lead to buggy behaviors if you are wrapping your own
914
- * navigations/fetchers in `startTransition`.
915
- * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
916
- * in `React.startTransition` and router state changes will be wrapped in
917
- * `React.startTransition` and also sent through
918
- * [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
919
- * surface mid-navigation router state changes to the UI.
920
- * - When set to `false`, the router will not leverage `React.startTransition` or
921
- * `React.useOptimistic` on any navigations or state changes.
922
- *
923
- * For more information, please see the [docs](../../explanation/react-transitions).
924
- */
925
- useTransitions?: boolean;
926
- }
927
- /**
928
- * Render the UI for the given {@link DataRouter}. This component should
929
- * typically be at the top of an app's element tree.
930
- *
931
- * ```tsx
932
- * import { createBrowserRouter } from "react-router";
933
- * import { RouterProvider } from "react-router/dom";
934
- * import { createRoot } from "react-dom/client";
935
- *
936
- * const router = createBrowserRouter(routes);
937
- * createRoot(document.getElementById("root")).render(
938
- * <RouterProvider router={router} />
939
- * );
940
- * ```
941
- *
942
- * <docs-info>Please note that this component is exported both from
943
- * `react-router` and `react-router/dom` with the only difference being that the
944
- * latter automatically wires up `react-dom`'s [`flushSync`](https://react.dev/reference/react-dom/flushSync)
945
- * implementation. You _almost always_ want to use the version from
946
- * `react-router/dom` unless you're running in a non-DOM environment.</docs-info>
947
- *
948
- *
949
- * @public
950
- * @category Data Routers
951
- * @mode data
952
- * @param props Props
953
- * @param {RouterProviderProps.flushSync} props.flushSync n/a
954
- * @param {RouterProviderProps.onError} props.onError n/a
955
- * @param {RouterProviderProps.router} props.router n/a
956
- * @param {RouterProviderProps.useTransitions} props.useTransitions n/a
957
- * @returns React element for the rendered router
958
- */
959
- declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, useTransitions, }: RouterProviderProps): React.ReactElement;
960
- /**
961
- * @category Types
962
- */
963
- interface MemoryRouterProps {
964
- /**
965
- * Application basename
966
- */
967
- basename?: string;
968
- /**
969
- * Nested {@link Route} elements describing the route tree
970
- */
971
- children?: React.ReactNode;
972
- /**
973
- * Initial entries in the in-memory history stack
974
- */
975
- initialEntries?: InitialEntry[];
976
- /**
977
- * Index of `initialEntries` the application should initialize to
978
- */
979
- initialIndex?: number;
980
- /**
981
- * Control whether router state updates are internally wrapped in
982
- * [`React.startTransition`](https://react.dev/reference/react/startTransition).
983
- *
984
- * - When left `undefined`, all router state updates are wrapped in
985
- * `React.startTransition`
986
- * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
987
- * in `React.startTransition` and all router state updates are wrapped in
988
- * `React.startTransition`
989
- * - When set to `false`, the router will not leverage `React.startTransition`
990
- * on any navigations or state changes.
991
- *
992
- * For more information, please see the [docs](../../explanation/react-transitions).
993
- */
994
- useTransitions?: boolean;
995
- }
996
- /**
997
- * A declarative {@link Router | `<Router>`} that stores all entries in memory.
998
- *
999
- * @public
1000
- * @category Declarative Routers
1001
- * @mode declarative
1002
- * @param props Props
1003
- * @param {MemoryRouterProps.basename} props.basename n/a
1004
- * @param {MemoryRouterProps.children} props.children n/a
1005
- * @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
1006
- * @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
1007
- * @param {MemoryRouterProps.useTransitions} props.useTransitions n/a
1008
- * @returns A declarative in-memory {@link Router | `<Router>`} for client-side
1009
- * routing.
1010
- */
1011
- declare function MemoryRouter({ basename, children, initialEntries, initialIndex, useTransitions, }: MemoryRouterProps): React.ReactElement;
1012
- /**
1013
- * @category Types
1014
- */
1015
- interface NavigateProps {
1016
- /**
1017
- * The path to navigate to. This can be a string or a {@link Path} object
1018
- */
1019
- to: To;
1020
- /**
1021
- * Whether to replace the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1022
- * stack
1023
- */
1024
- replace?: boolean;
1025
- /**
1026
- * State to pass to the new {@link Location} to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
1027
- */
1028
- state?: any;
1029
- /**
1030
- * How to interpret relative routing in the `to` prop.
1031
- * See {@link RelativeRoutingType}.
1032
- */
1033
- relative?: RelativeRoutingType;
1034
- }
1035
- /**
1036
- * A component-based version of {@link useNavigate} to use in a
1037
- * [`React.Component` class](https://react.dev/reference/react/Component) where
1038
- * hooks cannot be used.
1039
- *
1040
- * It's recommended to avoid using this component in favor of {@link useNavigate}.
1041
- *
1042
- * @example
1043
- * <Navigate to="/tasks" />
1044
- *
1045
- * @public
1046
- * @category Components
1047
- * @param props Props
1048
- * @param {NavigateProps.relative} props.relative n/a
1049
- * @param {NavigateProps.replace} props.replace n/a
1050
- * @param {NavigateProps.state} props.state n/a
1051
- * @param {NavigateProps.to} props.to n/a
1052
- * @returns {void}
1053
- *
1054
- */
1055
- declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
1056
- /**
1057
- * @category Types
1058
- */
1059
- interface OutletProps {
1060
- /**
1061
- * Provides a context value to the element tree below the outlet. Use when
1062
- * the parent route needs to provide values to child routes.
1063
- *
1064
- * ```tsx
1065
- * <Outlet context={myContextValue} />
1066
- * ```
1067
- *
1068
- * Access the context with {@link useOutletContext}.
1069
- */
1070
- context?: unknown;
1071
- }
1072
- /**
1073
- * Renders the matching child route of a parent route or nothing if no child
1074
- * route matches.
1075
- *
1076
- * @example
1077
- * import { Outlet } from "react-router";
1078
- *
1079
- * export default function SomeParent() {
1080
- * return (
1081
- * <div>
1082
- * <h1>Parent Content</h1>
1083
- * <Outlet />
1084
- * </div>
1085
- * );
1086
- * }
1087
- *
1088
- * @public
1089
- * @category Components
1090
- * @param props Props
1091
- * @param {OutletProps.context} props.context n/a
1092
- * @returns React element for the rendered outlet or `null` if no child route matches.
1093
- */
1094
- declare function Outlet(props: OutletProps): React.ReactElement | null;
1095
- /**
1096
- * @category Types
1097
- */
1098
- interface PathRouteProps {
1099
- /**
1100
- * Whether the path should be case-sensitive. Defaults to `false`.
1101
- */
1102
- caseSensitive?: NonIndexRouteObject["caseSensitive"];
1103
- /**
1104
- * The path pattern to match. If unspecified or empty, then this becomes a
1105
- * layout route.
1106
- */
1107
- path?: NonIndexRouteObject["path"];
1108
- /**
1109
- * The unique identifier for this route (for use with {@link DataRouter}s)
1110
- */
1111
- id?: NonIndexRouteObject["id"];
1112
- /**
1113
- * A function that returns a promise that resolves to the route object.
1114
- * Used for code-splitting routes.
1115
- * See [`lazy`](../../start/data/route-object#lazy).
1116
- */
1117
- lazy?: LazyRouteFunction<NonIndexRouteObject>;
1118
- /**
1119
- * The route middleware.
1120
- * See [`middleware`](../../start/data/route-object#middleware).
1121
- */
1122
- middleware?: NonIndexRouteObject["middleware"];
1123
- /**
1124
- * The route loader.
1125
- * See [`loader`](../../start/data/route-object#loader).
1126
- */
1127
- loader?: NonIndexRouteObject["loader"];
1128
- /**
1129
- * The route action.
1130
- * See [`action`](../../start/data/route-object#action).
1131
- */
1132
- action?: NonIndexRouteObject["action"];
1133
- hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
1134
- /**
1135
- * The route shouldRevalidate function.
1136
- * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
1137
- */
1138
- shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
1139
- /**
1140
- * The route handle.
1141
- */
1142
- handle?: NonIndexRouteObject["handle"];
1143
- /**
1144
- * Whether this is an index route.
1145
- */
1146
- index?: false;
1147
- /**
1148
- * Child Route components
1149
- */
1150
- children?: React.ReactNode;
1151
- /**
1152
- * The React element to render when this Route matches.
1153
- * Mutually exclusive with `Component`.
1154
- */
1155
- element?: React.ReactNode | null;
1156
- /**
1157
- * The React element to render while this router is loading data.
1158
- * Mutually exclusive with `HydrateFallback`.
1159
- */
1160
- hydrateFallbackElement?: React.ReactNode | null;
1161
- /**
1162
- * The React element to render at this route if an error occurs.
1163
- * Mutually exclusive with `ErrorBoundary`.
1164
- */
1165
- errorElement?: React.ReactNode | null;
1166
- /**
1167
- * The React Component to render when this route matches.
1168
- * Mutually exclusive with `element`.
1169
- */
1170
- Component?: React.ComponentType | null;
1171
- /**
1172
- * The React Component to render while this router is loading data.
1173
- * Mutually exclusive with `hydrateFallbackElement`.
1174
- */
1175
- HydrateFallback?: React.ComponentType | null;
1176
- /**
1177
- * The React Component to render at this route if an error occurs.
1178
- * Mutually exclusive with `errorElement`.
1179
- */
1180
- ErrorBoundary?: React.ComponentType | null;
1181
- }
1182
- /**
1183
- * @category Types
1184
- */
1185
- interface LayoutRouteProps extends PathRouteProps {
1186
- }
1187
- /**
1188
- * @category Types
1189
- */
1190
- interface IndexRouteProps {
1191
- /**
1192
- * Whether the path should be case-sensitive. Defaults to `false`.
1193
- */
1194
- caseSensitive?: IndexRouteObject["caseSensitive"];
1195
- /**
1196
- * The path pattern to match. If unspecified or empty, then this becomes a
1197
- * layout route.
1198
- */
1199
- path?: IndexRouteObject["path"];
1200
- /**
1201
- * The unique identifier for this route (for use with {@link DataRouter}s)
1202
- */
1203
- id?: IndexRouteObject["id"];
1204
- /**
1205
- * A function that returns a promise that resolves to the route object.
1206
- * Used for code-splitting routes.
1207
- * See [`lazy`](../../start/data/route-object#lazy).
1208
- */
1209
- lazy?: LazyRouteFunction<IndexRouteObject>;
1210
- /**
1211
- * The route middleware.
1212
- * See [`middleware`](../../start/data/route-object#middleware).
1213
- */
1214
- middleware?: IndexRouteObject["middleware"];
1215
- /**
1216
- * The route loader.
1217
- * See [`loader`](../../start/data/route-object#loader).
1218
- */
1219
- loader?: IndexRouteObject["loader"];
1220
- /**
1221
- * The route action.
1222
- * See [`action`](../../start/data/route-object#action).
1223
- */
1224
- action?: IndexRouteObject["action"];
1225
- hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
1226
- /**
1227
- * The route shouldRevalidate function.
1228
- * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
1229
- */
1230
- shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
1231
- /**
1232
- * The route handle.
1233
- */
1234
- handle?: IndexRouteObject["handle"];
1235
- /**
1236
- * Whether this is an index route.
1237
- */
1238
- index: true;
1239
- /**
1240
- * Child Route components
1241
- */
1242
- children?: undefined;
1243
- /**
1244
- * The React element to render when this Route matches.
1245
- * Mutually exclusive with `Component`.
1246
- */
1247
- element?: React.ReactNode | null;
1248
- /**
1249
- * The React element to render while this router is loading data.
1250
- * Mutually exclusive with `HydrateFallback`.
1251
- */
1252
- hydrateFallbackElement?: React.ReactNode | null;
1253
- /**
1254
- * The React element to render at this route if an error occurs.
1255
- * Mutually exclusive with `ErrorBoundary`.
1256
- */
1257
- errorElement?: React.ReactNode | null;
1258
- /**
1259
- * The React Component to render when this route matches.
1260
- * Mutually exclusive with `element`.
1261
- */
1262
- Component?: React.ComponentType | null;
1263
- /**
1264
- * The React Component to render while this router is loading data.
1265
- * Mutually exclusive with `hydrateFallbackElement`.
1266
- */
1267
- HydrateFallback?: React.ComponentType | null;
1268
- /**
1269
- * The React Component to render at this route if an error occurs.
1270
- * Mutually exclusive with `errorElement`.
1271
- */
1272
- ErrorBoundary?: React.ComponentType | null;
1273
- }
1274
- /**
1275
- * @category Types
1276
- */
1277
- type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
1278
- /**
1279
- * Configures an element to render when a pattern matches the current location.
1280
- * It must be rendered within a {@link Routes} element. Note that these routes
1281
- * do not participate in data loading, actions, code splitting, or any other
1282
- * route module features.
1283
- *
1284
- * @example
1285
- * // Usually used in a declarative router
1286
- * function App() {
1287
- * return (
1288
- * <BrowserRouter>
1289
- * <Routes>
1290
- * <Route index element={<StepOne />} />
1291
- * <Route path="step-2" element={<StepTwo />} />
1292
- * <Route path="step-3" element={<StepThree />} />
1293
- * </Routes>
1294
- * </BrowserRouter>
1295
- * );
1296
- * }
1297
- *
1298
- * // But can be used with a data router as well if you prefer the JSX notation
1299
- * const routes = createRoutesFromElements(
1300
- * <>
1301
- * <Route index loader={step1Loader} Component={StepOne} />
1302
- * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
1303
- * <Route path="step-3" loader={step3Loader} Component={StepThree} />
1304
- * </>
1305
- * );
1306
- *
1307
- * const router = createBrowserRouter(routes);
1308
- *
1309
- * function App() {
1310
- * return <RouterProvider router={router} />;
1311
- * }
1312
- *
1313
- * @public
1314
- * @category Components
1315
- * @param props Props
1316
- * @param {PathRouteProps.action} props.action n/a
1317
- * @param {PathRouteProps.caseSensitive} props.caseSensitive n/a
1318
- * @param {PathRouteProps.Component} props.Component n/a
1319
- * @param {PathRouteProps.children} props.children n/a
1320
- * @param {PathRouteProps.element} props.element n/a
1321
- * @param {PathRouteProps.ErrorBoundary} props.ErrorBoundary n/a
1322
- * @param {PathRouteProps.errorElement} props.errorElement n/a
1323
- * @param {PathRouteProps.handle} props.handle n/a
1324
- * @param {PathRouteProps.HydrateFallback} props.HydrateFallback n/a
1325
- * @param {PathRouteProps.hydrateFallbackElement} props.hydrateFallbackElement n/a
1326
- * @param {PathRouteProps.id} props.id n/a
1327
- * @param {PathRouteProps.index} props.index n/a
1328
- * @param {PathRouteProps.lazy} props.lazy n/a
1329
- * @param {PathRouteProps.loader} props.loader n/a
1330
- * @param {PathRouteProps.path} props.path n/a
1331
- * @param {PathRouteProps.shouldRevalidate} props.shouldRevalidate n/a
1332
- * @returns {void}
1333
- */
1334
- declare function Route(props: RouteProps): React.ReactElement | null;
1335
- /**
1336
- * @category Types
1337
- */
1338
- interface RouterProps {
1339
- /**
1340
- * The base path for the application. This is prepended to all locations
1341
- */
1342
- basename?: string;
1343
- /**
1344
- * Nested {@link Route} elements describing the route tree
1345
- */
1346
- children?: React.ReactNode;
1347
- /**
1348
- * The location to match against. Defaults to the current location.
1349
- * This can be a string or a {@link Location} object.
1350
- */
1351
- location: Partial<Location> | string;
1352
- /**
1353
- * The type of navigation that triggered this `location` change.
1354
- * Defaults to {@link NavigationType.Pop}.
1355
- */
1356
- navigationType?: Action;
1357
- /**
1358
- * The navigator to use for navigation. This is usually a history object
1359
- * or a custom navigator that implements the {@link Navigator} interface.
1360
- */
1361
- navigator: Navigator;
1362
- /**
1363
- * Whether this router is static or not (used for SSR). If `true`, the router
1364
- * will not be reactive to location changes.
1365
- */
1366
- static?: boolean;
1367
- /**
1368
- * Control whether router state updates are internally wrapped in
1369
- * [`React.startTransition`](https://react.dev/reference/react/startTransition).
1370
- *
1371
- * - When left `undefined`, all router state updates are wrapped in
1372
- * `React.startTransition`
1373
- * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
1374
- * in `React.startTransition` and all router state updates are wrapped in
1375
- * `React.startTransition`
1376
- * - When set to `false`, the router will not leverage `React.startTransition`
1377
- * on any navigations or state changes.
1378
- *
1379
- * For more information, please see the [docs](../../explanation/react-transitions).
1380
- */
1381
- useTransitions?: boolean;
1382
- }
1383
- /**
1384
- * Provides location context for the rest of the app.
1385
- *
1386
- * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
1387
- * router that is more specific to your environment such as a {@link BrowserRouter}
1388
- * in web browsers or a {@link ServerRouter} for server rendering.
1389
- *
1390
- * @public
1391
- * @category Declarative Routers
1392
- * @mode declarative
1393
- * @param props Props
1394
- * @param {RouterProps.basename} props.basename n/a
1395
- * @param {RouterProps.children} props.children n/a
1396
- * @param {RouterProps.location} props.location n/a
1397
- * @param {RouterProps.navigationType} props.navigationType n/a
1398
- * @param {RouterProps.navigator} props.navigator n/a
1399
- * @param {RouterProps.static} props.static n/a
1400
- * @param {RouterProps.useTransitions} props.useTransitions n/a
1401
- * @returns React element for the rendered router or `null` if the location does
1402
- * not match the {@link props.basename}
1403
- */
1404
- declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, useTransitions, }: RouterProps): React.ReactElement | null;
1405
- /**
1406
- * @category Types
1407
- */
1408
- interface RoutesProps {
1409
- /**
1410
- * Nested {@link Route} elements
1411
- */
1412
- children?: React.ReactNode;
1413
- /**
1414
- * The {@link Location} to match against. Defaults to the current location.
1415
- */
1416
- location?: Partial<Location> | string;
1417
- }
1418
- /**
1419
- * Renders a branch of {@link Route | `<Route>`s} that best matches the current
1420
- * location. Note that these routes do not participate in [data loading](../../start/framework/route-module#loader),
1421
- * [`action`](../../start/framework/route-module#action), code splitting, or
1422
- * any other [route module](../../start/framework/route-module) features.
1423
- *
1424
- * @example
1425
- * import { Route, Routes } from "react-router";
1426
- *
1427
- * <Routes>
1428
- * <Route index element={<StepOne />} />
1429
- * <Route path="step-2" element={<StepTwo />} />
1430
- * <Route path="step-3" element={<StepThree />} />
1431
- * </Routes>
1432
- *
1433
- * @public
1434
- * @category Components
1435
- * @param props Props
1436
- * @param {RoutesProps.children} props.children n/a
1437
- * @param {RoutesProps.location} props.location n/a
1438
- * @returns React element for the rendered routes or `null` if no route matches
1439
- */
1440
- declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
1441
- interface AwaitResolveRenderFunction<Resolve = any> {
1442
- (data: Awaited<Resolve>): React.ReactNode;
1443
- }
1444
- /**
1445
- * @category Types
1446
- */
1447
- interface AwaitProps<Resolve> {
1448
- /**
1449
- * When using a function, the resolved value is provided as the parameter.
1450
- *
1451
- * ```tsx [2]
1452
- * <Await resolve={reviewsPromise}>
1453
- * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
1454
- * </Await>
1455
- * ```
1456
- *
1457
- * When using React elements, {@link useAsyncValue} will provide the
1458
- * resolved value:
1459
- *
1460
- * ```tsx [2]
1461
- * <Await resolve={reviewsPromise}>
1462
- * <Reviews />
1463
- * </Await>
1464
- *
1465
- * function Reviews() {
1466
- * const resolvedReviews = useAsyncValue();
1467
- * return <div>...</div>;
1468
- * }
1469
- * ```
1470
- */
1471
- children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
1472
- /**
1473
- * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1474
- * rejects.
1475
- *
1476
- * ```tsx
1477
- * <Await
1478
- * errorElement={<div>Oops</div>}
1479
- * resolve={reviewsPromise}
1480
- * >
1481
- * <Reviews />
1482
- * </Await>
1483
- * ```
1484
- *
1485
- * To provide a more contextual error, you can use the {@link useAsyncError} in a
1486
- * child component
1487
- *
1488
- * ```tsx
1489
- * <Await
1490
- * errorElement={<ReviewsError />}
1491
- * resolve={reviewsPromise}
1492
- * >
1493
- * <Reviews />
1494
- * </Await>
1495
- *
1496
- * function ReviewsError() {
1497
- * const error = useAsyncError();
1498
- * return <div>Error loading reviews: {error.message}</div>;
1499
- * }
1500
- * ```
1501
- *
1502
- * If you do not provide an `errorElement`, the rejected value will bubble up
1503
- * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
1504
- * and be accessible via the {@link useRouteError} hook.
1505
- */
1506
- errorElement?: React.ReactNode;
1507
- /**
1508
- * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1509
- * returned from a [`loader`](../../start/framework/route-module#loader) to be
1510
- * resolved and rendered.
1511
- *
1512
- * ```tsx
1513
- * import { Await, useLoaderData } from "react-router";
1514
- *
1515
- * export async function loader() {
1516
- * let reviews = getReviews(); // not awaited
1517
- * let book = await getBook();
1518
- * return {
1519
- * book,
1520
- * reviews, // this is a promise
1521
- * };
1522
- * }
1523
- *
1524
- * export default function Book() {
1525
- * const {
1526
- * book,
1527
- * reviews, // this is the same promise
1528
- * } = useLoaderData();
1529
- *
1530
- * return (
1531
- * <div>
1532
- * <h1>{book.title}</h1>
1533
- * <p>{book.description}</p>
1534
- * <React.Suspense fallback={<ReviewsSkeleton />}>
1535
- * <Await
1536
- * // and is the promise we pass to Await
1537
- * resolve={reviews}
1538
- * >
1539
- * <Reviews />
1540
- * </Await>
1541
- * </React.Suspense>
1542
- * </div>
1543
- * );
1544
- * }
1545
- * ```
1546
- */
1547
- resolve: Resolve;
1548
- }
1549
- /**
1550
- * Used to render promise values with automatic error handling.
1551
- *
1552
- * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
1553
- *
1554
- * @example
1555
- * import { Await, useLoaderData } from "react-router";
1556
- *
1557
- * export async function loader() {
1558
- * // not awaited
1559
- * const reviews = getReviews();
1560
- * // awaited (blocks the transition)
1561
- * const book = await fetch("/api/book").then((res) => res.json());
1562
- * return { book, reviews };
1563
- * }
1564
- *
1565
- * function Book() {
1566
- * const { book, reviews } = useLoaderData();
1567
- * return (
1568
- * <div>
1569
- * <h1>{book.title}</h1>
1570
- * <p>{book.description}</p>
1571
- * <React.Suspense fallback={<ReviewsSkeleton />}>
1572
- * <Await
1573
- * resolve={reviews}
1574
- * errorElement={
1575
- * <div>Could not load reviews 😬</div>
1576
- * }
1577
- * children={(resolvedReviews) => (
1578
- * <Reviews items={resolvedReviews} />
1579
- * )}
1580
- * />
1581
- * </React.Suspense>
1582
- * </div>
1583
- * );
1584
- * }
1585
- *
1586
- * @public
1587
- * @category Components
1588
- * @mode framework
1589
- * @mode data
1590
- * @param props Props
1591
- * @param {AwaitProps.children} props.children n/a
1592
- * @param {AwaitProps.errorElement} props.errorElement n/a
1593
- * @param {AwaitProps.resolve} props.resolve n/a
1594
- * @returns React element for the rendered awaited value
1595
- */
1596
- declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
1597
- /**
1598
- * Creates a route config from a React "children" object, which is usually
1599
- * either a `<Route>` element or an array of them. Used internally by
1600
- * `<Routes>` to create a route config from its children.
1601
- *
1602
- * @category Utils
1603
- * @mode data
1604
- * @param children The React children to convert into a route config
1605
- * @param parentPath The path of the parent route, used to generate unique IDs.
1606
- * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
1607
- */
1608
- declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
1609
- /**
1610
- * Create route objects from JSX elements instead of arrays of objects.
1611
- *
1612
- * @example
1613
- * const routes = createRoutesFromElements(
1614
- * <>
1615
- * <Route index loader={step1Loader} Component={StepOne} />
1616
- * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
1617
- * <Route path="step-3" loader={step3Loader} Component={StepThree} />
1618
- * </>
1619
- * );
1620
- *
1621
- * const router = createBrowserRouter(routes);
1622
- *
1623
- * function App() {
1624
- * return <RouterProvider router={router} />;
1625
- * }
1626
- *
1627
- * @name createRoutesFromElements
1628
- * @public
1629
- * @category Utils
1630
- * @mode data
1631
- * @param children The React children to convert into a route config
1632
- * @param parentPath The path of the parent route, used to generate unique IDs.
1633
- * This is used for internal recursion and is not intended to be used by the
1634
- * application developer.
1635
- * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
1636
- */
1637
- declare const createRoutesFromElements: typeof createRoutesFromChildren;
1638
- /**
1639
- * Renders the result of {@link matchRoutes} into a React element.
1640
- *
1641
- * @public
1642
- * @category Utils
1643
- * @param matches The array of {@link RouteMatch | route matches} to render
1644
- * @returns A React element that renders the matched routes or `null` if no matches
1645
- */
1646
- declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
1647
- declare function useRouteComponentProps(): {
1648
- params: Readonly<Params<string>>;
1649
- loaderData: any;
1650
- actionData: any;
1651
- matches: UIMatch<unknown, unknown>[];
1652
- };
1653
- type RouteComponentProps = ReturnType<typeof useRouteComponentProps>;
1654
- type RouteComponentType = React.ComponentType<RouteComponentProps>;
1655
- declare function WithComponentProps({ children, }: {
1656
- children: React.ReactElement;
1657
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
1658
- declare function withComponentProps(Component: RouteComponentType): () => React.ReactElement<{
1659
- params: Readonly<Params<string>>;
1660
- loaderData: any;
1661
- actionData: any;
1662
- matches: UIMatch<unknown, unknown>[];
1663
- }, string | React.JSXElementConstructor<any>>;
1664
- declare function useHydrateFallbackProps(): {
1665
- params: Readonly<Params<string>>;
1666
- loaderData: any;
1667
- actionData: any;
1668
- };
1669
- type HydrateFallbackProps = ReturnType<typeof useHydrateFallbackProps>;
1670
- type HydrateFallbackType = React.ComponentType<HydrateFallbackProps>;
1671
- declare function WithHydrateFallbackProps({ children, }: {
1672
- children: React.ReactElement;
1673
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
1674
- declare function withHydrateFallbackProps(HydrateFallback: HydrateFallbackType): () => React.ReactElement<{
1675
- params: Readonly<Params<string>>;
1676
- loaderData: any;
1677
- actionData: any;
1678
- }, string | React.JSXElementConstructor<any>>;
1679
- declare function useErrorBoundaryProps(): {
1680
- params: Readonly<Params<string>>;
1681
- loaderData: any;
1682
- actionData: any;
1683
- error: unknown;
1684
- };
1685
- type ErrorBoundaryProps = ReturnType<typeof useErrorBoundaryProps>;
1686
- type ErrorBoundaryType = React.ComponentType<ErrorBoundaryProps>;
1687
- declare function WithErrorBoundaryProps({ children, }: {
1688
- children: React.ReactElement;
1689
- }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
1690
- declare function withErrorBoundaryProps(ErrorBoundary: ErrorBoundaryType): () => React.ReactElement<{
1691
- params: Readonly<Params<string>>;
1692
- loaderData: any;
1693
- actionData: any;
1694
- error: unknown;
1695
- }, string | React.JSXElementConstructor<any>>;
1696
-
1697
- interface DataRouterContextObject extends Omit<NavigationContextObject, "future" | "useTransitions"> {
1698
- router: Router$1;
1699
- staticContext?: StaticHandlerContext;
1700
- onError?: ClientOnErrorFunction;
1701
- }
1702
- declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
1703
- declare const DataRouterStateContext: React.Context<RouterState | null>;
1704
- type ViewTransitionContextObject = {
1705
- isTransitioning: false;
1706
- } | {
1707
- isTransitioning: true;
1708
- flushSync: boolean;
1709
- currentLocation: Location;
1710
- nextLocation: Location;
1711
- };
1712
- declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
1713
- type FetchersContextObject = Map<string, any>;
1714
- declare const FetchersContext: React.Context<FetchersContextObject>;
1715
- declare const AwaitContext: React.Context<TrackedPromise | null>;
1716
- declare const AwaitContextProvider: (props: React.ComponentProps<typeof AwaitContext.Provider>) => React.FunctionComponentElement<React.ProviderProps<TrackedPromise | null>>;
1717
- interface NavigateOptions {
1718
- /** Replace the current entry in the history stack instead of pushing a new one */
1719
- replace?: boolean;
1720
- /** Masked URL */
1721
- mask?: To;
1722
- /** Adds persistent client side routing state to the next location */
1723
- state?: any;
1724
- /** If you are using {@link ScrollRestoration `<ScrollRestoration>`}, prevent the scroll position from being reset to the top of the window when navigating */
1725
- preventScrollReset?: boolean;
1726
- /** Defines the relative path behavior for the link. "route" will use the route hierarchy so ".." will remove all URL segments of the current route pattern while "path" will use the URL path so ".." will remove one URL segment. */
1727
- relative?: RelativeRoutingType;
1728
- /** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
1729
- flushSync?: boolean;
1730
- /** Enables a {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API View Transition} for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the {@link useViewTransitionState `useViewTransitionState()`} hook. */
1731
- viewTransition?: boolean;
1732
- /** Specifies the default revalidation behavior after this submission */
1733
- defaultShouldRevalidate?: boolean;
1734
- }
1735
- /**
1736
- * A Navigator is a "location changer"; it's how you get to different locations.
1737
- *
1738
- * Every history instance conforms to the Navigator interface, but the
1739
- * distinction is useful primarily when it comes to the low-level `<Router>` API
1740
- * where both the location and a navigator must be provided separately in order
1741
- * to avoid "tearing" that may occur in a suspense-enabled app if the action
1742
- * and/or location were to be read directly from the history instance.
1743
- */
1744
- interface Navigator {
1745
- createHref: History["createHref"];
1746
- encodeLocation?: History["encodeLocation"];
1747
- go: History["go"];
1748
- push(to: To, state?: any, opts?: NavigateOptions): void;
1749
- replace(to: To, state?: any, opts?: NavigateOptions): void;
1750
- }
1751
- interface NavigationContextObject {
1752
- basename: string;
1753
- navigator: Navigator;
1754
- static: boolean;
1755
- useTransitions: boolean | undefined;
1756
- future: {};
1757
- }
1758
- declare const NavigationContext: React.Context<NavigationContextObject>;
1759
- interface LocationContextObject {
1760
- location: Location;
1761
- navigationType: Action;
1762
- }
1763
- declare const LocationContext: React.Context<LocationContextObject>;
1764
- interface RouteContextObject {
1765
- outlet: React.ReactElement | null;
1766
- matches: RouteMatch[];
1767
- isDataRoute: boolean;
1768
- }
1769
- declare const RouteContext: React.Context<RouteContextObject>;
1770
-
1771
- export { createRoutesFromElements as $, AwaitContextProvider as A, type BlockerFunction as B, type ClientInstrumentation as C, type RouteProps as D, type RouterProps as E, type Fetcher as F, type GetScrollPositionFunction as G, type HydrationState as H, type InstrumentRequestHandlerFunction as I, type RoutesProps as J, Await as K, type LayoutRouteProps as L, type MemoryRouterOpts as M, type NavigateOptions as N, type OutletProps as O, type PathRouteProps as P, MemoryRouter as Q, type RouterInit as R, type StaticHandler as S, Navigate as T, Outlet as U, Route as V, Router as W, RouterProvider as X, Routes as Y, createMemoryRouter as Z, createRoutesFromChildren as _, type RouterProviderProps as a, renderMatches as a0, createRouter as a1, DataRouterContext as a2, DataRouterStateContext as a3, FetchersContext as a4, LocationContext as a5, NavigationContext as a6, RouteContext as a7, ViewTransitionContext as a8, hydrationRouteProperties as a9, mapRouteProperties as aa, WithComponentProps as ab, withComponentProps as ac, WithHydrateFallbackProps as ad, withHydrateFallbackProps as ae, WithErrorBoundaryProps as af, withErrorBoundaryProps as ag, type FutureConfig as ah, type CreateStaticHandlerOptions as ai, type ClientOnErrorFunction as b, type Router$1 as c, type NavigationStates as d, type Blocker as e, type RelativeRoutingType as f, type RouterState as g, type GetScrollRestorationKeyFunction as h, type StaticHandlerContext as i, type Navigation as j, type RouterSubscriber as k, type RouterNavigateOptions as l, type RouterFetchOptions as m, type RevalidationState as n, type ServerInstrumentation as o, type InstrumentRouterFunction as p, type InstrumentRouteFunction as q, type InstrumentationHandlerResult as r, IDLE_NAVIGATION as s, IDLE_FETCHER as t, IDLE_BLOCKER as u, type Navigator as v, type AwaitProps as w, type IndexRouteProps as x, type MemoryRouterProps as y, type NavigateProps as z };