react-router 8.0.0-pre.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.
Files changed (168) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/development/dom-export.js +1 -1
  3. package/dist/development/index-react-server-client.js +1 -1
  4. package/dist/development/index-react-server.d.ts +9 -2
  5. package/dist/development/index-react-server.js +91 -88
  6. package/dist/development/index.d.ts +1 -2
  7. package/dist/development/index.js +2 -3
  8. package/dist/development/lib/actions.js +6 -18
  9. package/dist/development/lib/components.d.ts +11 -3
  10. package/dist/development/lib/components.js +8 -2
  11. package/dist/development/lib/context.js +1 -1
  12. package/dist/development/lib/dom/dom.js +1 -1
  13. package/dist/development/lib/dom/lib.d.ts +12 -1
  14. package/dist/development/lib/dom/lib.js +18 -6
  15. package/dist/development/lib/dom/server.js +2 -2
  16. package/dist/development/lib/dom/ssr/components.d.ts +4 -2
  17. package/dist/development/lib/dom/ssr/components.js +13 -3
  18. package/dist/development/lib/dom/ssr/data.js +1 -1
  19. package/dist/development/lib/dom/ssr/entry.d.ts +1 -0
  20. package/dist/development/lib/dom/ssr/errorBoundaries.js +7 -3
  21. package/dist/development/lib/dom/ssr/fallback.js +8 -3
  22. package/dist/development/lib/dom/ssr/fog-of-war.js +12 -2
  23. package/dist/development/lib/dom/ssr/hydration.js +1 -1
  24. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  25. package/dist/development/lib/dom/ssr/links.js +1 -1
  26. package/dist/development/lib/dom/ssr/markup.js +1 -1
  27. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  28. package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
  29. package/dist/development/lib/dom/ssr/routes.js +1 -1
  30. package/dist/development/lib/dom/ssr/server.d.ts +4 -1
  31. package/dist/development/lib/dom/ssr/server.js +2 -1
  32. package/dist/development/lib/dom/ssr/single-fetch.js +2 -3
  33. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  34. package/dist/development/lib/dom-export/hydrated-router.d.ts +1 -1
  35. package/dist/development/lib/dom-export/hydrated-router.js +14 -17
  36. package/dist/development/lib/errors.js +1 -1
  37. package/dist/development/lib/hooks.js +6 -4
  38. package/dist/development/lib/href.js +1 -1
  39. package/dist/development/lib/router/history.js +3 -2
  40. package/dist/development/lib/router/instrumentation.js +1 -1
  41. package/dist/development/lib/router/links.d.ts +3 -2
  42. package/dist/development/lib/router/router.js +13 -6
  43. package/dist/development/lib/router/url.js +18 -0
  44. package/dist/development/lib/router/utils.d.ts +6 -0
  45. package/dist/development/lib/router/utils.js +27 -8
  46. package/dist/development/lib/rsc/browser.js +21 -17
  47. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  48. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  49. package/dist/development/lib/rsc/html-stream/server.js +1 -1
  50. package/dist/development/lib/rsc/route-modules.js +1 -1
  51. package/dist/development/lib/rsc/server.ssr.js +27 -11
  52. package/dist/development/lib/server-runtime/cookies.js +1 -1
  53. package/dist/development/lib/server-runtime/crypto.js +1 -1
  54. package/dist/development/lib/server-runtime/data.js +1 -1
  55. package/dist/development/lib/server-runtime/dev.js +1 -1
  56. package/dist/development/lib/server-runtime/entry.js +1 -1
  57. package/dist/development/lib/server-runtime/errors.js +2 -22
  58. package/dist/development/lib/server-runtime/headers.js +1 -1
  59. package/dist/development/lib/server-runtime/invariant.js +1 -1
  60. package/dist/development/lib/server-runtime/mode.js +1 -1
  61. package/dist/development/lib/server-runtime/routeMatching.js +1 -1
  62. package/dist/development/lib/server-runtime/routes.js +1 -1
  63. package/dist/development/lib/server-runtime/server.js +17 -23
  64. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  65. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
  66. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
  67. package/dist/development/lib/server-runtime/sessions.js +1 -1
  68. package/dist/development/lib/server-runtime/single-fetch.js +4 -4
  69. package/dist/development/lib/server-runtime/urls.js +2 -5
  70. package/dist/development/lib/server-runtime/warnings.js +1 -1
  71. package/dist/development/lib/types/internal.js +1 -1
  72. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  73. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +2 -1
  74. package/dist/development/vendor/turbo-stream-v2/unflatten.js +3 -2
  75. package/dist/development/vendor/turbo-stream-v2/utils.js +2 -10
  76. package/dist/production/dom-export.js +1 -1
  77. package/dist/production/index-react-server-client.js +1 -1
  78. package/dist/production/index-react-server.d.ts +9 -2
  79. package/dist/production/index-react-server.js +91 -88
  80. package/dist/production/index.d.ts +1 -2
  81. package/dist/production/index.js +2 -3
  82. package/dist/production/lib/actions.js +6 -18
  83. package/dist/production/lib/components.d.ts +11 -3
  84. package/dist/production/lib/components.js +8 -2
  85. package/dist/production/lib/context.js +1 -1
  86. package/dist/production/lib/dom/dom.js +1 -1
  87. package/dist/production/lib/dom/lib.d.ts +12 -1
  88. package/dist/production/lib/dom/lib.js +18 -6
  89. package/dist/production/lib/dom/server.js +2 -2
  90. package/dist/production/lib/dom/ssr/components.d.ts +4 -2
  91. package/dist/production/lib/dom/ssr/components.js +13 -3
  92. package/dist/production/lib/dom/ssr/data.js +1 -1
  93. package/dist/production/lib/dom/ssr/entry.d.ts +1 -0
  94. package/dist/production/lib/dom/ssr/errorBoundaries.js +7 -3
  95. package/dist/production/lib/dom/ssr/fallback.js +3 -1
  96. package/dist/production/lib/dom/ssr/fog-of-war.js +12 -2
  97. package/dist/production/lib/dom/ssr/hydration.js +1 -1
  98. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  99. package/dist/production/lib/dom/ssr/links.js +1 -1
  100. package/dist/production/lib/dom/ssr/markup.js +1 -1
  101. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  102. package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
  103. package/dist/production/lib/dom/ssr/routes.js +1 -1
  104. package/dist/production/lib/dom/ssr/server.d.ts +4 -1
  105. package/dist/production/lib/dom/ssr/server.js +2 -1
  106. package/dist/production/lib/dom/ssr/single-fetch.js +2 -3
  107. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  108. package/dist/production/lib/dom-export/hydrated-router.d.ts +1 -1
  109. package/dist/production/lib/dom-export/hydrated-router.js +14 -17
  110. package/dist/production/lib/errors.js +1 -1
  111. package/dist/production/lib/hooks.js +6 -4
  112. package/dist/production/lib/href.js +1 -1
  113. package/dist/production/lib/router/history.js +3 -2
  114. package/dist/production/lib/router/instrumentation.js +1 -1
  115. package/dist/production/lib/router/links.d.ts +3 -2
  116. package/dist/production/lib/router/router.js +13 -6
  117. package/dist/production/lib/router/url.js +18 -0
  118. package/dist/production/lib/router/utils.d.ts +6 -0
  119. package/dist/production/lib/router/utils.js +27 -8
  120. package/dist/production/lib/rsc/browser.js +21 -17
  121. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  122. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  123. package/dist/production/lib/rsc/html-stream/server.js +1 -1
  124. package/dist/production/lib/rsc/route-modules.js +1 -1
  125. package/dist/production/lib/rsc/server.ssr.js +27 -11
  126. package/dist/production/lib/server-runtime/cookies.js +1 -1
  127. package/dist/production/lib/server-runtime/crypto.js +1 -1
  128. package/dist/production/lib/server-runtime/data.js +1 -1
  129. package/dist/production/lib/server-runtime/dev.js +1 -1
  130. package/dist/production/lib/server-runtime/entry.js +1 -1
  131. package/dist/production/lib/server-runtime/errors.js +2 -22
  132. package/dist/production/lib/server-runtime/headers.js +1 -1
  133. package/dist/production/lib/server-runtime/invariant.js +1 -1
  134. package/dist/production/lib/server-runtime/mode.js +1 -1
  135. package/dist/production/lib/server-runtime/routeMatching.js +1 -1
  136. package/dist/production/lib/server-runtime/routes.js +1 -1
  137. package/dist/production/lib/server-runtime/server.js +17 -23
  138. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  139. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
  140. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
  141. package/dist/production/lib/server-runtime/sessions.js +1 -1
  142. package/dist/production/lib/server-runtime/single-fetch.js +4 -4
  143. package/dist/production/lib/server-runtime/urls.js +2 -5
  144. package/dist/production/lib/server-runtime/warnings.js +1 -1
  145. package/dist/production/lib/types/internal.js +1 -1
  146. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  147. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +2 -1
  148. package/dist/production/vendor/turbo-stream-v2/unflatten.js +3 -2
  149. package/dist/production/vendor/turbo-stream-v2/utils.js +2 -10
  150. package/docs/explanation/code-splitting.md +1 -1
  151. package/docs/explanation/index-query-param.md +2 -2
  152. package/docs/explanation/type-safety.md +1 -1
  153. package/docs/how-to/data-strategy.md +5 -5
  154. package/docs/how-to/error-reporting.md +10 -2
  155. package/docs/how-to/headers.md +2 -1
  156. package/docs/how-to/security.md +9 -7
  157. package/docs/start/data/installation.md +4 -0
  158. package/docs/start/data/route-object.md +20 -0
  159. package/docs/start/framework/actions.md +0 -1
  160. package/docs/start/framework/data-loading.md +1 -1
  161. package/docs/start/framework/deploying.md +4 -0
  162. package/docs/start/framework/installation.md +0 -1
  163. package/docs/upgrading/v6.md +3 -0
  164. package/package.json +2 -2
  165. package/dist/development/lib/dom/ssr/errors.d.ts +0 -7
  166. package/dist/development/lib/dom/ssr/errors.js +0 -36
  167. package/dist/production/lib/dom/ssr/errors.d.ts +0 -7
  168. package/dist/production/lib/dom/ssr/errors.js +0 -36
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -22,7 +22,7 @@ const SERVER_NO_BODY_STATUS_CODES = new Set([...NO_BODY_STATUS_CODES, 304]);
22
22
  async function singleFetchAction(build, serverMode, staticHandler, request, loadContext, handleError) {
23
23
  try {
24
24
  try {
25
- throwIfPotentialCSRFAttack(request.headers, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []);
25
+ throwIfPotentialCSRFAttack(request, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []);
26
26
  } catch (e) {
27
27
  return handleQueryError(/* @__PURE__ */ new Error("Bad Request"), 400);
28
28
  }
@@ -37,7 +37,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, load
37
37
  return handleQueryError(error);
38
38
  }
39
39
  },
40
- normalizePath: (r) => getNormalizedPath(r, build.basename)
40
+ normalizePath: (r) => getNormalizedPath(r)
41
41
  }));
42
42
  } catch (error) {
43
43
  return handleQueryError(error);
@@ -90,7 +90,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, loa
90
90
  return handleQueryError(error);
91
91
  }
92
92
  },
93
- normalizePath: (r) => getNormalizedPath(r, build.basename)
93
+ normalizePath: (r) => getNormalizedPath(r)
94
94
  }));
95
95
  } catch (error) {
96
96
  return handleQueryError(error);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,15 +8,12 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { stripBasename } from "../router/utils.js";
12
11
  //#region lib/server-runtime/urls.ts
13
- function getNormalizedPath(request, basename) {
14
- basename = basename || "/";
12
+ function getNormalizedPath(request) {
15
13
  let url = new URL(request.url);
16
14
  let pathname = url.pathname;
17
15
  if (pathname.endsWith("/_.data")) pathname = pathname.replace(/_\.data$/, "");
18
16
  else pathname = pathname.replace(/\.data$/, "");
19
- if (stripBasename(pathname, basename) !== "/" && pathname.endsWith("/")) pathname = pathname.slice(0, -1);
20
17
  let searchParams = new URLSearchParams(url.search);
21
18
  searchParams.delete("_routes");
22
19
  let search = searchParams.toString();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,6 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
+ import "../../lib/router/utils.js";
11
12
  import { Deferred, createLineSplittingTransform } from "./utils.js";
12
13
  import { flatten } from "./flatten.js";
13
14
  import { unflatten } from "./unflatten.js";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,7 +8,8 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { Deferred, SUPPORTED_ERROR_TYPES } from "./utils.js";
11
+ import { SUPPORTED_ERROR_TYPES } from "../../lib/router/utils.js";
12
+ import { Deferred } from "./utils.js";
12
13
  //#region vendor/turbo-stream-v2/unflatten.ts
13
14
  const globalObj = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
14
15
  function unflatten(parsed) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.0.0-pre.0
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -9,14 +9,6 @@
9
9
  * @license MIT
10
10
  */
11
11
  //#region vendor/turbo-stream-v2/utils.ts
12
- const SUPPORTED_ERROR_TYPES = [
13
- "EvalError",
14
- "RangeError",
15
- "ReferenceError",
16
- "SyntaxError",
17
- "TypeError",
18
- "URIError"
19
- ];
20
12
  var Deferred = class {
21
13
  promise;
22
14
  resolve;
@@ -44,4 +36,4 @@ function createLineSplittingTransform() {
44
36
  });
45
37
  }
46
38
  //#endregion
47
- export { Deferred, SUPPORTED_ERROR_TYPES, createLineSplittingTransform };
39
+ export { Deferred, createLineSplittingTransform };
@@ -74,4 +74,4 @@ export default function Component({ loaderData }) {
74
74
 
75
75
  After building for the browser, only the `Component` will still be in the bundle, so you can use server-only code in the other module exports.
76
76
 
77
- [route-module]: ../../start/framework/route-module
77
+ [route-module]: ../start/framework/route-module
@@ -80,7 +80,7 @@ function Component() {
80
80
  }
81
81
  ```
82
82
 
83
- [loader]: ../api/data-routers/loader
83
+ [loader]: ../start/data/route-object#loader
84
84
  [form_element]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
85
85
  [form_component]: ../api/components/Form
86
- [action]: ../api/data-routers/action
86
+ [action]: ../start/data/route-object#action
@@ -50,7 +50,7 @@ React Router's type generation executes your route config (`app/routes.ts` by de
50
50
  It then generates a `+types/<route file>.d.ts` for each route within a special `.react-router/types/` directory.
51
51
  With [`rootDirs` configured][route-module-type-safety], TypeScript can import these generated files as if they were right next to their corresponding route modules.
52
52
 
53
- For a deeper dive into some of the design decisions, check out our [type inference decision doc](https://github.com/remix-run/react-router/blob/dev/decisions/0012-type-inference.md).
53
+ For a deeper dive into some of the design decisions, check out our [type inference decision doc](https://github.com/remix-run/react-router/blob/main/decisions/0012-type-inference.md).
54
54
 
55
55
  [route-module-type-safety]: ../how-to/route-module-type-safety
56
56
 
@@ -158,11 +158,11 @@ const matchesToLoad = matches.filter((match) => {
158
158
 
159
159
  ## Migrating away from `shouldLoad`
160
160
 
161
- Now that we have stabilized the new `match.shouldCallHandler()`/`match.shouldRevalidateArgs` fields, it's recommended to move away from the now-deprecated `match.shouldLoad` API. The prior boolean approach did not allow for custom `dataStrategy`functions to alter the default revalidation behavior, so the new function-based APIs were created to allow that.
161
+ Now that we have stabilized the new `match.shouldCallHandler()`/`match.shouldRevalidateArgs` fields, it's recommended to move away from the now-deprecated `match.shouldLoad` API. The prior boolean approach did not allow for custom `dataStrategy` functions to alter the default revalidation behavior, so the new function-based APIs were created to allow that.
162
162
 
163
163
  The major difference between these two APIs is that when using `shouldLoad`, calling `resolve()` would _only_ call the handler if `shouldLoad` was `true`. You could safely call it for all matches even if only a subset needed to have their handlers executed.
164
164
 
165
- With `shouldCallHandler`, you are in charge of which handlers should be called so calling resolve will automatically call the handler. You should only call resolve on a the set of matches you wish to run handlers for.
165
+ With `shouldCallHandler`, you are in charge of which handlers should be called so calling resolve will automatically call the handler. You should only call resolve on the set of matches you wish to run handlers for.
166
166
 
167
167
  Here's an example change from the prior API to the new API. Note that we pre-filter the `matchesToLoad` before calling `resolve()`:
168
168
 
@@ -184,9 +184,9 @@ return results;
184
184
 
185
185
  <docs-info>This is an unlikely use-case now that React Router has built-in middleware, but if you wish to use a custom middleware you can do so with a `dataStrategy`.</docs-info>
186
186
 
187
- Let's define a middleware on each route via [`handle`](../../start/data/route-object#handle)
187
+ Let's define a middleware on each route via [`handle`](../start/data/route-object#handle)
188
188
  and call middleware sequentially first, then call all
189
- [`loader`](../../start/data/route-object#loader)s in parallel - providing
189
+ [`loader`](../start/data/route-object#loader)s in parallel - providing
190
190
  any data made available via the middleware:
191
191
 
192
192
  ```ts
@@ -258,7 +258,7 @@ let router = createBrowserRouter(routes, {
258
258
 
259
259
  ### Custom Handler
260
260
 
261
- It's also possible you don't even want to define a [`loader`](../../start/daoute-object#loader)
261
+ It's also possible you don't even want to define a [`loader`](../start/data/route-object#loader)
262
262
  implementation at the route level. Maybe you want to just determine the
263
263
  routes and issue a single GraphQL request for all of your data. You can do
264
264
  that by setting your `route.loader=true` so it qualifies as "having a
@@ -104,7 +104,11 @@ See also:
104
104
  This function is called whenever React Router catches an error in your application on the client.
105
105
 
106
106
  ```tsx
107
- import { type ClientOnErrorFunction } from "react-router";
107
+ import {
108
+ createBrowserRouter,
109
+ type ClientOnErrorFunction,
110
+ } from "react-router";
111
+ import { RouterProvider } from "react-router/dom";
108
112
 
109
113
  const onError: ClientOnErrorFunction = (
110
114
  error,
@@ -116,8 +120,12 @@ const onError: ClientOnErrorFunction = (
116
120
  console.error(error, errorInfo);
117
121
  };
118
122
 
123
+ const router = createBrowserRouter(routes);
124
+
119
125
  function App() {
120
- return <RouterProvider onError={onError} />;
126
+ return (
127
+ <RouterProvider router={router} onError={onError} />
128
+ );
121
129
  }
122
130
  ```
123
131
 
@@ -110,7 +110,8 @@ The easiest way is to simply append to the parent headers. This avoids overwriti
110
110
  ```tsx
111
111
  export function headers({ parentHeaders }: HeadersArgs) {
112
112
  parentHeaders.append(
113
- "Permissions-Policy: geolocation=()",
113
+ "Permissions-Policy",
114
+ "geolocation=()",
114
115
  );
115
116
  return parentHeaders;
116
117
  }
@@ -13,18 +13,20 @@ This is by no means a comprehensive guide, but React Router provides features to
13
13
 
14
14
  ## `Content-Security-Policy`
15
15
 
16
- If you are implementing a [Content-Security-Policy (CSP)][csp] in your application, specifically one using the `unsafe-inline` directive, you will need to specify a [`nonce`][nonce] attribute on the inline `<script>` elements rendered in your HTML. This must be specified on any API that generates inline scripts, including:
16
+ If you are implementing a [Content-Security-Policy (CSP)][csp] in your application, specifically one using the `unsafe-inline` directive, you will need to specify a [`nonce`][nonce] attribute on the inline `<script>` elements rendered in your HTML.
17
17
 
18
- - [`<Scripts nonce>`][scripts] (`root.tsx`)
19
- - [`<ScrollRestoration nonce>`][scrollrestoration] (`root.tsx`)
20
- - [`<ServerRouter nonce>`][serverrouter] (`entry.server.tsx`)
21
- - [`renderToPipeableStream(..., { nonce })`][renderToPipeableStream] (`entry.server.tsx`)
22
- - [`renderToReadableStream(..., { nonce })`][renderToReadableStream] (`entry.server.tsx`)
18
+ Add a nonce to these two spots in [`entry.server.tsx`][entryserver]:
19
+
20
+ - The [`<ServerRouter nonce>`][serverrouter] prop
21
+ - This will be proxied along through React Context and used for other Framework Mode components that output `nonce`-aware elements, including [`<Scripts>`][scripts], [`<ScrollRestoration>`][scrollrestoration]
22
+ - If those components specify their own `nonce` prop, it will override the `ServerRouter` value
23
+ - The `nonce` options of [`renderToPipeableStream`][renderToPipeableStream]/[`renderToReadableStream`][renderToReadableStream]
23
24
 
24
25
  [csp]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP
26
+ [entryserver]: ../api/framework-conventions/entry.server.tsx
25
27
  [nonce]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
26
28
  [renderToPipeableStream]: https://react.dev/reference/react-dom/server/renderToPipeableStream
27
29
  [renderToReadableStream]: https://react.dev/reference/react-dom/server/renderToReadableStream
28
30
  [scripts]: ../api/components/Scripts
29
31
  [scrollrestoration]: ../api/components/ScrollRestoration
30
- [serverrouter]: ../api/components/ServerRouter
32
+ [serverrouter]: ../api/framework-routers/ServerRouter
@@ -47,6 +47,10 @@ ReactDOM.createRoot(root).render(
47
47
  );
48
48
  ```
49
49
 
50
+ <docs-info>Data Routers should not be held in React state. You should create your router
51
+ once outside of the React tree and pass it to `<RouterProvider>`. You can use
52
+ `patchRoutesOnNavigation` to add additional routes programmatically.</docs-info>
53
+
50
54
  ---
51
55
 
52
56
  Next: [Routing](./routing)
@@ -240,9 +240,29 @@ createBrowserRouter([
240
240
  ]);
241
241
  ```
242
242
 
243
+ ## `handle`
244
+
245
+ Route handle allows apps to add anything to a route match in `useMatches` to create abstractions (like breadcrumbs, etc.).
246
+
247
+ ```tsx
248
+ createBrowserRouter([
249
+ {
250
+ path: "/app",
251
+ handle: {
252
+ breadcrumb: "App",
253
+ },
254
+ },
255
+ ]);
256
+ ```
257
+
258
+ See also:
259
+
260
+ - [`useMatches`][use-matches]
261
+
243
262
  ---
244
263
 
245
264
  Next: [Data Loading](./data-loading)
246
265
 
247
266
  [loader-params]: https://api.reactrouter.com/v7/interfaces/react-router.LoaderFunctionArgs
248
267
  [middleware]: ../../how-to/middleware
268
+ [use-matches]: ../../api/hooks/useMatches
@@ -172,4 +172,3 @@ See the [Using Fetchers][fetchers] guide for more information.
172
172
  Next: [Navigating](./navigating)
173
173
 
174
174
  [fetchers]: ../../how-to/fetchers
175
- [data]: ../../api/react-router/data
@@ -142,7 +142,7 @@ export async function clientLoader({
142
142
  }: Route.ClientLoaderArgs) {
143
143
  const res = await fetch(`/api/products/${params.pid}`);
144
144
  const serverData = await serverLoader();
145
- return { ...serverData, ...res.json() };
145
+ return { ...serverData, ...(await res.json()) };
146
146
  }
147
147
 
148
148
  export default function Product({
@@ -94,3 +94,7 @@ Netlify maintains their own template for React Router. Checkout the [Netlify Gui
94
94
  ### EdgeOne Pages
95
95
 
96
96
  EdgeOne Pages maintains their own template for React Router. Checkout the [EdgeOne Pages Guide](https://pages.edgeone.ai/document/framework-react-router) for more information.
97
+
98
+ ### DeployHQ
99
+
100
+ DeployHQ maintains their own guide for deploying React Router v7 to your own server. Checkout the [DeployHQ Guide](https://www.deployhq.com/guides/deploy-react-router-from-github) for more information.
@@ -37,6 +37,5 @@ npx create-react-router@latest --template remix-run/react-router-templates/<temp
37
37
 
38
38
  Next: [Routing](./routing)
39
39
 
40
- [manual_usage]: ../how-to/manual-usage
41
40
  [default-template]: https://github.com/remix-run/react-router-templates/tree/main/default
42
41
  [react-router-templates]: https://github.com/remix-run/react-router-templates
@@ -141,6 +141,8 @@ You don't need to update anything unless you are using `React.lazy` _inside_ of
141
141
 
142
142
  Using `React.lazy` inside of a component is incompatible with `React.useTransition` (or other code that makes promises inside of components). Move `React.lazy` to the module scope and stop making promises inside of components. This is not a limitation of React Router but rather incorrect usage of React.
143
143
 
144
+ <docs-info>We added a flag to opt-out of `React.startTransition` in v7 so you can use that to upgrade to v7 without adopting React transition-enabled navigations if needed. See the [transition docs][transitions] for more information.</docs-info>
145
+
144
146
  ### v7_fetcherPersist
145
147
 
146
148
  <docs-warning>If you are not using a `<RouterProvider>` you can skip this</docs-warning>
@@ -377,3 +379,4 @@ Congratulations, you're now on v7!
377
379
  [react-flushsync]: https://react.dev/reference/react-dom/flushSync
378
380
  [response-json]: https://developer.mozilla.org/en-US/docs/Web/API/Response/json
379
381
  [data-util]: https://api.reactrouter.com/v7/functions/react-router.data.html
382
+ [transitions]: ../explanation/react-transitions
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-router",
3
3
  "type": "module",
4
- "version": "8.0.0-pre.0",
4
+ "version": "8.0.0-pre.1",
5
5
  "description": "Declarative routing for React",
6
6
  "keywords": [
7
7
  "react",
@@ -110,7 +110,7 @@
110
110
  "README.md"
111
111
  ],
112
112
  "engines": {
113
- "node": ">=22.12.0"
113
+ "node": ">=22.22.0"
114
114
  },
115
115
  "scripts": {
116
116
  "build": "wireit",
@@ -1,7 +0,0 @@
1
-
2
- import { RouterState } from "../../router/router.js";
3
-
4
- //#region lib/dom/ssr/errors.d.ts
5
- declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
6
- //#endregion
7
- export { deserializeErrors };
@@ -1,36 +0,0 @@
1
- /**
2
- * react-router v8.0.0-pre.0
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 { ErrorResponseImpl } from "../../router/utils.js";
12
- //#region lib/dom/ssr/errors.ts
13
- function deserializeErrors(errors) {
14
- if (!errors) return null;
15
- let entries = Object.entries(errors);
16
- let serialized = {};
17
- for (let [key, val] of entries) if (val && val.__type === "RouteErrorResponse") serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true);
18
- else if (val && val.__type === "Error") {
19
- if (val.__subType) {
20
- let ErrorConstructor = window[val.__subType];
21
- if (typeof ErrorConstructor === "function") try {
22
- let error = new ErrorConstructor(val.message);
23
- error.stack = val.stack;
24
- serialized[key] = error;
25
- } catch (e) {}
26
- }
27
- if (serialized[key] == null) {
28
- let error = new Error(val.message);
29
- error.stack = val.stack;
30
- serialized[key] = error;
31
- }
32
- } else serialized[key] = val;
33
- return serialized;
34
- }
35
- //#endregion
36
- export { deserializeErrors };
@@ -1,7 +0,0 @@
1
-
2
- import { RouterState } from "../../router/router.js";
3
-
4
- //#region lib/dom/ssr/errors.d.ts
5
- declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
6
- //#endregion
7
- export { deserializeErrors };
@@ -1,36 +0,0 @@
1
- /**
2
- * react-router v8.0.0-pre.0
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 { ErrorResponseImpl } from "../../router/utils.js";
12
- //#region lib/dom/ssr/errors.ts
13
- function deserializeErrors(errors) {
14
- if (!errors) return null;
15
- let entries = Object.entries(errors);
16
- let serialized = {};
17
- for (let [key, val] of entries) if (val && val.__type === "RouteErrorResponse") serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true);
18
- else if (val && val.__type === "Error") {
19
- if (val.__subType) {
20
- let ErrorConstructor = window[val.__subType];
21
- if (typeof ErrorConstructor === "function") try {
22
- let error = new ErrorConstructor(val.message);
23
- error.stack = val.stack;
24
- serialized[key] = error;
25
- } catch (e) {}
26
- }
27
- if (serialized[key] == null) {
28
- let error = new Error(val.message);
29
- error.stack = val.stack;
30
- serialized[key] = error;
31
- }
32
- } else serialized[key] = val;
33
- return serialized;
34
- }
35
- //#endregion
36
- export { deserializeErrors };