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
@@ -0,0 +1,442 @@
1
+ ---
2
+ title: Framework Adoption from RouterProvider
3
+ order: 5
4
+ ---
5
+
6
+ # Framework Adoption from RouterProvider
7
+
8
+ If you are not using `<RouterProvider>` please see [Framework Adoption from Component Routes][upgrade-component-routes] instead.
9
+
10
+ The React Router Vite plugin adds framework features to React Router. This guide will help you adopt the plugin in your app. If you run into any issues, please reach out for help on [Twitter](https://x.com/remix_run) or [Discord](https://rmx.as/discord).
11
+
12
+ ## Features
13
+
14
+ The Vite plugin adds:
15
+
16
+ - Route loaders, actions, and automatic data revalidation
17
+ - Type-safe Routes Modules
18
+ - Automatic route code-splitting
19
+ - Automatic scroll restoration across navigations
20
+ - Optional Static pre-rendering
21
+ - Optional Server rendering
22
+
23
+ The initial setup requires the most work. However, once complete, you can adopt new features incrementally.
24
+
25
+ ## Prerequisites
26
+
27
+ To use the Vite plugin, your project requires:
28
+
29
+ - Node.js 20+ (if using Node as your runtime)
30
+ - Vite 5+
31
+
32
+ ## 1. Move route definitions into route modules
33
+
34
+ The React Router Vite plugin renders its own `RouterProvider`, so you can't render an existing `RouterProvider` within it. Instead, you will need to format all of your route definitions to match the [Route Module API][route-modules].
35
+
36
+ This step will take the longest, however there are several benefits to doing this regardless of adopting the React Router Vite plugin:
37
+
38
+ - Route modules will be lazy loaded, decreasing the initial bundle size of your app
39
+ - Route definitions will be uniform, simplifying your app's architecture
40
+ - Moving to route modules is incremental, you can migrate one route at a time
41
+
42
+ **👉 Move your route definitions into route modules**
43
+
44
+ Export each piece of your route definition as a separate named export, following the [Route Module API][route-modules].
45
+
46
+ ```tsx filename=src/routes/about.tsx
47
+ export async function clientLoader() {
48
+ return {
49
+ title: "About",
50
+ };
51
+ }
52
+
53
+ export default function About() {
54
+ let data = useLoaderData();
55
+ return <div>{data.title}</div>;
56
+ }
57
+
58
+ // clientAction, ErrorBoundary, etc.
59
+ ```
60
+
61
+ **👉 Create a convert function**
62
+
63
+ Create a helper function to convert route module definitions into the format expected by your data router:
64
+
65
+ ```tsx filename=src/main.tsx
66
+ function convert(m: any) {
67
+ let {
68
+ clientLoader,
69
+ clientAction,
70
+ default: Component,
71
+ ...rest
72
+ } = m;
73
+ return {
74
+ ...rest,
75
+ loader: clientLoader,
76
+ action: clientAction,
77
+ Component,
78
+ };
79
+ }
80
+ ```
81
+
82
+ **👉 Lazy load and convert your route modules**
83
+
84
+ Instead of importing your route modules directly, lazy load and convert them to the format expected by your data router.
85
+
86
+ Not only does your route definition now conform to the Route Module API, but you also get the benefits of code-splitting your routes.
87
+
88
+ ```diff filename=src/main.tsx
89
+ let router = createBrowserRouter([
90
+ // ... other routes
91
+ {
92
+ path: "about",
93
+ - loader: aboutLoader,
94
+ - Component: About,
95
+ + lazy: () => import("./routes/about").then(convert),
96
+ },
97
+ // ... other routes
98
+ ]);
99
+ ```
100
+
101
+ Repeat this process for each route in your app.
102
+
103
+ ## 2. Install the Vite plugin
104
+
105
+ Once all of your route definitions are converted to route modules, you can adopt the React Router Vite plugin.
106
+
107
+ **👉 Install the React Router Vite plugin**
108
+
109
+ ```shellscript nonumber
110
+ npm install -D @react-router/dev
111
+ ```
112
+
113
+ **👉 Install a runtime adapter**
114
+
115
+ We will assume you are using Node as your runtime.
116
+
117
+ ```shellscript nonumber
118
+ npm install @react-router/node
119
+ ```
120
+
121
+ **👉 Swap out the React plugin for React Router**
122
+
123
+ ```diff filename=vite.config.ts
124
+ -import react from '@vitejs/plugin-react'
125
+ +import { reactRouter } from "@react-router/dev/vite";
126
+ import { defineConfig } from "vite";
127
+
128
+
129
+ export default defineConfig({
130
+ plugins: [
131
+ - react()
132
+ + reactRouter()
133
+ ],
134
+ });
135
+ ```
136
+
137
+ ## 3. Add the React Router config
138
+
139
+ **👉 Create a `react-router.config.ts` file**
140
+
141
+ Add the following to the root of your project. In this config you can tell React Router about your project, like where to find the app directory and to not use SSR (server-side rendering) for now.
142
+
143
+ ```shellscript nonumber
144
+ touch react-router.config.ts
145
+ ```
146
+
147
+ ```ts filename=react-router.config.ts
148
+ import type { Config } from "@react-router/dev/config";
149
+
150
+ export default {
151
+ appDirectory: "src",
152
+ ssr: false,
153
+ } satisfies Config;
154
+ ```
155
+
156
+ ## 4. Add the Root entry point
157
+
158
+ In a typical Vite app, the `index.html` file is the entry point for bundling. The React Router Vite plugin moves the entry point to a `root.tsx` file so you can use React to render the shell of your app instead of static HTML, and eventually upgrade to Server Rendering if you want.
159
+
160
+ **👉 Move your existing `index.html` to `root.tsx`**
161
+
162
+ For example, if your current `index.html` looks like this:
163
+
164
+ ```html filename=index.html
165
+ <!DOCTYPE html>
166
+ <html lang="en">
167
+ <head>
168
+ <meta charset="UTF-8" />
169
+ <meta
170
+ name="viewport"
171
+ content="width=device-width, initial-scale=1.0"
172
+ />
173
+ <title>My App</title>
174
+ </head>
175
+ <body>
176
+ <div id="root"></div>
177
+ <script type="module" src="/src/main.tsx"></script>
178
+ </body>
179
+ </html>
180
+ ```
181
+
182
+ You would move that markup into `src/root.tsx` and delete `index.html`:
183
+
184
+ ```shellscript nonumber
185
+ touch src/root.tsx
186
+ ```
187
+
188
+ ```tsx filename=src/root.tsx
189
+ import {
190
+ Links,
191
+ Meta,
192
+ Outlet,
193
+ Scripts,
194
+ ScrollRestoration,
195
+ } from "react-router";
196
+
197
+ export function Layout({
198
+ children,
199
+ }: {
200
+ children: React.ReactNode;
201
+ }) {
202
+ return (
203
+ <html lang="en">
204
+ <head>
205
+ <meta charSet="UTF-8" />
206
+ <meta
207
+ name="viewport"
208
+ content="width=device-width, initial-scale=1.0"
209
+ />
210
+ <title>My App</title>
211
+ <Meta />
212
+ <Links />
213
+ </head>
214
+ <body>
215
+ {children}
216
+ <ScrollRestoration />
217
+ <Scripts />
218
+ </body>
219
+ </html>
220
+ );
221
+ }
222
+
223
+ export default function Root() {
224
+ return <Outlet />;
225
+ }
226
+ ```
227
+
228
+ **👉 Move everything above `RouterProvider` to `root.tsx`**
229
+
230
+ Any global styles, context providers, etc. should be moved into `root.tsx` so they can be shared across all routes.
231
+
232
+ For example, if your `App.tsx` looks like this:
233
+
234
+ ```tsx filename=src/App.tsx
235
+ import "./index.css";
236
+
237
+ export default function App() {
238
+ return (
239
+ <OtherProviders>
240
+ <AppLayout>
241
+ <RouterProvider router={router} />
242
+ </AppLayout>
243
+ </OtherProviders>
244
+ );
245
+ }
246
+ ```
247
+
248
+ You would move everything above the `RouterProvider` into `root.tsx`.
249
+
250
+ ```diff filename=src/root.tsx
251
+ +import "./index.css";
252
+
253
+ // ... other imports and Layout
254
+
255
+ export default function Root() {
256
+ return (
257
+ + <OtherProviders>
258
+ + <AppLayout>
259
+ <Outlet />
260
+ + </AppLayout>
261
+ + </OtherProviders>
262
+ );
263
+ }
264
+ ```
265
+
266
+ ## 5. Add client entry module (optional)
267
+
268
+ In the typical Vite app the `index.html` file points to `src/main.tsx` as the client entry point. React Router uses a file named `src/entry.client.tsx` instead.
269
+
270
+ If no `entry.client.tsx` exists, the React Router Vite plugin will use a default, hidden one.
271
+
272
+ **👉 Make `src/entry.client.tsx` your entry point**
273
+
274
+ If your current `src/main.tsx` looks like this:
275
+
276
+ ```tsx filename=src/main.tsx
277
+ import React from "react";
278
+ import ReactDOM from "react-dom/client";
279
+ import { BrowserRouter } from "react-router";
280
+ import App from "./App";
281
+
282
+ const router = createBrowserRouter([
283
+ // ... route definitions
284
+ ]);
285
+
286
+ ReactDOM.createRoot(
287
+ document.getElementById("root")!,
288
+ ).render(
289
+ <React.StrictMode>
290
+ <RouterProvider router={router} />;
291
+ </React.StrictMode>,
292
+ );
293
+ ```
294
+
295
+ You would rename it to `entry.client.tsx` and change it to this:
296
+
297
+ ```tsx filename=src/entry.client.tsx
298
+ import React from "react";
299
+ import ReactDOM from "react-dom/client";
300
+ import { HydratedRouter } from "react-router/dom";
301
+
302
+ ReactDOM.hydrateRoot(
303
+ document,
304
+ <React.StrictMode>
305
+ <HydratedRouter />
306
+ </React.StrictMode>,
307
+ );
308
+ ```
309
+
310
+ - Use `hydrateRoot` instead of `createRoot`
311
+ - Render a `<HydratedRouter>` instead of your `<App/>` component
312
+ - Note: We are no longer creating the routes and manually passing them to `<RouterProvider />`. We will migrate our route definitions in the next step.
313
+
314
+ ## 6. Migrate your routes
315
+
316
+ The React Router Vite plugin uses a `routes.ts` file to configure your routes. The format will be pretty similar to the definitions of your data router.
317
+
318
+ **👉 Move definitions to a `routes.ts` file**
319
+
320
+ ```shellscript nonumber
321
+ touch src/routes.ts src/catchall.tsx
322
+ ```
323
+
324
+ Move your route definitions to `routes.ts`. Note that the schemas don't match exactly, so you will get type errors; we'll fix this next.
325
+
326
+ ```diff filename=src/routes.ts
327
+ +import type { RouteConfig } from "@react-router/dev/routes";
328
+
329
+ -const router = createBrowserRouter([
330
+ +export default [
331
+ {
332
+ path: "/",
333
+ lazy: () => import("./routes/layout").then(convert),
334
+ children: [
335
+ {
336
+ index: true,
337
+ lazy: () => import("./routes/home").then(convert),
338
+ },
339
+ {
340
+ path: "about",
341
+ lazy: () => import("./routes/about").then(convert),
342
+ },
343
+ {
344
+ path: "todos",
345
+ lazy: () => import("./routes/todos").then(convert),
346
+ children: [
347
+ {
348
+ path: ":id",
349
+ lazy: () =>
350
+ import("./routes/todo").then(convert),
351
+ },
352
+ ],
353
+ },
354
+ ],
355
+ },
356
+ -]);
357
+ +] satisfies RouteConfig;
358
+ ```
359
+
360
+ **👉 Replace the `lazy` loader with a `file` loader**
361
+
362
+ ```diff filename=src/routes.ts
363
+ export default [
364
+ {
365
+ path: "/",
366
+ - lazy: () => import("./routes/layout").then(convert),
367
+ + file: "./routes/layout.tsx",
368
+ children: [
369
+ {
370
+ index: true,
371
+ - lazy: () => import("./routes/home").then(convert),
372
+ + file: "./routes/home.tsx",
373
+ },
374
+ {
375
+ path: "about",
376
+ - lazy: () => import("./routes/about").then(convert),
377
+ + file: "./routes/about.tsx",
378
+ },
379
+ {
380
+ path: "todos",
381
+ - lazy: () => import("./routes/todos").then(convert),
382
+ + file: "./routes/todos.tsx",
383
+ children: [
384
+ {
385
+ path: ":id",
386
+ - lazy: () => import("./routes/todo").then(convert),
387
+ + file: "./routes/todo.tsx",
388
+ },
389
+ ],
390
+ },
391
+ ],
392
+ },
393
+ ] satisfies RouteConfig;
394
+ ```
395
+
396
+ [View our guide on configuring routes][configuring-routes] to learn more about the `routes.ts` file and helper functions to further simplify the route definitions.
397
+
398
+ ## 7. Boot the app
399
+
400
+ At this point you should be fully migrated to the React Router Vite plugin. Go ahead and update your `dev` script and run the app to make sure everything is working.
401
+
402
+ **👉 Add `dev` script and run the app**
403
+
404
+ ```json filename=package.json
405
+ "scripts": {
406
+ "dev": "react-router dev"
407
+ }
408
+ ```
409
+
410
+ Now make sure you can boot your app at this point before moving on:
411
+
412
+ ```shellscript
413
+ npm run dev
414
+ ```
415
+
416
+ You will probably want to add `.react-router/` to your `.gitignore` file to avoid tracking unnecessary files in your repository.
417
+
418
+ ```txt
419
+ .react-router/
420
+ ```
421
+
422
+ You can checkout [Type Safety][type-safety] to learn how to fully setup and use autogenerated type safety for params, loader data, and more.
423
+
424
+ ## Enable SSR and/or Pre-rendering
425
+
426
+ If you want to enable server rendering and static pre-rendering, you can do so with the `ssr` and `prerender` options in the bundler plugin. For SSR you'll need to also deploy the server build to a server.
427
+
428
+ ```ts filename=react-router.config.ts
429
+ import type { Config } from "@react-router/dev/config";
430
+
431
+ export default {
432
+ ssr: true,
433
+ async prerender() {
434
+ return ["/", "/about", "/contact"];
435
+ },
436
+ } satisfies Config;
437
+ ```
438
+
439
+ [upgrade-component-routes]: ./component-routes
440
+ [configuring-routes]: ../start/framework/routing
441
+ [route-modules]: ../start/framework/route-module
442
+ [type-safety]: ../how-to/route-module-type-safety