react-router 7.15.1 → 8.3.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.
- package/CHANGELOG.md +181 -2
- package/dist/development/dom-export.d.ts +6 -172
- package/dist/development/dom-export.js +12 -1007
- package/dist/development/index-react-server-client.d.ts +7 -4
- package/dist/development/index-react-server-client.js +8 -52
- package/dist/development/index-react-server.d.ts +1789 -1657
- package/dist/development/index-react-server.js +3074 -3674
- package/dist/development/index.d.ts +41 -1469
- package/dist/development/index.js +36 -2621
- package/dist/development/lib/actions.js +50 -0
- package/dist/development/lib/components.d.ts +1030 -0
- package/dist/development/lib/components.js +841 -0
- package/dist/development/lib/context.d.ts +83 -0
- package/dist/development/lib/context.js +41 -0
- package/dist/development/lib/dom/dom.d.ts +119 -0
- package/dist/development/lib/dom/dom.js +143 -0
- package/dist/development/lib/dom/lib.d.ts +2054 -0
- package/dist/development/lib/dom/lib.js +1272 -0
- package/dist/development/lib/dom/server.d.ts +138 -0
- package/dist/development/lib/dom/server.js +301 -0
- package/dist/development/lib/dom/ssr/components.d.ts +198 -0
- package/dist/development/lib/dom/ssr/components.js +589 -0
- package/dist/development/lib/dom/ssr/data.js +29 -0
- package/dist/development/lib/dom/ssr/entry.d.ts +60 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.js +87 -0
- package/dist/development/lib/dom/ssr/fallback.js +33 -0
- package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
- package/dist/development/lib/dom/ssr/fog-of-war.js +185 -0
- package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
- package/dist/development/lib/dom/ssr/hydration.js +29 -0
- package/dist/development/lib/dom/ssr/invariant.js +16 -0
- package/dist/development/lib/dom/ssr/links.js +170 -0
- package/dist/development/lib/dom/ssr/markup.js +24 -0
- package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
- package/dist/development/lib/dom/ssr/routeModules.js +31 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +75 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.js +121 -0
- package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
- package/dist/development/lib/dom/ssr/routes.js +303 -0
- package/dist/development/lib/dom/ssr/server.d.ts +48 -0
- package/dist/development/lib/dom/ssr/server.js +69 -0
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
- package/dist/development/lib/dom/ssr/single-fetch.js +345 -0
- package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
- package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
- package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
- package/dist/development/lib/dom-export/hydrated-router.js +150 -0
- package/dist/development/lib/errors.js +29 -0
- package/dist/development/lib/hooks.d.ts +974 -0
- package/dist/development/lib/hooks.js +1415 -0
- package/dist/development/lib/href.d.ts +36 -0
- package/dist/development/lib/href.js +70 -0
- package/dist/development/lib/router/history.d.ts +264 -0
- package/dist/development/lib/router/history.js +378 -0
- package/dist/development/lib/router/instrumentation.d.ts +111 -0
- package/dist/development/lib/router/instrumentation.js +290 -0
- package/dist/development/lib/router/links.d.ts +114 -0
- package/dist/development/lib/router/router.d.ts +663 -0
- package/dist/development/lib/router/router.js +2988 -0
- package/dist/development/lib/router/url.js +18 -0
- package/dist/development/lib/router/utils.d.ts +960 -0
- package/dist/development/lib/router/utils.js +881 -0
- package/dist/development/lib/rsc/browser.d.ts +137 -0
- package/dist/development/lib/rsc/browser.js +612 -0
- package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
- package/dist/development/lib/rsc/errorBoundaries.js +90 -0
- package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
- package/dist/development/lib/rsc/html-stream/browser.js +74 -0
- package/dist/development/lib/rsc/html-stream/server.js +97 -0
- package/dist/development/lib/rsc/route-modules.js +27 -0
- package/dist/development/lib/rsc/server.rsc.d.ts +224 -0
- package/dist/development/lib/rsc/server.ssr.d.ts +152 -0
- package/dist/development/lib/rsc/server.ssr.js +419 -0
- package/dist/development/lib/server-runtime/build.d.ts +66 -0
- package/dist/development/lib/server-runtime/cookies.d.ts +92 -0
- package/dist/development/lib/server-runtime/cookies.js +153 -0
- package/dist/development/lib/server-runtime/crypto.js +43 -0
- package/dist/development/lib/server-runtime/data.js +25 -0
- package/dist/development/lib/server-runtime/dev.d.ts +9 -0
- package/dist/development/lib/server-runtime/dev.js +26 -0
- package/dist/development/lib/server-runtime/entry.js +20 -0
- package/dist/development/lib/server-runtime/errors.js +75 -0
- package/dist/development/lib/server-runtime/headers.js +73 -0
- package/dist/development/lib/server-runtime/invariant.js +19 -0
- package/dist/development/lib/server-runtime/mode.d.ts +12 -0
- package/dist/development/lib/server-runtime/mode.js +25 -0
- package/dist/development/lib/server-runtime/routeMatching.js +28 -0
- package/dist/development/lib/server-runtime/routes.d.ts +13 -0
- package/dist/development/lib/server-runtime/routes.js +74 -0
- package/dist/development/lib/server-runtime/server.d.ts +22 -0
- package/dist/development/lib/server-runtime/server.js +364 -0
- package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +33 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +53 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +29 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +58 -0
- package/dist/development/lib/server-runtime/sessions.d.ts +174 -0
- package/dist/development/lib/server-runtime/sessions.js +115 -0
- package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
- package/dist/development/lib/server-runtime/single-fetch.js +215 -0
- package/dist/development/lib/server-runtime/urls.js +28 -0
- package/dist/development/lib/server-runtime/warnings.js +20 -0
- package/dist/development/lib/types/future.d.ts +9 -0
- package/dist/development/lib/types/internal.d.ts +26 -177
- package/dist/development/lib/types/internal.js +3 -2
- package/dist/{production/register-Bsscfj79.d.ts → development/lib/types/register.d.ts} +9 -15
- package/dist/development/lib/types/route-data.d.ts +113 -0
- package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/development/lib/types/route-module.d.ts +19 -0
- package/dist/development/lib/types/serializes-to.d.ts +13 -0
- package/dist/development/lib/types/utils.d.ts +11 -0
- package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +179 -0
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +199 -0
- package/dist/development/vendor/turbo-stream-v2/utils.js +39 -0
- package/dist/production/dom-export.d.ts +6 -172
- package/dist/production/dom-export.js +12 -1007
- package/dist/production/index-react-server-client.d.ts +7 -4
- package/dist/production/index-react-server-client.js +8 -52
- package/dist/production/index-react-server.d.ts +1789 -1657
- package/dist/production/index-react-server.js +3065 -3674
- package/dist/production/index.d.ts +41 -1469
- package/dist/production/index.js +36 -2621
- package/dist/production/lib/actions.js +50 -0
- package/dist/production/lib/components.d.ts +1030 -0
- package/dist/production/lib/components.js +841 -0
- package/dist/production/lib/context.d.ts +83 -0
- package/dist/production/lib/context.js +41 -0
- package/dist/production/lib/dom/dom.d.ts +119 -0
- package/dist/production/lib/dom/dom.js +143 -0
- package/dist/production/lib/dom/lib.d.ts +2054 -0
- package/dist/production/lib/dom/lib.js +1272 -0
- package/dist/production/lib/dom/server.d.ts +138 -0
- package/dist/production/lib/dom/server.js +301 -0
- package/dist/production/lib/dom/ssr/components.d.ts +198 -0
- package/dist/production/lib/dom/ssr/components.js +589 -0
- package/dist/production/lib/dom/ssr/data.js +29 -0
- package/dist/production/lib/dom/ssr/entry.d.ts +60 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.js +87 -0
- package/dist/production/lib/dom/ssr/fallback.js +23 -0
- package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
- package/dist/production/lib/dom/ssr/fog-of-war.js +185 -0
- package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
- package/dist/production/lib/dom/ssr/hydration.js +29 -0
- package/dist/production/lib/dom/ssr/invariant.js +16 -0
- package/dist/production/lib/dom/ssr/links.js +170 -0
- package/dist/production/lib/dom/ssr/markup.js +24 -0
- package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
- package/dist/production/lib/dom/ssr/routeModules.js +31 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +75 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.js +121 -0
- package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
- package/dist/production/lib/dom/ssr/routes.js +303 -0
- package/dist/production/lib/dom/ssr/server.d.ts +48 -0
- package/dist/production/lib/dom/ssr/server.js +69 -0
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
- package/dist/production/lib/dom/ssr/single-fetch.js +345 -0
- package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
- package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
- package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
- package/dist/production/lib/dom-export/hydrated-router.js +150 -0
- package/dist/production/lib/errors.js +29 -0
- package/dist/production/lib/hooks.d.ts +974 -0
- package/dist/production/lib/hooks.js +1400 -0
- package/dist/production/lib/href.d.ts +36 -0
- package/dist/production/lib/href.js +70 -0
- package/dist/production/lib/router/history.d.ts +264 -0
- package/dist/production/lib/router/history.js +378 -0
- package/dist/production/lib/router/instrumentation.d.ts +111 -0
- package/dist/production/lib/router/instrumentation.js +290 -0
- package/dist/production/lib/router/links.d.ts +114 -0
- package/dist/production/lib/router/router.d.ts +663 -0
- package/dist/production/lib/router/router.js +2988 -0
- package/dist/production/lib/router/url.js +18 -0
- package/dist/production/lib/router/utils.d.ts +960 -0
- package/dist/production/lib/router/utils.js +872 -0
- package/dist/production/lib/rsc/browser.d.ts +137 -0
- package/dist/production/lib/rsc/browser.js +612 -0
- package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
- package/dist/production/lib/rsc/errorBoundaries.js +90 -0
- package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
- package/dist/production/lib/rsc/html-stream/browser.js +74 -0
- package/dist/production/lib/rsc/html-stream/server.js +97 -0
- package/dist/production/lib/rsc/route-modules.js +27 -0
- package/dist/production/lib/rsc/server.rsc.d.ts +224 -0
- package/dist/production/lib/rsc/server.ssr.d.ts +152 -0
- package/dist/production/lib/rsc/server.ssr.js +419 -0
- package/dist/production/lib/server-runtime/build.d.ts +66 -0
- package/dist/production/lib/server-runtime/cookies.d.ts +92 -0
- package/dist/production/lib/server-runtime/cookies.js +153 -0
- package/dist/production/lib/server-runtime/crypto.js +43 -0
- package/dist/production/lib/server-runtime/data.js +25 -0
- package/dist/production/lib/server-runtime/dev.d.ts +9 -0
- package/dist/production/lib/server-runtime/dev.js +26 -0
- package/dist/production/lib/server-runtime/entry.js +20 -0
- package/dist/production/lib/server-runtime/errors.js +75 -0
- package/dist/production/lib/server-runtime/headers.js +73 -0
- package/dist/production/lib/server-runtime/invariant.js +19 -0
- package/dist/production/lib/server-runtime/mode.d.ts +12 -0
- package/dist/production/lib/server-runtime/mode.js +25 -0
- package/dist/production/lib/server-runtime/routeMatching.js +28 -0
- package/dist/production/lib/server-runtime/routes.d.ts +13 -0
- package/dist/production/lib/server-runtime/routes.js +74 -0
- package/dist/production/lib/server-runtime/server.d.ts +22 -0
- package/dist/production/lib/server-runtime/server.js +364 -0
- package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +33 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +53 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +29 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +58 -0
- package/dist/production/lib/server-runtime/sessions.d.ts +174 -0
- package/dist/production/lib/server-runtime/sessions.js +115 -0
- package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
- package/dist/production/lib/server-runtime/single-fetch.js +215 -0
- package/dist/production/lib/server-runtime/urls.js +28 -0
- package/dist/production/lib/server-runtime/warnings.js +20 -0
- package/dist/production/lib/types/future.d.ts +9 -0
- package/dist/production/lib/types/internal.d.ts +26 -177
- package/dist/production/lib/types/internal.js +3 -2
- package/dist/{development/register-Bsscfj79.d.ts → production/lib/types/register.d.ts} +9 -15
- package/dist/production/lib/types/route-data.d.ts +113 -0
- package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/production/lib/types/route-module.d.ts +19 -0
- package/dist/production/lib/types/serializes-to.d.ts +13 -0
- package/dist/production/lib/types/utils.d.ts +11 -0
- package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +179 -0
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +199 -0
- package/dist/production/vendor/turbo-stream-v2/utils.js +39 -0
- package/docs/explanation/backend-for-frontend.md +50 -0
- package/docs/explanation/code-splitting.md +77 -0
- package/docs/explanation/concurrency.md +135 -0
- package/docs/explanation/form-vs-fetcher.md +292 -0
- package/docs/explanation/hot-module-replacement.md +137 -0
- package/docs/explanation/hydration.md +14 -0
- package/docs/explanation/index-query-param.md +86 -0
- package/docs/explanation/index.md +4 -0
- package/docs/explanation/lazy-route-discovery.md +78 -0
- package/docs/explanation/location.md +6 -0
- package/docs/explanation/progressive-enhancement.md +150 -0
- package/docs/explanation/race-conditions.md +88 -0
- package/docs/explanation/react-transitions.md +160 -0
- package/docs/explanation/route-matching.md +7 -0
- package/docs/explanation/server-client-execution.md +4 -0
- package/docs/explanation/sessions-and-cookies.md +465 -0
- package/docs/explanation/special-files.md +16 -0
- package/docs/explanation/state-management.md +524 -0
- package/docs/explanation/styling.md +87 -0
- package/docs/explanation/type-safety.md +82 -0
- package/docs/how-to/accessibility.md +44 -0
- package/docs/how-to/client-data.md +199 -0
- package/docs/how-to/data-strategy.md +317 -0
- package/docs/how-to/error-boundary.md +231 -0
- package/docs/how-to/error-reporting.md +142 -0
- package/docs/how-to/fetchers.md +307 -0
- package/docs/how-to/file-route-conventions.md +410 -0
- package/docs/how-to/file-uploads.md +217 -0
- package/docs/how-to/form-validation.md +120 -0
- package/docs/how-to/headers.md +165 -0
- package/docs/how-to/index.md +4 -0
- package/docs/how-to/instrumentation.md +661 -0
- package/docs/how-to/meta.md +40 -0
- package/docs/how-to/middleware.md +647 -0
- package/docs/how-to/navigation-blocking.md +233 -0
- package/docs/how-to/optimize-revalidation.md +12 -0
- package/docs/how-to/pre-rendering.md +225 -0
- package/docs/how-to/presets.md +103 -0
- package/docs/how-to/react-server-components.md +951 -0
- package/docs/how-to/resource-routes.md +126 -0
- package/docs/how-to/route-module-type-safety.md +85 -0
- package/docs/how-to/search-params.md +4 -0
- package/docs/how-to/security.md +39 -0
- package/docs/how-to/server-bundles.md +66 -0
- package/docs/how-to/spa.md +120 -0
- package/docs/how-to/status.md +63 -0
- package/docs/how-to/suspense.md +132 -0
- package/docs/how-to/using-handle.md +117 -0
- package/docs/how-to/view-transitions.md +237 -0
- package/docs/how-to/webhook.md +50 -0
- package/docs/index.md +36 -0
- package/docs/start/data/actions.md +138 -0
- package/docs/start/data/custom.md +198 -0
- package/docs/start/data/data-loading.md +44 -0
- package/docs/start/data/index.md +4 -0
- package/docs/start/data/installation.md +56 -0
- package/docs/start/data/navigating.md +12 -0
- package/docs/start/data/pending-ui.md +12 -0
- package/docs/start/data/route-object.md +268 -0
- package/docs/start/data/routing.md +281 -0
- package/docs/start/data/testing.md +8 -0
- package/docs/start/declarative/index.md +4 -0
- package/docs/start/declarative/installation.md +43 -0
- package/docs/start/declarative/navigating.md +133 -0
- package/docs/start/declarative/routing.md +237 -0
- package/docs/start/declarative/url-values.md +65 -0
- package/docs/start/framework/actions.md +174 -0
- package/docs/start/framework/data-loading.md +201 -0
- package/docs/start/framework/deploying.md +104 -0
- package/docs/start/framework/index.md +4 -0
- package/docs/start/framework/installation.md +41 -0
- package/docs/start/framework/navigating.md +182 -0
- package/docs/start/framework/pending-ui.md +142 -0
- package/docs/start/framework/rendering.md +59 -0
- package/docs/start/framework/route-module.md +527 -0
- package/docs/start/framework/routing.md +362 -0
- package/docs/start/framework/testing.md +133 -0
- package/docs/start/index.md +4 -0
- package/docs/start/modes.md +200 -0
- package/docs/upgrading/component-routes.md +363 -0
- package/docs/upgrading/future.md +111 -0
- package/docs/upgrading/index.md +4 -0
- package/docs/upgrading/router-provider.md +445 -0
- package/docs/upgrading/v7.md +460 -0
- package/package.json +44 -87
- package/dist/development/browser-3AnU12UI.d.mts +0 -318
- package/dist/development/browser-BOdXz9dK.d.ts +0 -318
- package/dist/development/chunk-4N6VE7H7.mjs +0 -11528
- package/dist/development/chunk-4YRVXM2U.js +0 -188
- package/dist/development/chunk-66UKHEGQ.js +0 -1362
- package/dist/development/chunk-D6LUOGOQ.js +0 -10229
- package/dist/development/chunk-RJYABSBD.mjs +0 -2585
- package/dist/development/context-ByvtofY2.d.mts +0 -1771
- package/dist/development/data-BVUf681J.d.mts +0 -1732
- package/dist/development/data-BqZ2x964.d.ts +0 -1732
- package/dist/development/dom-export.d.mts +0 -172
- package/dist/development/dom-export.mjs +0 -1008
- package/dist/development/index-react-server-client-BS5F89FR.d.ts +0 -3655
- package/dist/development/index-react-server-client-DY04-103.d.mts +0 -2600
- package/dist/development/index-react-server-client.d.mts +0 -4
- package/dist/development/index-react-server-client.mjs +0 -59
- package/dist/development/index-react-server.d.mts +0 -2703
- package/dist/development/index-react-server.mjs +0 -3780
- package/dist/development/index.d.mts +0 -1472
- package/dist/development/index.mjs +0 -277
- package/dist/development/instrumentation-cRWWLfsU.d.ts +0 -715
- package/dist/development/lib/types/internal.d.mts +0 -184
- package/dist/development/lib/types/internal.mjs +0 -10
- package/dist/development/register-Df8okEea.d.mts +0 -30
- package/dist/production/browser-3AnU12UI.d.mts +0 -318
- package/dist/production/browser-BOdXz9dK.d.ts +0 -318
- package/dist/production/chunk-6S4627ZB.mjs +0 -2585
- package/dist/production/chunk-HUBUW7R3.js +0 -10229
- package/dist/production/chunk-JAKZPQZC.mjs +0 -11528
- package/dist/production/chunk-PNZCCTKT.js +0 -1362
- package/dist/production/chunk-Y6IFXO7V.js +0 -188
- package/dist/production/context-ByvtofY2.d.mts +0 -1771
- package/dist/production/data-BVUf681J.d.mts +0 -1732
- package/dist/production/data-BqZ2x964.d.ts +0 -1732
- package/dist/production/dom-export.d.mts +0 -172
- package/dist/production/dom-export.mjs +0 -1008
- package/dist/production/index-react-server-client-BS5F89FR.d.ts +0 -3655
- package/dist/production/index-react-server-client-DY04-103.d.mts +0 -2600
- package/dist/production/index-react-server-client.d.mts +0 -4
- package/dist/production/index-react-server-client.mjs +0 -59
- package/dist/production/index-react-server.d.mts +0 -2703
- package/dist/production/index-react-server.mjs +0 -3780
- package/dist/production/index.d.mts +0 -1472
- package/dist/production/index.mjs +0 -277
- package/dist/production/instrumentation-cRWWLfsU.d.ts +0 -715
- package/dist/production/lib/types/internal.d.mts +0 -184
- package/dist/production/lib/types/internal.mjs +0 -10
- package/dist/production/register-Df8okEea.d.mts +0 -30
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Framework Adoption from Component Routes
|
|
3
|
+
order: 4
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Framework Adoption from Component Routes
|
|
7
|
+
|
|
8
|
+
If you are using `<RouterProvider>` please see [Framework Adoption from RouterProvider][upgrade-router-provider] instead.
|
|
9
|
+
|
|
10
|
+
If you are using `<Routes>` this is the right place.
|
|
11
|
+
|
|
12
|
+
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://remix.run/discord).
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
The Vite plugin adds:
|
|
17
|
+
|
|
18
|
+
- Route loaders, actions, and automatic data revalidation
|
|
19
|
+
- Type-safe Routes Modules
|
|
20
|
+
- Automatic route code-splitting
|
|
21
|
+
- Automatic scroll restoration across navigations
|
|
22
|
+
- Optional Static pre-rendering
|
|
23
|
+
- Optional Server rendering
|
|
24
|
+
|
|
25
|
+
The initial setup requires the most work. However, once complete, you can adopt new features incrementally, one route at a time.
|
|
26
|
+
|
|
27
|
+
## Prerequisites
|
|
28
|
+
|
|
29
|
+
To use the Vite plugin, your project requires:
|
|
30
|
+
|
|
31
|
+
- Node.js 22.22.0+
|
|
32
|
+
- Vite 7+ or Vite 8+
|
|
33
|
+
|
|
34
|
+
## 1. Install the Vite plugin
|
|
35
|
+
|
|
36
|
+
**👉 Install the React Router Vite plugin**
|
|
37
|
+
|
|
38
|
+
```shellscript nonumber
|
|
39
|
+
npm install -D @react-router/dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**👉 Install a runtime adapter**
|
|
43
|
+
|
|
44
|
+
We will assume you are using Node as your runtime.
|
|
45
|
+
|
|
46
|
+
```shellscript nonumber
|
|
47
|
+
npm install @react-router/node
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**👉 Swap out the React plugin for React Router.**
|
|
51
|
+
|
|
52
|
+
```tsx diff filename=vite.config.ts
|
|
53
|
+
-import react from '@vitejs/plugin-react'
|
|
54
|
+
+import { reactRouter } from "@react-router/dev/vite";
|
|
55
|
+
import { defineConfig } from "vite";
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export default defineConfig({
|
|
59
|
+
plugins: [
|
|
60
|
+
- react()
|
|
61
|
+
+ reactRouter()
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 2. Add the React Router config
|
|
67
|
+
|
|
68
|
+
**👉 Create a `react-router.config.ts` file**
|
|
69
|
+
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
|
+
```shellscript nonumber
|
|
73
|
+
touch react-router.config.ts
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```ts filename=react-router.config.ts
|
|
77
|
+
import type { Config } from "@react-router/dev/config";
|
|
78
|
+
|
|
79
|
+
export default {
|
|
80
|
+
appDirectory: "src",
|
|
81
|
+
ssr: false,
|
|
82
|
+
} satisfies Config;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 3. Add the Root entry point
|
|
86
|
+
|
|
87
|
+
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.
|
|
88
|
+
|
|
89
|
+
**👉 Move your existing `index.html` to `root.tsx`**
|
|
90
|
+
|
|
91
|
+
For example, if your current `index.html` looks like this:
|
|
92
|
+
|
|
93
|
+
```html filename=index.html
|
|
94
|
+
<!DOCTYPE html>
|
|
95
|
+
<html lang="en">
|
|
96
|
+
<head>
|
|
97
|
+
<meta charset="UTF-8" />
|
|
98
|
+
<meta
|
|
99
|
+
name="viewport"
|
|
100
|
+
content="width=device-width, initial-scale=1.0"
|
|
101
|
+
/>
|
|
102
|
+
<title>My App</title>
|
|
103
|
+
</head>
|
|
104
|
+
<body>
|
|
105
|
+
<div id="root"></div>
|
|
106
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
107
|
+
</body>
|
|
108
|
+
</html>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
You would move that markup into `src/root.tsx` and delete `index.html`:
|
|
112
|
+
|
|
113
|
+
```shellscript nonumber
|
|
114
|
+
touch src/root.tsx
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```tsx filename=src/root.tsx
|
|
118
|
+
import {
|
|
119
|
+
Links,
|
|
120
|
+
Meta,
|
|
121
|
+
Outlet,
|
|
122
|
+
Scripts,
|
|
123
|
+
ScrollRestoration,
|
|
124
|
+
} from "react-router";
|
|
125
|
+
|
|
126
|
+
export function Layout({
|
|
127
|
+
children,
|
|
128
|
+
}: {
|
|
129
|
+
children: React.ReactNode;
|
|
130
|
+
}) {
|
|
131
|
+
return (
|
|
132
|
+
<html lang="en">
|
|
133
|
+
<head>
|
|
134
|
+
<meta charSet="UTF-8" />
|
|
135
|
+
<meta
|
|
136
|
+
name="viewport"
|
|
137
|
+
content="width=device-width, initial-scale=1.0"
|
|
138
|
+
/>
|
|
139
|
+
<title>My App</title>
|
|
140
|
+
<Meta />
|
|
141
|
+
<Links />
|
|
142
|
+
</head>
|
|
143
|
+
<body>
|
|
144
|
+
{children}
|
|
145
|
+
<ScrollRestoration />
|
|
146
|
+
<Scripts />
|
|
147
|
+
</body>
|
|
148
|
+
</html>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export default function Root() {
|
|
153
|
+
return <Outlet />;
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 4. Add client entry module
|
|
158
|
+
|
|
159
|
+
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.
|
|
160
|
+
|
|
161
|
+
**👉 Make `src/entry.client.tsx` your entry point**
|
|
162
|
+
|
|
163
|
+
If your current `src/main.tsx` looks like this:
|
|
164
|
+
|
|
165
|
+
```tsx filename=src/main.tsx
|
|
166
|
+
import React from "react";
|
|
167
|
+
import ReactDOM from "react-dom/client";
|
|
168
|
+
import { BrowserRouter } from "react-router";
|
|
169
|
+
import "./index.css";
|
|
170
|
+
import App from "./App";
|
|
171
|
+
|
|
172
|
+
ReactDOM.createRoot(
|
|
173
|
+
document.getElementById("root")!,
|
|
174
|
+
).render(
|
|
175
|
+
<React.StrictMode>
|
|
176
|
+
<BrowserRouter>
|
|
177
|
+
<App />
|
|
178
|
+
</BrowserRouter>
|
|
179
|
+
</React.StrictMode>,
|
|
180
|
+
);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
You would rename it to `entry.client.tsx` and change it to this:
|
|
184
|
+
|
|
185
|
+
```tsx filename=src/entry.client.tsx
|
|
186
|
+
import React from "react";
|
|
187
|
+
import ReactDOM from "react-dom/client";
|
|
188
|
+
import { HydratedRouter } from "react-router/dom";
|
|
189
|
+
import "./index.css";
|
|
190
|
+
|
|
191
|
+
ReactDOM.hydrateRoot(
|
|
192
|
+
document,
|
|
193
|
+
<React.StrictMode>
|
|
194
|
+
<HydratedRouter />
|
|
195
|
+
</React.StrictMode>,
|
|
196
|
+
);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
- Use `hydrateRoot` instead of `createRoot`
|
|
200
|
+
- Render a `<HydratedRouter>` instead of your `<App/>` component
|
|
201
|
+
- Note: we stopped rendering the `<App/>` component. We'll bring it back in a later step, but first we want to get the app to boot with the new entry point.
|
|
202
|
+
|
|
203
|
+
## 5. Shuffle stuff around
|
|
204
|
+
|
|
205
|
+
Between `root.tsx` and `entry.client.tsx`, you may want to shuffle some stuff around between them.
|
|
206
|
+
|
|
207
|
+
In general:
|
|
208
|
+
|
|
209
|
+
- `root.tsx` contains any rendering things like context providers, layouts, styles, etc.
|
|
210
|
+
- `entry.client.tsx` should be as minimal as possible
|
|
211
|
+
- Remember to _not_ try to render your existing `<App/>` component yet, we'll do that in a later step
|
|
212
|
+
|
|
213
|
+
Note that your `root.tsx` file will be statically generated and served as the entry point of your app, so just that module will need to be compatible with server rendering. This is where most of your trouble will come.
|
|
214
|
+
|
|
215
|
+
## 6. Set up your routes
|
|
216
|
+
|
|
217
|
+
The React Router Vite plugin uses a `routes.ts` file to configure your routes. For now we'll add a simple catchall route to get things going.
|
|
218
|
+
|
|
219
|
+
**👉 Set up a `catchall.tsx` route**
|
|
220
|
+
|
|
221
|
+
```shellscript nonumber
|
|
222
|
+
touch src/routes.ts src/catchall.tsx
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
```ts filename=src/routes.ts
|
|
226
|
+
import {
|
|
227
|
+
type RouteConfig,
|
|
228
|
+
route,
|
|
229
|
+
} from "@react-router/dev/routes";
|
|
230
|
+
|
|
231
|
+
export default [
|
|
232
|
+
// * matches all URLs, the ? makes it optional so it will match / as well
|
|
233
|
+
route("*?", "catchall.tsx"),
|
|
234
|
+
] satisfies RouteConfig;
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**👉 Render a placeholder route**
|
|
238
|
+
|
|
239
|
+
Eventually we'll replace this with our original `App` component, but for now we'll just render something simple to make sure we can boot the app.
|
|
240
|
+
|
|
241
|
+
```tsx filename=src/catchall.tsx
|
|
242
|
+
export default function Component() {
|
|
243
|
+
return <div>Hello, world!</div>;
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
[View our guide on configuring routes][configuring-routes] to learn more about the `routes.ts` file.
|
|
248
|
+
|
|
249
|
+
## 7. Boot the app
|
|
250
|
+
|
|
251
|
+
At this point you should be able to boot the app and see the root layout.
|
|
252
|
+
|
|
253
|
+
**👉 Add `dev` script and run the app**
|
|
254
|
+
|
|
255
|
+
```json filename=package.json
|
|
256
|
+
"scripts": {
|
|
257
|
+
"dev": "react-router dev"
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Now make sure you can boot your app at this point before moving on:
|
|
262
|
+
|
|
263
|
+
```shellscript
|
|
264
|
+
npm run dev
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
You will probably want to add `.react-router/` to your `.gitignore` file to avoid tracking unnecessary files in your repository.
|
|
268
|
+
|
|
269
|
+
```txt
|
|
270
|
+
.react-router/
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
You can check out [Type Safety][type-safety] to learn how to fully set up and use autogenerated type safety for params, loader data, and more.
|
|
274
|
+
|
|
275
|
+
## 8. Render your app
|
|
276
|
+
|
|
277
|
+
To get back to rendering your app, we'll update the "catchall" route we set up earlier that matches all URLs so that your existing `<Routes>` get a chance to render.
|
|
278
|
+
|
|
279
|
+
**👉 Update the catchall route to render your app**
|
|
280
|
+
|
|
281
|
+
```tsx filename=src/catchall.tsx
|
|
282
|
+
import App from "./App";
|
|
283
|
+
|
|
284
|
+
export default function Component() {
|
|
285
|
+
return <App />;
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Your app should be back on the screen and working as usual!
|
|
290
|
+
|
|
291
|
+
## 9. Migrate a route to a Route Module
|
|
292
|
+
|
|
293
|
+
You can now incrementally migrate your routes to route modules.
|
|
294
|
+
|
|
295
|
+
Given an existing route like this:
|
|
296
|
+
|
|
297
|
+
```tsx filename=src/App.tsx
|
|
298
|
+
// ...
|
|
299
|
+
import About from "./containers/About";
|
|
300
|
+
|
|
301
|
+
export default function App() {
|
|
302
|
+
return (
|
|
303
|
+
<Routes>
|
|
304
|
+
<Route path="/about" element={<About />} />
|
|
305
|
+
</Routes>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**👉 Add the route definition to `routes.ts`**
|
|
311
|
+
|
|
312
|
+
```tsx filename=src/routes.ts
|
|
313
|
+
import {
|
|
314
|
+
type RouteConfig,
|
|
315
|
+
route,
|
|
316
|
+
} from "@react-router/dev/routes";
|
|
317
|
+
|
|
318
|
+
export default [
|
|
319
|
+
route("/about", "./pages/about.tsx"),
|
|
320
|
+
route("*?", "catchall.tsx"),
|
|
321
|
+
] satisfies RouteConfig;
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**👉 Add the route module**
|
|
325
|
+
|
|
326
|
+
Edit the route module to use the [Route Module API][route-modules]:
|
|
327
|
+
|
|
328
|
+
```tsx filename=src/pages/about.tsx
|
|
329
|
+
export async function clientLoader() {
|
|
330
|
+
// you can now fetch data here
|
|
331
|
+
return {
|
|
332
|
+
title: "About page",
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export default function Component({ loaderData }) {
|
|
337
|
+
return <h1>{loaderData.title}</h1>;
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
See [Type Safety][type-safety] to set up autogenerated type safety for params, loader data, and more.
|
|
342
|
+
|
|
343
|
+
The first few routes you migrate are the hardest because you often have to access various abstractions a bit differently than before (like in a loader instead of from a hook or context). But once the trickiest bits get dealt with, you get into an incremental groove.
|
|
344
|
+
|
|
345
|
+
## Enable SSR and/or Pre-rendering
|
|
346
|
+
|
|
347
|
+
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.
|
|
348
|
+
|
|
349
|
+
```ts filename=react-router.config.ts
|
|
350
|
+
import type { Config } from "@react-router/dev/config";
|
|
351
|
+
|
|
352
|
+
export default {
|
|
353
|
+
ssr: true,
|
|
354
|
+
async prerender() {
|
|
355
|
+
return ["/", "/about", "/contact"];
|
|
356
|
+
},
|
|
357
|
+
} satisfies Config;
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
[upgrade-router-provider]: ./router-provider
|
|
361
|
+
[configuring-routes]: ../start/framework/routing
|
|
362
|
+
[route-modules]: ../start/framework/route-module
|
|
363
|
+
[type-safety]: ../how-to/route-module-type-safety
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Future Changes
|
|
3
|
+
order: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Future Changes
|
|
7
|
+
|
|
8
|
+
We try our best to keep major version upgrades simple and boring through the use of opt-in APIs and [Future Flags][api-development-strategy]. Future flags are used to gate breaking changes that don't otherwise have a good call-site opt-in strategy. By adopting all opt-in APIs and future flags, you should be able to upgrade to the next major version of React Router with minimal changes.
|
|
9
|
+
|
|
10
|
+
We plan to ship new major versions roughly once a year as described in our [Open Governance Model][governance], so this guide will continue to track future changes you can adopt ahead of the next major release. v9 is currently estimated for mid-2027 when Node 22 reaches EOL.
|
|
11
|
+
|
|
12
|
+
We highly recommend you make a commit after each step and ship it instead of doing everything all at once. Most flags can be adopted in any order, with exceptions noted below.
|
|
13
|
+
|
|
14
|
+
<docs-info>This is an evolving document that will be updated throughout the duration of v8</docs-info>
|
|
15
|
+
|
|
16
|
+
## Minimum Versions
|
|
17
|
+
|
|
18
|
+
[MODES: framework, data, declarative]
|
|
19
|
+
|
|
20
|
+
<br/>
|
|
21
|
+
<br/>
|
|
22
|
+
|
|
23
|
+
React Router v9 will require the following minimum versions (as of now). You can prepare for the upgrade by updating them while still on v8:
|
|
24
|
+
|
|
25
|
+
- `node@24+`
|
|
26
|
+
|
|
27
|
+
## Update to latest v8.x
|
|
28
|
+
|
|
29
|
+
Before adopting any future flags or call-site opt-in changes, you should update to the latest minor version of v8.x to make sure you have access to the latest flags. You may see a number of deprecation warnings as you upgrade, which we'll cover below.
|
|
30
|
+
|
|
31
|
+
👉 Update to latest v8
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install react-router@8 @react-router/{dev,node,etc.}@8
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Future Flags
|
|
38
|
+
|
|
39
|
+
_No future flags yet_
|
|
40
|
+
|
|
41
|
+
## Other Planned Breaking Changes
|
|
42
|
+
|
|
43
|
+
_No known planned breaking changes yet_
|
|
44
|
+
|
|
45
|
+
## Unstable Future Flags (Optional)
|
|
46
|
+
|
|
47
|
+
We document some [unstable] flags here as a reference for folks contributing to the project via beta testing, but they are not generally recommended for production use and may have breaking changes in patch or minor releases - adopt with caution!
|
|
48
|
+
|
|
49
|
+
### `future.unstable_enableNodeReadableStream`
|
|
50
|
+
|
|
51
|
+
[MODES: framework]
|
|
52
|
+
|
|
53
|
+
<br/>
|
|
54
|
+
<br/>
|
|
55
|
+
|
|
56
|
+
**Background**
|
|
57
|
+
|
|
58
|
+
Now that the Web Streams API is [stable](https://nodejs.org/docs/latest-v22.x/api/webstreams.html) in Node 22+, it's viable for React Router to use React's [`renderToReadableStream`](https://react.dev/reference/react-dom/server/renderToReadableStream) in the server entry.
|
|
59
|
+
|
|
60
|
+
When no `entry.server.tsx` file is present, React Router defaults to [`renderToPipeableStream`](https://react.dev/reference/react-dom/server/renderToPipeableStream) when a Node runtime is detected, and `renderToReadableStream` otherwise.
|
|
61
|
+
|
|
62
|
+
With this flag enabled, React Router will default to `renderToReadableStream` on all runtimes, including Node. You can continue to use `renderToPipeableStream` via a custom `entry.server.tsx` file if needed.
|
|
63
|
+
|
|
64
|
+
<docs-info>Enabling this flag might even provide slight performance gains because we are already using Web Streams internally, so this flag removes some unnecessary transforms between Web and Node streams.</docs-info>
|
|
65
|
+
|
|
66
|
+
👉 **Enable the Flag**
|
|
67
|
+
|
|
68
|
+
```ts filename=react-router.config.ts
|
|
69
|
+
import type { Config } from "@react-router/dev/config";
|
|
70
|
+
|
|
71
|
+
export default {
|
|
72
|
+
future: {
|
|
73
|
+
unstable_enableNodeReadableStream: true,
|
|
74
|
+
},
|
|
75
|
+
} satisfies Config;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Update your Code**
|
|
79
|
+
|
|
80
|
+
No code changes are required. If your app has a custom `entry.server.tsx`, this flag will not change your runtime behavior.
|
|
81
|
+
|
|
82
|
+
### `future.unstable_optimizeDeps`
|
|
83
|
+
|
|
84
|
+
[MODES: framework]
|
|
85
|
+
|
|
86
|
+
<br/>
|
|
87
|
+
<br/>
|
|
88
|
+
|
|
89
|
+
**Background**
|
|
90
|
+
|
|
91
|
+
This flag lets React Router provide Vite's dependency optimizer with the client entry file and route module files. This can improve dependency optimization in development, but the behavior is still experimental.
|
|
92
|
+
|
|
93
|
+
👉 **Enable the Flag**
|
|
94
|
+
|
|
95
|
+
```ts filename=react-router.config.ts
|
|
96
|
+
import type { Config } from "@react-router/dev/config";
|
|
97
|
+
|
|
98
|
+
export default {
|
|
99
|
+
future: {
|
|
100
|
+
unstable_optimizeDeps: true,
|
|
101
|
+
},
|
|
102
|
+
} satisfies Config;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Update your Code**
|
|
106
|
+
|
|
107
|
+
No code changes are required. If you run into dependency optimization issues after enabling this flag, remove the flag and restart the dev server.
|
|
108
|
+
|
|
109
|
+
[api-development-strategy]: ../community/api-development-strategy
|
|
110
|
+
[governance]: https://github.com/remix-run/react-router/blob/main/GOVERNANCE.md#design-goals
|
|
111
|
+
[unstable]: ../community/api-development-strategy#unstable-flags
|