react-router 7.15.1 → 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 +18 -2
  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 -1469
  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-Bsscfj79.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 -1469
  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-Bsscfj79.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-3AnU12UI.d.mts +0 -318
  323. package/dist/development/browser-BOdXz9dK.d.ts +0 -318
  324. package/dist/development/chunk-4N6VE7H7.mjs +0 -11528
  325. package/dist/development/chunk-4YRVXM2U.js +0 -188
  326. package/dist/development/chunk-66UKHEGQ.js +0 -1362
  327. package/dist/development/chunk-D6LUOGOQ.js +0 -10229
  328. package/dist/development/chunk-RJYABSBD.mjs +0 -2585
  329. package/dist/development/context-ByvtofY2.d.mts +0 -1771
  330. package/dist/development/data-BVUf681J.d.mts +0 -1732
  331. package/dist/development/data-BqZ2x964.d.ts +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-BS5F89FR.d.ts +0 -3655
  335. package/dist/development/index-react-server-client-DY04-103.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 -1472
  341. package/dist/development/index.mjs +0 -277
  342. package/dist/development/instrumentation-cRWWLfsU.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-Df8okEea.d.mts +0 -30
  346. package/dist/production/browser-3AnU12UI.d.mts +0 -318
  347. package/dist/production/browser-BOdXz9dK.d.ts +0 -318
  348. package/dist/production/chunk-6S4627ZB.mjs +0 -2585
  349. package/dist/production/chunk-HUBUW7R3.js +0 -10229
  350. package/dist/production/chunk-JAKZPQZC.mjs +0 -11528
  351. package/dist/production/chunk-PNZCCTKT.js +0 -1362
  352. package/dist/production/chunk-Y6IFXO7V.js +0 -188
  353. package/dist/production/context-ByvtofY2.d.mts +0 -1771
  354. package/dist/production/data-BVUf681J.d.mts +0 -1732
  355. package/dist/production/data-BqZ2x964.d.ts +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-BS5F89FR.d.ts +0 -3655
  359. package/dist/production/index-react-server-client-DY04-103.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 -1472
  365. package/dist/production/index.mjs +0 -277
  366. package/dist/production/instrumentation-cRWWLfsU.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-Df8okEea.d.mts +0 -30
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: Accessibility
3
+ ---
4
+
5
+ # Accessibility
6
+
7
+ Accessibility in a React Router app looks a lot like accessibility on the web in general. Using proper semantic markup and following the [Web Content Accessibility Guidelines (WCAG)][wcag] will get you most of the way there.
8
+
9
+ React Router makes certain accessibility practices the default where possible and provides APIs to help where it's not.
10
+
11
+ ## Links
12
+
13
+ [MODES: framework, data, declarative]
14
+
15
+ <br/>
16
+ <br/>
17
+
18
+ The [`<Link>` component][link] renders a standard anchor tag, meaning that you get its accessibility behaviors from the browser for free!
19
+
20
+ React Router also provides the [`<NavLink/>`][navlink] which behaves the same as `<Link>`, but it also provides context for assistive technology when the link points to the current page. This is useful for building navigation menus or breadcrumbs.
21
+
22
+ ## Routing
23
+
24
+ [MODES: framework]
25
+
26
+ <br/>
27
+ <br/>
28
+
29
+ If you are rendering [`<Scripts>`][scripts] in your app, there are some important things to consider to make client-side routing more accessible for your users.
30
+
31
+ With a traditional multi-page website we don't have to think about route changes too much. Your app renders an anchor tag, and the browser handles the rest. If your users disable JavaScript, your React Router app should already work this way by default!
32
+
33
+ When the client scripts in React Router are loaded, React Router takes control of routing and prevents the browser's default behavior. React Router doesn't make any assumptions about your UI as the route changes. There are some important features you'll want to consider as a result, including:
34
+
35
+ - **Focus management:** What element receives focus when the route changes? This is important for keyboard users and can be helpful for screen-reader users.
36
+ - **Live-region announcements:** Screen-reader users also benefit from announcements when a route has changed. You may want to also notify them during certain transition states depending on the nature of the change and how long loading is expected to take.
37
+
38
+ In 2019, [Marcy Sutton led and published findings from user research][marcy-sutton-led-and-published-findings-from-user-research] to help developers build accessible client-side routing experiences.
39
+
40
+ [link]: ../api/components/Link
41
+ [navlink]: ../api/components/NavLink
42
+ [scripts]: ../api/components/Scripts
43
+ [wcag]: https://www.w3.org/WAI/standards-guidelines/wcag/
44
+ [marcy-sutton-led-and-published-findings-from-user-research]: https://www.gatsbyjs.com/blog/2019-07-11-user-testing-accessible-client-routing
@@ -0,0 +1,199 @@
1
+ ---
2
+ title: Client Data
3
+ ---
4
+
5
+ # Client Data
6
+
7
+ [MODES: framework]
8
+
9
+ <br/>
10
+ <br/>
11
+
12
+ You can fetch and mutate data directly in the browser using `clientLoader` and `clientAction` functions.
13
+
14
+ These functions are the primary mechanism for data handling when using [SPA mode][spa]. This guide demonstrates common use cases for leveraging client data in Server-Side Rendering (SSR).
15
+
16
+ ## Skip the Server Hop
17
+
18
+ When using React Router with a Backend-For-Frontend (BFF) architecture, you might want to bypass the React Router server and communicate directly with your backend API. This approach requires proper authentication handling and assumes no CORS restrictions. Here's how to implement this:
19
+
20
+ 1. Load the data from server `loader` on the document load
21
+ 2. Load the data from the `clientLoader` on all subsequent loads
22
+
23
+ In this scenario, React Router will _not_ call the `clientLoader` on hydration - and will only call it on subsequent navigations.
24
+
25
+ ```tsx lines=[4,11]
26
+ export async function loader({
27
+ request,
28
+ }: Route.LoaderArgs) {
29
+ const data = await fetchApiFromServer({ request }); // (1)
30
+ return data;
31
+ }
32
+
33
+ export async function clientLoader({
34
+ request,
35
+ }: Route.ClientLoaderArgs) {
36
+ const data = await fetchApiFromClient({ request }); // (2)
37
+ return data;
38
+ }
39
+ ```
40
+
41
+ ## Fullstack State
42
+
43
+ Sometimes you need to combine data from both the server and browser (like IndexedDB or browser SDKs) before rendering a component. Here's how to implement this pattern:
44
+
45
+ 1. Load the partial data from server `loader` on the document load
46
+ 2. Export a [`HydrateFallback`][hydratefallback] component to render during SSR because we don't yet have a full set of data
47
+ 3. Set `clientLoader.hydrate = true`, this instructs React Router to call the clientLoader as part of initial document hydration
48
+ 4. Combine the server data with the client data in `clientLoader`
49
+
50
+ ```tsx lines=[4-6,19-20,23,26]
51
+ export async function loader({
52
+ request,
53
+ }: Route.LoaderArgs) {
54
+ const partialData = await getPartialDataFromDb({
55
+ request,
56
+ }); // (1)
57
+ return partialData;
58
+ }
59
+
60
+ export async function clientLoader({
61
+ request,
62
+ serverLoader,
63
+ }: Route.ClientLoaderArgs) {
64
+ const [serverData, clientData] = await Promise.all([
65
+ serverLoader(),
66
+ getClientData(request),
67
+ ]);
68
+ return {
69
+ ...serverData, // (4)
70
+ ...clientData, // (4)
71
+ };
72
+ }
73
+ clientLoader.hydrate = true as const; // (3)
74
+
75
+ export function HydrateFallback() {
76
+ return <p>Skeleton rendered during SSR</p>; // (2)
77
+ }
78
+
79
+ export default function Component({
80
+ // This will always be the combined set of server + client data
81
+ loaderData,
82
+ }: Route.ComponentProps) {
83
+ return <>...</>;
84
+ }
85
+ ```
86
+
87
+ ## Choosing Server or Client Data Loading
88
+
89
+ You can mix data loading strategies across your application, choosing between server-only or client-only data loading for each route. Here's how to implement both approaches:
90
+
91
+ 1. Export a `loader` when you want to use server data
92
+ 2. Export `clientLoader` and a `HydrateFallback` when you want to use client data
93
+
94
+ A route that only depends on a server loader looks like this:
95
+
96
+ ```tsx filename=app/routes/server-data-route.tsx
97
+ export async function loader({
98
+ request,
99
+ }: Route.LoaderArgs) {
100
+ const data = await getServerData(request);
101
+ return data;
102
+ }
103
+
104
+ export default function Component({
105
+ loaderData, // (1) - server data
106
+ }: Route.ComponentProps) {
107
+ return <>...</>;
108
+ }
109
+ ```
110
+
111
+ A route that only depends on a client loader looks like this.
112
+
113
+ ```tsx filename=app/routes/client-data-route.tsx
114
+ export async function clientLoader({
115
+ request,
116
+ }: Route.ClientLoaderArgs) {
117
+ const clientData = await getClientData(request);
118
+ return clientData;
119
+ }
120
+ // Note: you do not have to set this explicitly - it is implied if there is no `loader`
121
+ clientLoader.hydrate = true;
122
+
123
+ // (2)
124
+ export function HydrateFallback() {
125
+ return <p>Skeleton rendered during SSR</p>;
126
+ }
127
+
128
+ export default function Component({
129
+ loaderData, // (2) - client data
130
+ }: Route.ComponentProps) {
131
+ return <>...</>;
132
+ }
133
+ ```
134
+
135
+ ## Client-Side Caching
136
+
137
+ You can implement client-side caching (using memory, localStorage, etc.) to optimize server requests. Here's a pattern that demonstrates cache management:
138
+
139
+ 1. Load the data from server `loader` on the document load
140
+ 2. Set `clientLoader.hydrate = true` to prime the cache
141
+ 3. Load subsequent navigations from the cache via `clientLoader`
142
+ 4. Invalidate the cache in your `clientAction`
143
+
144
+ Note that since we are not exporting a `HydrateFallback` component, we will SSR the route component and then run the `clientLoader` on hydration, so it's important that your `loader` and `clientLoader` return the same data on initial load to avoid hydration errors.
145
+
146
+ ```tsx lines=[4,26,32,39,46]
147
+ export async function loader({
148
+ request,
149
+ }: Route.LoaderArgs) {
150
+ const data = await getDataFromDb({ request }); // (1)
151
+ return data;
152
+ }
153
+
154
+ export async function action({
155
+ request,
156
+ }: Route.ActionArgs) {
157
+ await saveDataToDb({ request });
158
+ return { ok: true };
159
+ }
160
+
161
+ let isInitialRequest = true;
162
+
163
+ export async function clientLoader({
164
+ request,
165
+ serverLoader,
166
+ }: Route.ClientLoaderArgs) {
167
+ const cacheKey = generateKey(request);
168
+
169
+ if (isInitialRequest) {
170
+ isInitialRequest = false;
171
+ const serverData = await serverLoader();
172
+ cache.set(cacheKey, serverData); // (2)
173
+ return serverData;
174
+ }
175
+
176
+ const cachedData = await cache.get(cacheKey);
177
+ if (cachedData) {
178
+ return cachedData; // (3)
179
+ }
180
+
181
+ const serverData = await serverLoader();
182
+ cache.set(cacheKey, serverData);
183
+ return serverData;
184
+ }
185
+ clientLoader.hydrate = true; // (2)
186
+
187
+ export async function clientAction({
188
+ request,
189
+ serverAction,
190
+ }: Route.ClientActionArgs) {
191
+ const cacheKey = generateKey(request);
192
+ cache.delete(cacheKey); // (4)
193
+ const serverData = await serverAction();
194
+ return serverData;
195
+ }
196
+ ```
197
+
198
+ [spa]: ../how-to/spa
199
+ [hydratefallback]: ../start/framework/route-module#hydratefallback
@@ -0,0 +1,317 @@
1
+ ---
2
+ title: Data Strategy
3
+ ---
4
+
5
+ # Data Strategy
6
+
7
+ [MODES: data]
8
+
9
+ <br />
10
+ <br />
11
+
12
+ <docs-warning>This is a low-level API intended for advanced use-cases. This overrides React Router's internal handling of `action`/`loader` execution, and if done incorrectly will break your app code. Please use with caution and perform the appropriate testing.</docs-warning>
13
+
14
+ ## Overview
15
+
16
+ By default, React Router is opinionated about how your data is loaded/submitted - and most notably, executes all of your [`loader`][loader] functions in parallel for optimal data fetching. While we think this is the right behavior for most use-cases, we realize that there is no "one size fits all" solution when it comes to data fetching for the wide landscape of application requirements.
17
+
18
+ The [`dataStrategy`][data-strategy] option gives you full control over how your [`action`][action]/[`loader`][loader] functions are executed and lays the foundation to build in more advanced APIs such as middleware, context, and caching layers. Over time, we expect that we'll leverage this API internally to bring more first class APIs to React Router, but until then (and beyond), this is your way to add more advanced functionality for your application's data needs.
19
+
20
+ ## Usage
21
+
22
+ A custom `dataStrategy` receives the `loader`/`action` arguments (`request`, `params`, `context`) plus a few more that allow you to decide how you want to control the executions for your application:
23
+
24
+ - `matches`: An array of `DataStrategyMatch` instances for the routes matched by the current `request`
25
+ - `runClientMiddleware`: A helper function to run the middleware for the matched routes
26
+ - `fetcherKey`: The fetcher key if this is for a fetcher request and not a navigation
27
+
28
+ A `DataStrategyMatch` is a normal route match plus a few additional fields:
29
+
30
+ - `shouldCallHandler`: A function that tells you whether this routes handler should be called for this request
31
+ - `shouldRevalidateArgs`: The arguments that to be passed to the routes `shouldRevalidate` for this request
32
+ - ~~`shouldLoad`~~: A boolean field for whether this routes handler should be run for this request
33
+ - Deprecated in favor of the more powerful `shouldCallHandler` API
34
+ - `resolve`: A function to handle call through to the route handler, and also allow you custom execution of the handler
35
+
36
+ Here's a basic example that adds logging around the handler executions:
37
+
38
+ ```tsx
39
+ let router = createBrowserRouter(routes, {
40
+ async dataStrategy({
41
+ matches,
42
+ request,
43
+ runClientMiddleware,
44
+ }) {
45
+ // Determine which matches are expected to be executed for this request.
46
+ // - For loading navigations, this will return true for new routes + existing
47
+ // routes requiring revalidation
48
+ // - For submission navigations, this will only return true for the action route
49
+ // - For fetcher calls, this will only return true for the fetcher route
50
+ const matchesToLoad = matches.filter((m) =>
51
+ m.shouldCallHandler(),
52
+ );
53
+
54
+ // For each match that we want to execute, call match.resolve() to execute
55
+ // the handler and store the result
56
+ const results: Record<string, DataStrategyResult> = {};
57
+ await runClientMiddleware(() =>
58
+ Promise.all(
59
+ matchesToLoad.map(async (match) => {
60
+ console.log(`Processing ${match.route.id}`);
61
+ // The resolve function calls through to the route handler
62
+ results[match.route.id] = await match.resolve();
63
+ }),
64
+ ),
65
+ );
66
+ return results;
67
+ },
68
+ });
69
+ ```
70
+
71
+ The `dataStrategy` function should return a `Record<string, DataStrategyResult>` which contains the result for each handler that was executed. A `DataStrategyResult` is just a wrapper object that indicates if the handler returned or threw:
72
+
73
+ ```ts
74
+ interface DataStrategyResult {
75
+ type: "data" | "error";
76
+ result: unknown; // data, Error, Response, data()
77
+ }
78
+ ```
79
+
80
+ ### Calling Route Middleware
81
+
82
+ If you are using `middleware` on your routes, you need to leverage the `callClientMiddleware` helper function to execute `middleware` around your handlers:
83
+
84
+ ```tsx
85
+ let router = createBrowserRouter(routes, {
86
+ async dataStrategy({
87
+ matches,
88
+ request,
89
+ runClientMiddleware,
90
+ }) {
91
+ const matchesToLoad = matches.filter((m) =>
92
+ m.shouldCallHandler(),
93
+ );
94
+ const results: Record<string, DataStrategyResult> = {};
95
+
96
+ // Run middleware and execute handlers at the end of the middleware chain
97
+ await runClientMiddleware(() =>
98
+ Promise.all(
99
+ matchesToLoad.map(async (match) => {
100
+ results[match.route.id] = await match.resolve();
101
+ }),
102
+ ),
103
+ );
104
+ return results;
105
+ },
106
+ });
107
+ ```
108
+
109
+ `runClientMiddleware` takes the same arguments as `dataStrategy` so it can also be easily composed with a standalone `dataStrategy` implementation:
110
+
111
+ ```tsx
112
+ const loggingDataStrategy: DataStrategyFunction = () => {
113
+ /* ... */
114
+ };
115
+
116
+ let router = createBrowserRouter(routes, {
117
+ async dataStrategy({ runClientMiddleware }) {
118
+ let results = await runClientMiddleware(
119
+ loggingDataStrategy,
120
+ );
121
+ return results;
122
+ },
123
+ });
124
+ ```
125
+
126
+ ### Advanced handler execution
127
+
128
+ If you want more fine-grained control over the execution of the handler, you can pass a callback to `match.resolve()`:
129
+
130
+ ```tsx
131
+ // Assume a loader shape such as
132
+ function loader({ request }, customContext) {...}
133
+
134
+ // In your dataStrategy, you can pass this context from inside a resolve callback
135
+ await Promise.all(
136
+ matchesToLoad.map((match, i) =>
137
+ match.resolve((handler) => {
138
+ let customContext = getCustomContext();
139
+ // Call the handler and p[ass a custom parameter as the handler's second argument
140
+ return handler(customContext);
141
+ }),
142
+ ),
143
+ );
144
+ ```
145
+
146
+ ### Custom Revalidation Behavior
147
+
148
+ If you want to alter the revalidation behavior, you can pass your own `defaultShouldRevalidate` to `match.shouldCallHandler()` which will pass through to any route level `shouldRevalidate` functions. The arguments that would be passed to the route level `shouldRevalidate` are available on `match.shouldRevalidateArgs`:
149
+
150
+ ```tsx
151
+ const matchesToLoad = matches.filter((match) => {
152
+ let defaultShouldRevalidate = customShouldRevalidate(
153
+ match.shouldRevalidateArgs,
154
+ );
155
+ return m.shouldCallHandler(defaultShouldRevalidate);
156
+ });
157
+ ```
158
+
159
+ ## Migrating away from `shouldLoad`
160
+
161
+ Now that we have stabilized the new `match.shouldCallHandler()`/`match.shouldRevalidateArgs` fields, it's recommended to move away from the now-deprecated `match.shouldLoad` API. The prior boolean approach did not allow for custom `dataStrategy`functions to alter the default revalidation behavior, so the new function-based APIs were created to allow that.
162
+
163
+ The major difference between these two APIs is that when using `shouldLoad`, calling `resolve()` would _only_ call the handler if `shouldLoad` was `true`. You could safely call it for all matches even if only a subset needed to have their handlers executed.
164
+
165
+ With `shouldCallHandler`, you are in charge of which handlers should be called so calling resolve will automatically call the handler. You should only call resolve on a the set of matches you wish to run handlers for.
166
+
167
+ Here's an example change from the prior API to the new API. Note that we pre-filter the `matchesToLoad` before calling `resolve()`:
168
+
169
+ ```diff
170
+ let results = {};
171
+ +let matchesToLoad = matches.filter(m => m.shouldCallHandler());
172
+ await Promise.all(() =>
173
+ - matches.map((m) => {
174
+ + matchesToLoad.map((m) => {
175
+ results[m.route.id] = await m.resolve();
176
+ }),
177
+ );
178
+ return results;
179
+ ```
180
+
181
+ ## Advanced Use Cases
182
+
183
+ ### Custom Middleware
184
+
185
+ <docs-info>This is an unlikely use-case now that React Router has built-in middleware, but if you wish to use a custom middleware you can do so with a `dataStrategy`.</docs-info>
186
+
187
+ Let's define a middleware on each route via [`handle`](../../start/data/route-object#handle)
188
+ and call middleware sequentially first, then call all
189
+ [`loader`](../../start/data/route-object#loader)s in parallel - providing
190
+ any data made available via the middleware:
191
+
192
+ ```ts
193
+ const routes = [
194
+ {
195
+ id: "parent",
196
+ path: "/parent",
197
+ loader({ request }, context) {
198
+ // ...
199
+ },
200
+ handle: {
201
+ async middleware({ request }, context) {
202
+ context.parent = "PARENT MIDDLEWARE";
203
+ },
204
+ },
205
+ children: [
206
+ {
207
+ id: "child",
208
+ path: "child",
209
+ loader({ request }, context) {
210
+ // ...
211
+ },
212
+ handle: {
213
+ async middleware({ request }, context) {
214
+ context.child = "CHILD MIDDLEWARE";
215
+ },
216
+ },
217
+ },
218
+ ],
219
+ },
220
+ ];
221
+
222
+ let router = createBrowserRouter(routes, {
223
+ async dataStrategy({ matches, params, request }) {
224
+ // Run middleware sequentially and let them add data to `context`
225
+ let context = {};
226
+ for (const match of matches) {
227
+ if (match.route.handle?.middleware) {
228
+ await match.route.handle.middleware(
229
+ { request, params },
230
+ context,
231
+ );
232
+ }
233
+ }
234
+
235
+ // Run loaders in parallel with the `context` value
236
+ let matchesToLoad = matches.filter((m) =>
237
+ m.shouldCallHandler(),
238
+ );
239
+ let results = await Promise.all(
240
+ matchesToLoad.map((match, i) =>
241
+ match.resolve((handler) => {
242
+ // Whatever you pass to `handler` will be passed as the 2nd parameter
243
+ // to your loader/action
244
+ return handler(context);
245
+ }),
246
+ ),
247
+ );
248
+ return results.reduce(
249
+ (acc, result, i) =>
250
+ Object.assign(acc, {
251
+ [matchesToLoad[i].route.id]: result,
252
+ }),
253
+ {},
254
+ );
255
+ },
256
+ });
257
+ ```
258
+
259
+ ### Custom Handler
260
+
261
+ It's also possible you don't even want to define a [`loader`](../../start/daoute-object#loader)
262
+ implementation at the route level. Maybe you want to just determine the
263
+ routes and issue a single GraphQL request for all of your data. You can do
264
+ that by setting your `route.loader=true` so it qualifies as "having a
265
+ loader", and then store GQL fragments on `route.handle`:
266
+
267
+ ```ts
268
+ const routes = [
269
+ {
270
+ id: "parent",
271
+ path: "/parent",
272
+ loader: true,
273
+ handle: {
274
+ gql: gql`
275
+ fragment Parent on Whatever {
276
+ parentField
277
+ }
278
+ `,
279
+ },
280
+ children: [
281
+ {
282
+ id: "child",
283
+ path: "child",
284
+ loader: true,
285
+ handle: {
286
+ gql: gql`
287
+ fragment Child on Whatever {
288
+ childField
289
+ }
290
+ `,
291
+ },
292
+ },
293
+ ],
294
+ },
295
+ ];
296
+
297
+ let router = createBrowserRouter(routes, {
298
+ async dataStrategy({ matches, params, request }) {
299
+ const matchesToLoad = matches.filter((m) =>
300
+ m.shouldCallHandler(),
301
+ );
302
+ // Compose route fragments into a single GQL payload
303
+ let gql = getFragmentsFromRouteHandles(matchesToLoad);
304
+ let data = await fetchGql(gql);
305
+ // Parse results back out into individual route level `DataStrategyResult`'s
306
+ // keyed by `routeId`
307
+ let results = parseResultsFromGql(matchesToLoad, data);
308
+ return results;
309
+ },
310
+ });
311
+ ```
312
+
313
+ Note that we never actually call `match.resolve()` in this scenario since we don't want to call the handlers defined on the routes. We instead make a single GQL call and split the resulting data back out to the proper routes in `results`.
314
+
315
+ [loader]: ../start/data/route-object#loader
316
+ [action]: ../start/data/route-object#action
317
+ [data-strategy]: ../api/data-routers/createBrowserRouter#optsdatastrategy