react-router 7.18.0 → 8.0.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/dom-export.d.ts +6 -172
- package/dist/development/dom-export.js +12 -1009
- 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 +1650 -1641
- package/dist/development/index-react-server.js +2882 -3664
- package/dist/development/index.d.ts +42 -1476
- package/dist/development/index.js +36 -2553
- 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 +2053 -0
- package/dist/development/lib/dom/lib.js +1271 -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 +180 -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 +62 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.js +108 -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 +947 -0
- package/dist/development/lib/hooks.js +1388 -0
- package/dist/development/lib/href.d.ts +20 -0
- package/dist/development/lib/href.js +50 -0
- package/dist/development/lib/router/history.d.ts +258 -0
- package/dist/development/lib/router/history.js +372 -0
- package/dist/development/lib/router/instrumentation.d.ts +86 -0
- package/dist/development/lib/router/instrumentation.js +213 -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 +948 -0
- package/dist/development/lib/router/utils.js +810 -0
- package/dist/development/lib/rsc/browser.d.ts +137 -0
- package/dist/development/lib/rsc/browser.js +603 -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 +78 -0
- package/dist/development/lib/rsc/route-modules.js +27 -0
- package/dist/development/lib/rsc/server.rsc.d.ts +219 -0
- package/dist/development/lib/rsc/server.ssr.d.ts +129 -0
- package/dist/development/lib/rsc/server.ssr.js +404 -0
- package/dist/development/lib/server-runtime/build.d.ts +66 -0
- package/dist/development/lib/server-runtime/cookies.d.ts +66 -0
- package/dist/development/lib/server-runtime/cookies.js +139 -0
- package/dist/development/lib/server-runtime/crypto.js +43 -0
- package/dist/development/lib/server-runtime/data.d.ts +13 -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 +10 -0
- package/dist/development/lib/server-runtime/server.js +345 -0
- package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +45 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +52 -0
- package/dist/development/lib/server-runtime/sessions.d.ts +145 -0
- package/dist/development/lib/server-runtime/sessions.js +98 -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/development/{register-roq_0qYo.d.ts → 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 -1009
- 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 +1650 -1641
- package/dist/production/index-react-server.js +2873 -3664
- package/dist/production/index.d.ts +42 -1476
- package/dist/production/index.js +36 -2553
- 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 +2053 -0
- package/dist/production/lib/dom/lib.js +1271 -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 +180 -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 +62 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.js +108 -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 +947 -0
- package/dist/production/lib/hooks.js +1373 -0
- package/dist/production/lib/href.d.ts +20 -0
- package/dist/production/lib/href.js +50 -0
- package/dist/production/lib/router/history.d.ts +258 -0
- package/dist/production/lib/router/history.js +372 -0
- package/dist/production/lib/router/instrumentation.d.ts +86 -0
- package/dist/production/lib/router/instrumentation.js +213 -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 +948 -0
- package/dist/production/lib/router/utils.js +801 -0
- package/dist/production/lib/rsc/browser.d.ts +137 -0
- package/dist/production/lib/rsc/browser.js +603 -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 +78 -0
- package/dist/production/lib/rsc/route-modules.js +27 -0
- package/dist/production/lib/rsc/server.rsc.d.ts +219 -0
- package/dist/production/lib/rsc/server.ssr.d.ts +129 -0
- package/dist/production/lib/rsc/server.ssr.js +404 -0
- package/dist/production/lib/server-runtime/build.d.ts +66 -0
- package/dist/production/lib/server-runtime/cookies.d.ts +66 -0
- package/dist/production/lib/server-runtime/cookies.js +139 -0
- package/dist/production/lib/server-runtime/crypto.js +43 -0
- package/dist/production/lib/server-runtime/data.d.ts +13 -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 +10 -0
- package/dist/production/lib/server-runtime/server.js +345 -0
- package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +45 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +52 -0
- package/dist/production/lib/server-runtime/sessions.d.ts +145 -0
- package/dist/production/lib/server-runtime/sessions.js +98 -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/production/{register-roq_0qYo.d.ts → 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/code-splitting.md +16 -0
- package/docs/how-to/middleware.md +6 -41
- package/docs/how-to/react-server-components.md +1 -1
- package/docs/upgrading/future.md +0 -249
- package/package.json +43 -87
- package/dist/development/browser-B2PdsXXH.d.ts +0 -318
- package/dist/development/browser-DBmQ1yAR.d.mts +0 -318
- package/dist/development/chunk-4ZMWKKQ3.mjs +0 -11606
- package/dist/development/chunk-E4MTK73K.mjs +0 -2517
- package/dist/development/chunk-U7ORXROY.js +0 -10307
- package/dist/development/chunk-WW7PN6QI.js +0 -188
- package/dist/development/chunk-YL5M26XI.js +0 -1366
- package/dist/development/context-CeD5LmaF.d.mts +0 -1779
- package/dist/development/data-CjO11-hU.d.ts +0 -1740
- package/dist/development/data-DEjBmEfD.d.mts +0 -1740
- package/dist/development/dom-export.d.mts +0 -172
- package/dist/development/dom-export.mjs +0 -1010
- package/dist/development/index-react-server-client-3ykjivgQ.d.ts +0 -3677
- package/dist/development/index-react-server-client-CACgcj2J.d.mts +0 -2614
- 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 -2711
- package/dist/development/index-react-server.mjs +0 -3803
- package/dist/development/index.d.mts +0 -1479
- package/dist/development/index.mjs +0 -275
- package/dist/development/instrumentation-Dkmpzd13.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-CmkRspdl.d.mts +0 -30
- package/dist/production/browser-B2PdsXXH.d.ts +0 -318
- package/dist/production/browser-DBmQ1yAR.d.mts +0 -318
- package/dist/production/chunk-3Z6WS2WZ.js +0 -188
- package/dist/production/chunk-BIP66BKV.js +0 -1366
- package/dist/production/chunk-EGOTSXNH.mjs +0 -2517
- package/dist/production/chunk-IUPBOWYO.js +0 -10307
- package/dist/production/chunk-M7NGGUU6.mjs +0 -11606
- package/dist/production/context-CeD5LmaF.d.mts +0 -1779
- package/dist/production/data-CjO11-hU.d.ts +0 -1740
- package/dist/production/data-DEjBmEfD.d.mts +0 -1740
- package/dist/production/dom-export.d.mts +0 -172
- package/dist/production/dom-export.mjs +0 -1010
- package/dist/production/index-react-server-client-3ykjivgQ.d.ts +0 -3677
- package/dist/production/index-react-server-client-CACgcj2J.d.mts +0 -2614
- 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 -2711
- package/dist/production/index-react-server.mjs +0 -3803
- package/dist/production/index.d.mts +0 -1479
- package/dist/production/index.mjs +0 -275
- package/dist/production/instrumentation-Dkmpzd13.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-CmkRspdl.d.mts +0 -30
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.0.0-pre.1
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { SUPPORTED_ERROR_TYPES } from "../../lib/router/utils.js";
|
|
12
|
+
import { Deferred } from "./utils.js";
|
|
13
|
+
//#region vendor/turbo-stream-v2/unflatten.ts
|
|
14
|
+
const globalObj = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
15
|
+
function unflatten(parsed) {
|
|
16
|
+
const { hydrated, values } = this;
|
|
17
|
+
if (typeof parsed === "number") return hydrate.call(this, parsed);
|
|
18
|
+
if (!Array.isArray(parsed) || !parsed.length) throw new SyntaxError();
|
|
19
|
+
const startIndex = values.length;
|
|
20
|
+
for (const value of parsed) values.push(value);
|
|
21
|
+
hydrated.length = values.length;
|
|
22
|
+
return hydrate.call(this, startIndex);
|
|
23
|
+
}
|
|
24
|
+
function hydrate(index) {
|
|
25
|
+
const { hydrated, values, deferred, plugins } = this;
|
|
26
|
+
let result;
|
|
27
|
+
const stack = [[index, (v) => {
|
|
28
|
+
result = v;
|
|
29
|
+
}]];
|
|
30
|
+
let postRun = [];
|
|
31
|
+
while (stack.length > 0) {
|
|
32
|
+
const [index, set] = stack.pop();
|
|
33
|
+
switch (index) {
|
|
34
|
+
case -7:
|
|
35
|
+
set(void 0);
|
|
36
|
+
continue;
|
|
37
|
+
case -5:
|
|
38
|
+
set(null);
|
|
39
|
+
continue;
|
|
40
|
+
case -2:
|
|
41
|
+
set(NaN);
|
|
42
|
+
continue;
|
|
43
|
+
case -6:
|
|
44
|
+
set(Infinity);
|
|
45
|
+
continue;
|
|
46
|
+
case -3:
|
|
47
|
+
set(-Infinity);
|
|
48
|
+
continue;
|
|
49
|
+
case -4:
|
|
50
|
+
set(-0);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (hydrated[index]) {
|
|
54
|
+
set(hydrated[index]);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const value = values[index];
|
|
58
|
+
if (!value || typeof value !== "object") {
|
|
59
|
+
hydrated[index] = value;
|
|
60
|
+
set(value);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(value)) if (typeof value[0] === "string") {
|
|
64
|
+
const [type, b, c] = value;
|
|
65
|
+
switch (type) {
|
|
66
|
+
case "D":
|
|
67
|
+
set(hydrated[index] = new Date(b));
|
|
68
|
+
continue;
|
|
69
|
+
case "U":
|
|
70
|
+
set(hydrated[index] = new URL(b));
|
|
71
|
+
continue;
|
|
72
|
+
case "B":
|
|
73
|
+
set(hydrated[index] = BigInt(b));
|
|
74
|
+
continue;
|
|
75
|
+
case "R":
|
|
76
|
+
set(hydrated[index] = new RegExp(b, c));
|
|
77
|
+
continue;
|
|
78
|
+
case "Y":
|
|
79
|
+
set(hydrated[index] = Symbol.for(b));
|
|
80
|
+
continue;
|
|
81
|
+
case "S":
|
|
82
|
+
const newSet = /* @__PURE__ */ new Set();
|
|
83
|
+
hydrated[index] = newSet;
|
|
84
|
+
for (let i = value.length - 1; i > 0; i--) stack.push([value[i], (v) => {
|
|
85
|
+
newSet.add(v);
|
|
86
|
+
}]);
|
|
87
|
+
set(newSet);
|
|
88
|
+
continue;
|
|
89
|
+
case "M":
|
|
90
|
+
const map = /* @__PURE__ */ new Map();
|
|
91
|
+
hydrated[index] = map;
|
|
92
|
+
for (let i = value.length - 2; i > 0; i -= 2) {
|
|
93
|
+
const r = [];
|
|
94
|
+
stack.push([value[i + 1], (v) => {
|
|
95
|
+
r[1] = v;
|
|
96
|
+
}]);
|
|
97
|
+
stack.push([value[i], (k) => {
|
|
98
|
+
r[0] = k;
|
|
99
|
+
}]);
|
|
100
|
+
postRun.push(() => {
|
|
101
|
+
map.set(r[0], r[1]);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
set(map);
|
|
105
|
+
continue;
|
|
106
|
+
case "N":
|
|
107
|
+
const obj = Object.create(null);
|
|
108
|
+
hydrated[index] = obj;
|
|
109
|
+
for (const key of Object.keys(b).reverse()) {
|
|
110
|
+
const r = [];
|
|
111
|
+
stack.push([b[key], (v) => {
|
|
112
|
+
r[1] = v;
|
|
113
|
+
}]);
|
|
114
|
+
stack.push([Number(key.slice(1)), (k) => {
|
|
115
|
+
r[0] = k;
|
|
116
|
+
}]);
|
|
117
|
+
postRun.push(() => {
|
|
118
|
+
obj[r[0]] = r[1];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
set(obj);
|
|
122
|
+
continue;
|
|
123
|
+
case "P":
|
|
124
|
+
if (hydrated[b]) set(hydrated[index] = hydrated[b]);
|
|
125
|
+
else {
|
|
126
|
+
const d = new Deferred();
|
|
127
|
+
deferred[b] = d;
|
|
128
|
+
set(hydrated[index] = d.promise);
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
case "E":
|
|
132
|
+
const [, message, errorType] = value;
|
|
133
|
+
let error = errorType && globalObj && SUPPORTED_ERROR_TYPES.includes(errorType) && errorType in globalObj && typeof globalObj[errorType] === "function" ? new globalObj[errorType](message) : new Error(message);
|
|
134
|
+
hydrated[index] = error;
|
|
135
|
+
set(error);
|
|
136
|
+
continue;
|
|
137
|
+
case "Z":
|
|
138
|
+
set(hydrated[index] = hydrated[b]);
|
|
139
|
+
continue;
|
|
140
|
+
default:
|
|
141
|
+
if (Array.isArray(plugins)) {
|
|
142
|
+
const r = [];
|
|
143
|
+
const vals = value.slice(1);
|
|
144
|
+
for (let i = 0; i < vals.length; i++) {
|
|
145
|
+
const v = vals[i];
|
|
146
|
+
stack.push([v, (v) => {
|
|
147
|
+
r[i] = v;
|
|
148
|
+
}]);
|
|
149
|
+
}
|
|
150
|
+
postRun.push(() => {
|
|
151
|
+
for (const plugin of plugins) {
|
|
152
|
+
const result = plugin(value[0], ...r);
|
|
153
|
+
if (result) {
|
|
154
|
+
set(hydrated[index] = result.value);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
throw new SyntaxError();
|
|
159
|
+
});
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
throw new SyntaxError();
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
const array = [];
|
|
166
|
+
hydrated[index] = array;
|
|
167
|
+
for (let i = 0; i < value.length; i++) {
|
|
168
|
+
const n = value[i];
|
|
169
|
+
if (n !== -1) stack.push([n, (v) => {
|
|
170
|
+
array[i] = v;
|
|
171
|
+
}]);
|
|
172
|
+
}
|
|
173
|
+
set(array);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const object = {};
|
|
178
|
+
hydrated[index] = object;
|
|
179
|
+
for (const key of Object.keys(value).reverse()) {
|
|
180
|
+
const r = [];
|
|
181
|
+
stack.push([value[key], (v) => {
|
|
182
|
+
r[1] = v;
|
|
183
|
+
}]);
|
|
184
|
+
stack.push([Number(key.slice(1)), (k) => {
|
|
185
|
+
r[0] = k;
|
|
186
|
+
}]);
|
|
187
|
+
postRun.push(() => {
|
|
188
|
+
object[r[0]] = r[1];
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
set(object);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
while (postRun.length > 0) postRun.pop()();
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { unflatten };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.0.0-pre.1
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
//#region vendor/turbo-stream-v2/utils.ts
|
|
12
|
+
var Deferred = class {
|
|
13
|
+
promise;
|
|
14
|
+
resolve;
|
|
15
|
+
reject;
|
|
16
|
+
constructor() {
|
|
17
|
+
this.promise = new Promise((resolve, reject) => {
|
|
18
|
+
this.resolve = resolve;
|
|
19
|
+
this.reject = reject;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function createLineSplittingTransform() {
|
|
24
|
+
const decoder = new TextDecoder();
|
|
25
|
+
let leftover = "";
|
|
26
|
+
return new TransformStream({
|
|
27
|
+
transform(chunk, controller) {
|
|
28
|
+
const str = decoder.decode(chunk, { stream: true });
|
|
29
|
+
const parts = (leftover + str).split("\n");
|
|
30
|
+
leftover = parts.pop() || "";
|
|
31
|
+
for (const part of parts) controller.enqueue(part);
|
|
32
|
+
},
|
|
33
|
+
flush(controller) {
|
|
34
|
+
if (leftover) controller.enqueue(leftover);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { Deferred, createLineSplittingTransform };
|
|
@@ -33,6 +33,22 @@ Because these entry points are coupled to URL segments, React Router knows just
|
|
|
33
33
|
|
|
34
34
|
If the user visits `"/about"` then the bundles for `about.tsx` will be loaded but not `contact.tsx`. This drastically reduces the JavaScript footprint for initial page loads and speeds up your application.
|
|
35
35
|
|
|
36
|
+
## Route Module Splitting
|
|
37
|
+
|
|
38
|
+
React Router can also split client-side route exports (`clientLoader`, `clientAction`, `clientMiddleware`, `HydrateFallback`) into separate chunks that can be loaded independently from the route component.
|
|
39
|
+
|
|
40
|
+
This allows these exports to be fetched and executed while the component code is still downloading, improving performance for client-side data loading.
|
|
41
|
+
|
|
42
|
+
This behavior is enabled by default. You can set `splitRouteModules` to `false` to opt out, or `"enforce"` to require all routes to be splittable. The `"enforce"` option will cause build failures for routes that cannot be split due to shared code.
|
|
43
|
+
|
|
44
|
+
```ts filename=react-router.config.ts
|
|
45
|
+
import type { Config } from "@react-router/dev/config";
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
splitRouteModules: false,
|
|
49
|
+
} satisfies Config;
|
|
50
|
+
```
|
|
51
|
+
|
|
36
52
|
## Removal of Server Code
|
|
37
53
|
|
|
38
54
|
Any server-only [Route Module APIs][route-module] will be removed from the bundles. Consider this route module:
|
|
@@ -29,23 +29,7 @@ For example, on a `GET /parent/child` request, the middleware would run in the f
|
|
|
29
29
|
|
|
30
30
|
## Quick Start (Framework mode)
|
|
31
31
|
|
|
32
|
-
### 1.
|
|
33
|
-
|
|
34
|
-
First, enable middleware in your [React Router config][rr-config]:
|
|
35
|
-
|
|
36
|
-
```ts filename=react-router.config.ts
|
|
37
|
-
import type { Config } from "@react-router/dev/config";
|
|
38
|
-
|
|
39
|
-
export default {
|
|
40
|
-
future: {
|
|
41
|
-
v8_middleware: true,
|
|
42
|
-
},
|
|
43
|
-
} satisfies Config;
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
<docs-warning>By enabling the middleware feature, you change the type of the `context` parameter to your [`action`][framework-action]s and [`loader`][framework-loader]s. Please pay attention to the section on [`getLoadContext`][getloadcontext] below if you are actively using `context` today.</docs-warning>
|
|
47
|
-
|
|
48
|
-
### 2. Create a context
|
|
32
|
+
### 1. Create a context
|
|
49
33
|
|
|
50
34
|
Middleware uses a `context` provider instance to provide data down the middleware chain.
|
|
51
35
|
You can create type-safe context objects using [`createContext`][createContext]:
|
|
@@ -57,7 +41,7 @@ import type { User } from "~/types";
|
|
|
57
41
|
export const userContext = createContext<User | null>(null);
|
|
58
42
|
```
|
|
59
43
|
|
|
60
|
-
###
|
|
44
|
+
### 2. Export middleware from your routes
|
|
61
45
|
|
|
62
46
|
```tsx filename=app/routes/dashboard.tsx
|
|
63
47
|
import { redirect } from "react-router";
|
|
@@ -107,7 +91,7 @@ export default function Dashboard({
|
|
|
107
91
|
}
|
|
108
92
|
```
|
|
109
93
|
|
|
110
|
-
###
|
|
94
|
+
### 3. Update your `getLoadContext` function (if applicable)
|
|
111
95
|
|
|
112
96
|
If you're using a custom server and a `getLoadContext` function, you will need to update your implementation to return an instance of [`RouterContextProvider`][RouterContextProvider], instead of a JavaScript object:
|
|
113
97
|
|
|
@@ -130,25 +114,7 @@ function getLoadContext(req, res) {
|
|
|
130
114
|
|
|
131
115
|
## Quick Start (Data Mode)
|
|
132
116
|
|
|
133
|
-
### 1.
|
|
134
|
-
|
|
135
|
-
In order to properly type your `context` param in your `loader`/`action`/`middleware` functions, you will need a small module augmentation to override the default context type of `any`:
|
|
136
|
-
|
|
137
|
-
```ts
|
|
138
|
-
// src/react-router.d.ts
|
|
139
|
-
|
|
140
|
-
import "react-router";
|
|
141
|
-
|
|
142
|
-
declare module "react-router" {
|
|
143
|
-
interface Future {
|
|
144
|
-
v8_middleware: true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Without this, `context` stays loosely typed even when middleware is enabled at runtime.
|
|
150
|
-
|
|
151
|
-
### 2. Create a context
|
|
117
|
+
### 1. Create a context
|
|
152
118
|
|
|
153
119
|
Middleware uses a `context` provider to pass data through the middleware chain into loaders and actions. Create typed context with [`createContext`][createContext]:
|
|
154
120
|
|
|
@@ -159,7 +125,7 @@ import type { User } from "~/types";
|
|
|
159
125
|
export const userContext = createContext<User | null>(null);
|
|
160
126
|
```
|
|
161
127
|
|
|
162
|
-
###
|
|
128
|
+
### 2. Add `middleware` to route objects
|
|
163
129
|
|
|
164
130
|
Attach `middleware` arrays to your route objects:
|
|
165
131
|
|
|
@@ -225,7 +191,7 @@ export default function Dashboard() {
|
|
|
225
191
|
}
|
|
226
192
|
```
|
|
227
193
|
|
|
228
|
-
###
|
|
194
|
+
### 3. Add a `getContext` function (optional)
|
|
229
195
|
|
|
230
196
|
To seed every navigation or fetcher call with shared values, pass [`getContext`][getContext] when creating the router:
|
|
231
197
|
|
|
@@ -738,7 +704,6 @@ export async function loader({
|
|
|
738
704
|
[Response]: https://developer.mozilla.org/en-US/docs/Web/API/Response
|
|
739
705
|
[common-patterns]: #common-patterns
|
|
740
706
|
[server-client]: #server-vs-client-middleware
|
|
741
|
-
[rr-config]: ../api/framework-conventions/react-router.config.ts
|
|
742
707
|
[create-browser-router]: ../api/data-routers/createBrowserRouter
|
|
743
708
|
[create-hash-router]: ../api/data-routers/createHashRouter
|
|
744
709
|
[create-memory-router]: ../api/data-routers/createMemoryRouter
|
package/docs/upgrading/future.md
CHANGED
|
@@ -19,253 +19,6 @@ First update to the latest minor version of v7.x to have the latest future flags
|
|
|
19
19
|
npm install react-router@7 @react-router/{dev,node,etc.}@7
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
## `future.v8_middleware`
|
|
23
|
-
|
|
24
|
-
[MODES: framework, data]
|
|
25
|
-
|
|
26
|
-
<br/>
|
|
27
|
-
<br/>
|
|
28
|
-
|
|
29
|
-
**Background**
|
|
30
|
-
|
|
31
|
-
Middleware allows you to run code before and after the [`Response`][Response] generation for the matched path. This enables common patterns like authentication, logging, error handling, and data preprocessing in a reusable way. Please see the [docs](../how-to/middleware) for more information.
|
|
32
|
-
|
|
33
|
-
👉 **Enable the Flag**
|
|
34
|
-
|
|
35
|
-
In Framework mode:
|
|
36
|
-
|
|
37
|
-
```ts filename=react-router.config.ts
|
|
38
|
-
import type { Config } from "@react-router/dev/config";
|
|
39
|
-
|
|
40
|
-
export default {
|
|
41
|
-
future: {
|
|
42
|
-
v8_middleware: true,
|
|
43
|
-
},
|
|
44
|
-
} satisfies Config;
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
In Data mode:
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
import { createBrowserRouter } from "react-router/dom";
|
|
51
|
-
|
|
52
|
-
const router = createBrowserRouter(routes, {
|
|
53
|
-
future: {
|
|
54
|
-
v8_middleware: true,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**Update your Code**
|
|
60
|
-
|
|
61
|
-
If you're using the `context` parameter in `loader` and `action` functions, you may need to update your code:
|
|
62
|
-
|
|
63
|
-
- In Framework mode, if you're using `react-router-serve`, you should not need to make any updates. Otherwise, this only applies if you have a custom server with a `getLoadContext` function. Please see the docs on the middleware [`getLoadContext` changes](../how-to/middleware#changes-to-getloadcontextapploadcontext) and the instructions to [migrate to the new API](../how-to/middleware#migration-from-apploadcontext).
|
|
64
|
-
- In Data mode, add the `Future` module augmentation described in the [middleware docs](../how-to/middleware#1-typescript-augment-future-for-loaderaction-context) so `context` is typed correctly.
|
|
65
|
-
|
|
66
|
-
## `future.v8_splitRouteModules`
|
|
67
|
-
|
|
68
|
-
[MODES: framework]
|
|
69
|
-
|
|
70
|
-
<br/>
|
|
71
|
-
<br/>
|
|
72
|
-
|
|
73
|
-
**Background**
|
|
74
|
-
|
|
75
|
-
This feature enables splitting client-side route exports (`clientLoader`, `clientAction`, `clientMiddleware`, `HydrateFallback`) into separate chunks that can be loaded independently from the route component. This allows these exports to be fetched and executed while the component code is still downloading, improving performance for client-side data loading.
|
|
76
|
-
|
|
77
|
-
This can be set to `true` for opt-in behavior, or `"enforce"` to require all routes to be splittable (which will cause build failures for routes that cannot be split due to shared code).
|
|
78
|
-
|
|
79
|
-
👉 **Enable the Flag**
|
|
80
|
-
|
|
81
|
-
```ts filename=react-router.config.ts
|
|
82
|
-
import type { Config } from "@react-router/dev/config";
|
|
83
|
-
|
|
84
|
-
export default {
|
|
85
|
-
future: {
|
|
86
|
-
v8_splitRouteModules: true,
|
|
87
|
-
},
|
|
88
|
-
} satisfies Config;
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**Update your Code**
|
|
92
|
-
|
|
93
|
-
No code changes are required. This is an optimization feature that works automatically once enabled.
|
|
94
|
-
|
|
95
|
-
## `future.v8_viteEnvironmentApi`
|
|
96
|
-
|
|
97
|
-
[MODES: framework]
|
|
98
|
-
|
|
99
|
-
<br/>
|
|
100
|
-
<br/>
|
|
101
|
-
|
|
102
|
-
**Background**
|
|
103
|
-
|
|
104
|
-
This enables support for the experimental Vite Environment API, which provides a more flexible and powerful way to configure Vite environments. This is only available when using Vite 6+.
|
|
105
|
-
|
|
106
|
-
👉 **Enable the Flag**
|
|
107
|
-
|
|
108
|
-
```ts filename=react-router.config.ts
|
|
109
|
-
import type { Config } from "@react-router/dev/config";
|
|
110
|
-
|
|
111
|
-
export default {
|
|
112
|
-
future: {
|
|
113
|
-
v8_viteEnvironmentApi: true,
|
|
114
|
-
},
|
|
115
|
-
} satisfies Config;
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
**Update your Code**
|
|
119
|
-
|
|
120
|
-
Most users won't need to make any changes. However, if you have custom Vite configuration that previously relied on the `isSsrBuild` flag — such as a custom server build that sets `build.rollupOptions.input` — you'll need to move that configuration under the per-environment [Environment API][vite-environment] config instead.
|
|
121
|
-
|
|
122
|
-
For example, a custom server build should move its SSR `rollupOptions` from the top-level `build` config into `environments.ssr.build`:
|
|
123
|
-
|
|
124
|
-
```diff filename=vite.config.ts
|
|
125
|
-
import { reactRouter } from "@react-router/dev/vite";
|
|
126
|
-
import { defineConfig } from "vite";
|
|
127
|
-
|
|
128
|
-
-export default defineConfig(({ isSsrBuild }) => ({
|
|
129
|
-
- build: {
|
|
130
|
-
- rollupOptions: isSsrBuild
|
|
131
|
-
- ? {
|
|
132
|
-
- input: "./server/app.ts",
|
|
133
|
-
- }
|
|
134
|
-
- : undefined,
|
|
135
|
-
- },
|
|
136
|
-
+export default defineConfig({
|
|
137
|
-
+ environments: {
|
|
138
|
-
+ ssr: {
|
|
139
|
-
+ build: {
|
|
140
|
-
+ rollupOptions: {
|
|
141
|
-
+ input: "./server/app.ts",
|
|
142
|
-
+ },
|
|
143
|
-
+ },
|
|
144
|
-
+ },
|
|
145
|
-
+ },
|
|
146
|
-
plugins: [reactRouter()],
|
|
147
|
-
-}));
|
|
148
|
-
+});
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
See the [`node-custom-server` template][node-custom-server-template] for a complete example.
|
|
152
|
-
|
|
153
|
-
## `future.v8_passThroughRequests`
|
|
154
|
-
|
|
155
|
-
[MODES: framework]
|
|
156
|
-
|
|
157
|
-
<br/>
|
|
158
|
-
<br/>
|
|
159
|
-
|
|
160
|
-
**Background**
|
|
161
|
-
|
|
162
|
-
By default, React Router normalizes the `request.url` passed to your `loader`, `action`, and `middleware` functions by removing React Router's internal implementation details. Specifically, it removes `.data` suffixes and internal search parameters like `?index` and `?_routes`.
|
|
163
|
-
|
|
164
|
-
This flag eliminates that normalization and passes the raw HTTP `request` instance to your handlers. This provides a few benefits:
|
|
165
|
-
|
|
166
|
-
- Reduces server-side overhead by eliminating multiple `new Request()` calls on the critical path
|
|
167
|
-
- Allows you to distinguish document from data requests in your handlers based on the presence of a `.data` suffix (useful for [observability] purposes)
|
|
168
|
-
|
|
169
|
-
If you were previously relying on the normalization of `request.url`, you can switch to use the new sibling `url` parameter which contains a `URL` instance representing the normalized location.
|
|
170
|
-
|
|
171
|
-
👉 **Enable the Flag**
|
|
172
|
-
|
|
173
|
-
```ts filename=react-router.config.ts
|
|
174
|
-
import type { Config } from "@react-router/dev/config";
|
|
175
|
-
|
|
176
|
-
export default {
|
|
177
|
-
future: {
|
|
178
|
-
v8_passThroughRequests: true,
|
|
179
|
-
},
|
|
180
|
-
} satisfies Config;
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Update your Code**
|
|
184
|
-
|
|
185
|
-
If your code relies on inspecting the request URL, you should review it for any assumptions about the URL format:
|
|
186
|
-
|
|
187
|
-
```tsx
|
|
188
|
-
// ❌ Before: assuming no `.data` suffix in `request.url` pathname
|
|
189
|
-
export async function loader({
|
|
190
|
-
request,
|
|
191
|
-
}: Route.LoaderArgs) {
|
|
192
|
-
let url = new URL(request.url);
|
|
193
|
-
if (url.pathname === "/path") {
|
|
194
|
-
// This check might now behave differently because the request pathname will
|
|
195
|
-
// contain the `.data` suffix on data requests
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// ✅ After: use `url` for normalized routing logic and `request.url`
|
|
200
|
-
// for raw routing logic
|
|
201
|
-
export async function loader({
|
|
202
|
-
request,
|
|
203
|
-
url,
|
|
204
|
-
}: Route.LoaderArgs) {
|
|
205
|
-
if (url.pathname === "/path") {
|
|
206
|
-
// This will always have the `.data` suffix stripped
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// And now you can distinguish between document versus data requests
|
|
210
|
-
let isDataRequest = new URL(
|
|
211
|
-
request.url,
|
|
212
|
-
).pathname.endsWith(".data");
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
## `future.v8_trailingSlashAwareDataRequests`
|
|
217
|
-
|
|
218
|
-
[MODES: framework]
|
|
219
|
-
|
|
220
|
-
<br/>
|
|
221
|
-
<br/>
|
|
222
|
-
|
|
223
|
-
**Background**
|
|
224
|
-
|
|
225
|
-
React Router serves Framework mode data requests from `.data` URLs. Previously, data requests for routes with and without trailing slashes could map to the same `.data` URL because trailing slashes were not considered during URL generation. This flag preserves trailing slash semantics for data request URLs to avoid ambiguity when your app distinguishes between trailing-slash and non-trailing-slash URLs.
|
|
226
|
-
|
|
227
|
-
Currently, your HTTP and `request` pathnames would be as follows for `/a/b/c` and `/a/b/c/`
|
|
228
|
-
|
|
229
|
-
| URL `/a/b/c` | **HTTP pathname** | **`request` pathname`** |
|
|
230
|
-
| ------------ | ----------------- | ----------------------- |
|
|
231
|
-
| **Document** | `/a/b/c` | `/a/b/c` ✅ |
|
|
232
|
-
| **Data** | `/a/b/c.data` | `/a/b/c` ✅ |
|
|
233
|
-
|
|
234
|
-
| URL `/a/b/c/` | **HTTP pathname** | **`request` pathname`** |
|
|
235
|
-
| ------------- | ----------------- | ----------------------- |
|
|
236
|
-
| **Document** | `/a/b/c/` | `/a/b/c/` ✅ |
|
|
237
|
-
| **Data** | `/a/b/c.data` | `/a/b/c` ⚠️ |
|
|
238
|
-
|
|
239
|
-
With this flag enabled, these pathnames will be made consistent though a new `_.data` format for client-side `.data` requests:
|
|
240
|
-
|
|
241
|
-
| URL `/a/b/c` | **HTTP pathname** | **`request` pathname`** |
|
|
242
|
-
| ------------ | ----------------- | ----------------------- |
|
|
243
|
-
| **Document** | `/a/b/c` | `/a/b/c` ✅ |
|
|
244
|
-
| **Data** | `/a/b/c.data` | `/a/b/c` ✅ |
|
|
245
|
-
|
|
246
|
-
| URL `/a/b/c/` | **HTTP pathname** | **`request` pathname`** |
|
|
247
|
-
| ------------- | ------------------ | ----------------------- |
|
|
248
|
-
| **Document** | `/a/b/c/` | `/a/b/c/` ✅ |
|
|
249
|
-
| **Data** | `/a/b/c/_.data` ⬅️ | `/a/b/c/` ✅ |
|
|
250
|
-
|
|
251
|
-
This flag also aligns the root data request to match this behavior by changing it from `/_root.data` to `/_.data`.
|
|
252
|
-
|
|
253
|
-
👉 **Enable the Flag**
|
|
254
|
-
|
|
255
|
-
```ts filename=react-router.config.ts
|
|
256
|
-
import type { Config } from "@react-router/dev/config";
|
|
257
|
-
|
|
258
|
-
export default {
|
|
259
|
-
future: {
|
|
260
|
-
v8_trailingSlashAwareDataRequests: true,
|
|
261
|
-
},
|
|
262
|
-
} satisfies Config;
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
**Update your Code**
|
|
266
|
-
|
|
267
|
-
If you have custom app, CDN, cache, or rewrite logic that matches `.data` request URLs, update it to handle the new trailing-slash-aware `/_.data` format.
|
|
268
|
-
|
|
269
22
|
## Unstable Future Flags (Optional)
|
|
270
23
|
|
|
271
24
|
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 having breaking changes patch/minor releases - adopt with caution!
|
|
@@ -275,6 +28,4 @@ _No current unstable flags to document_
|
|
|
275
28
|
[api-development-strategy]: ../community/api-development-strategy
|
|
276
29
|
[unstable]: ../community/api-development-strategy#unstable-flags
|
|
277
30
|
[observability]: ../how-to/instrumentation
|
|
278
|
-
[Response]: https://developer.mozilla.org/en-US/docs/Web/API/Response
|
|
279
31
|
[vite-environment]: https://vite.dev/guide/api-environment
|
|
280
|
-
[node-custom-server-template]: https://github.com/remix-run/react-router-templates/blob/7c617a435510bc3add3a5395c07bc65328b65e9e/node-custom-server/vite.config.ts
|