react-router 0.0.0-experimental-e56aa53bc → 0.0.0-experimental-e6fb6e074

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 (65) hide show
  1. package/CHANGELOG.md +18 -734
  2. package/README.md +14 -5
  3. package/dist/index.d.ts +30 -0
  4. package/dist/index.js +1501 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/components.d.ts +157 -0
  7. package/dist/lib/context.d.ts +102 -0
  8. package/dist/lib/deprecations.d.ts +4 -0
  9. package/dist/lib/hooks.d.ts +181 -0
  10. package/dist/main.js +19 -0
  11. package/dist/react-router.development.js +1397 -0
  12. package/dist/react-router.development.js.map +1 -0
  13. package/dist/react-router.production.min.js +12 -0
  14. package/dist/react-router.production.min.js.map +1 -0
  15. package/dist/umd/react-router.development.js +1624 -0
  16. package/dist/umd/react-router.development.js.map +1 -0
  17. package/dist/umd/react-router.production.min.js +12 -0
  18. package/dist/umd/react-router.production.min.js.map +1 -0
  19. package/package.json +9 -111
  20. package/dist/development/chunk-RMWJZNG5.mjs +0 -11505
  21. package/dist/development/data-CQbyyGzl.d.mts +0 -11
  22. package/dist/development/data-CQbyyGzl.d.ts +0 -11
  23. package/dist/development/dom-export.d.mts +0 -23
  24. package/dist/development/dom-export.d.ts +0 -23
  25. package/dist/development/dom-export.js +0 -6341
  26. package/dist/development/dom-export.mjs +0 -222
  27. package/dist/development/fog-of-war-C5L_Yd5M.d.mts +0 -1778
  28. package/dist/development/fog-of-war-DrUCUQQ-.d.ts +0 -1778
  29. package/dist/development/index.d.mts +0 -855
  30. package/dist/development/index.d.ts +0 -855
  31. package/dist/development/index.js +0 -11664
  32. package/dist/development/index.mjs +0 -263
  33. package/dist/development/lib/types/route-module.d.mts +0 -209
  34. package/dist/development/lib/types/route-module.d.ts +0 -209
  35. package/dist/development/lib/types/route-module.js +0 -28
  36. package/dist/development/lib/types/route-module.mjs +0 -10
  37. package/dist/development/route-data-BIYebJr3.d.mts +0 -1749
  38. package/dist/development/route-data-BIYebJr3.d.ts +0 -1749
  39. package/dist/development/rsc-export.d.mts +0 -1788
  40. package/dist/development/rsc-export.d.ts +0 -1788
  41. package/dist/development/rsc-export.js +0 -2778
  42. package/dist/development/rsc-export.mjs +0 -2743
  43. package/dist/production/chunk-BXBFRMFA.mjs +0 -11505
  44. package/dist/production/data-CQbyyGzl.d.mts +0 -11
  45. package/dist/production/data-CQbyyGzl.d.ts +0 -11
  46. package/dist/production/dom-export.d.mts +0 -23
  47. package/dist/production/dom-export.d.ts +0 -23
  48. package/dist/production/dom-export.js +0 -6341
  49. package/dist/production/dom-export.mjs +0 -222
  50. package/dist/production/fog-of-war-C5L_Yd5M.d.mts +0 -1778
  51. package/dist/production/fog-of-war-DrUCUQQ-.d.ts +0 -1778
  52. package/dist/production/index.d.mts +0 -855
  53. package/dist/production/index.d.ts +0 -855
  54. package/dist/production/index.js +0 -11664
  55. package/dist/production/index.mjs +0 -263
  56. package/dist/production/lib/types/route-module.d.mts +0 -209
  57. package/dist/production/lib/types/route-module.d.ts +0 -209
  58. package/dist/production/lib/types/route-module.js +0 -28
  59. package/dist/production/lib/types/route-module.mjs +0 -10
  60. package/dist/production/route-data-BIYebJr3.d.mts +0 -1749
  61. package/dist/production/route-data-BIYebJr3.d.ts +0 -1749
  62. package/dist/production/rsc-export.d.mts +0 -1788
  63. package/dist/production/rsc-export.d.ts +0 -1788
  64. package/dist/production/rsc-export.js +0 -2778
  65. package/dist/production/rsc-export.mjs +0 -2743
package/CHANGELOG.md CHANGED
@@ -1,766 +1,50 @@
1
1
  # `react-router`
2
2
 
3
- ## 7.5.1
4
-
5
- ### Patch Changes
6
-
7
- - Fix single fetch bug where no revalidation request would be made when navigating upwards to a reused parent route ([#13253](https://github.com/remix-run/react-router/pull/13253))
8
-
9
- - When using the object-based `route.lazy` API, the `HydrateFallback` and `hydrateFallbackElement` properties are now skipped when lazy loading routes after hydration. ([#13376](https://github.com/remix-run/react-router/pull/13376))
10
-
11
- If you move the code for these properties into a separate file, you can use this optimization to avoid downloading unused hydration code. For example:
12
-
13
- ```ts
14
- createBrowserRouter([
15
- {
16
- path: "/show/:showId",
17
- lazy: {
18
- loader: async () => (await import("./show.loader.js")).loader,
19
- Component: async () => (await import("./show.component.js")).Component,
20
- HydrateFallback: async () =>
21
- (await import("./show.hydrate-fallback.js")).HydrateFallback,
22
- },
23
- },
24
- ]);
25
- ```
26
-
27
- - Properly revalidate prerendered paths when param values change ([#13380](https://github.com/remix-run/react-router/pull/13380))
28
-
29
- - UNSTABLE: Add a new `unstable_runClientMiddleware` argument to `dataStrategy` to enable middleware execution in custom `dataStrategy` implementations ([#13395](https://github.com/remix-run/react-router/pull/13395))
30
-
31
- - UNSTABLE: Add better error messaging when `getLoadContext` is not updated to return a `Map`" ([#13242](https://github.com/remix-run/react-router/pull/13242))
32
-
33
- - Do not automatically add `null` to `staticHandler.query()` `context.loaderData` if routes do not have loaders ([#13223](https://github.com/remix-run/react-router/pull/13223))
34
-
35
- - This was a Remix v2 implementation detail inadvertently left in for React Router v7
36
- - Now that we allow returning `undefined` from loaders, our prior check of `loaderData[routeId] !== undefined` was no longer sufficient and was changed to a `routeId in loaderData` check - these `null` values can cause issues for this new check
37
- - ⚠️ This could be a "breaking bug fix" for you if you are doing manual SSR with `createStaticHandler()`/`<StaticRouterProvider>`, and using `context.loaderData` to control `<RouterProvider>` hydration behavior on the client
38
-
39
- - Fix prerendering when a loader returns a redirect ([#13365](https://github.com/remix-run/react-router/pull/13365))
40
-
41
- - UNSTABLE: Update context type for `LoaderFunctionArgs`/`ActionFunctionArgs` when middleware is enabled ([#13381](https://github.com/remix-run/react-router/pull/13381))
42
-
43
- - Add support for the new `unstable_shouldCallHandler`/`unstable_shouldRevalidateArgs` APIs in `dataStrategy` ([#13253](https://github.com/remix-run/react-router/pull/13253))
44
-
45
- ## 7.5.0
46
-
47
- ### Minor Changes
48
-
49
- - Add granular object-based API for `route.lazy` to support lazy loading of individual route properties, for example: ([#13294](https://github.com/remix-run/react-router/pull/13294))
50
-
51
- ```ts
52
- createBrowserRouter([
53
- {
54
- path: "/show/:showId",
55
- lazy: {
56
- loader: async () => (await import("./show.loader.js")).loader,
57
- action: async () => (await import("./show.action.js")).action,
58
- Component: async () => (await import("./show.component.js")).Component,
59
- },
60
- },
61
- ]);
62
- ```
63
-
64
- **Breaking change for `route.unstable_lazyMiddleware` consumers**
65
-
66
- The `route.unstable_lazyMiddleware` property is no longer supported. If you want to lazily load middleware, you must use the new object-based `route.lazy` API with `route.lazy.unstable_middleware`, for example:
67
-
68
- ```ts
69
- createBrowserRouter([
70
- {
71
- path: "/show/:showId",
72
- lazy: {
73
- unstable_middleware: async () =>
74
- (await import("./show.middleware.js")).middleware,
75
- // etc.
76
- },
77
- },
78
- ]);
79
- ```
80
-
81
- ### Patch Changes
82
-
83
- - Introduce `unstable_subResourceIntegrity` future flag that enables generation of an importmap with integrity for the scripts that will be loaded by the browser. ([#13163](https://github.com/remix-run/react-router/pull/13163))
84
-
85
- ## 7.4.1
86
-
87
- ### Patch Changes
88
-
89
- - Fix types on `unstable_MiddlewareFunction` to avoid type errors when a middleware doesn't return a value ([#13311](https://github.com/remix-run/react-router/pull/13311))
90
- - Dedupe calls to `route.lazy` functions ([#13260](https://github.com/remix-run/react-router/pull/13260))
91
- - Add support for `route.unstable_lazyMiddleware` function to allow lazy loading of middleware logic. ([#13210](https://github.com/remix-run/react-router/pull/13210))
92
-
93
- **Breaking change for `unstable_middleware` consumers**
94
-
95
- The `route.unstable_middleware` property is no longer supported in the return value from `route.lazy`. If you want to lazily load middleware, you must use `route.unstable_lazyMiddleware`.
96
-
97
- ## 7.4.0
98
-
99
- ### Patch Changes
100
-
101
- - Fix root loader data on initial load redirects in SPA mode ([#13222](https://github.com/remix-run/react-router/pull/13222))
102
- - Load ancestor pathless/index routes in lazy route discovery for upwards non-eager-discoery routing ([#13203](https://github.com/remix-run/react-router/pull/13203))
103
- - Fix `shouldRevalidate` behavior for `clientLoader`-only routes in `ssr:true` apps ([#13221](https://github.com/remix-run/react-router/pull/13221))
104
- - UNSTABLE: Fix `RequestHandler` `loadContext` parameter type when middleware is enabled ([#13204](https://github.com/remix-run/react-router/pull/13204))
105
- - UNSTABLE: Update `Route.unstable_MiddlewareFunction` to have a return value of `Response | undefined` instead of `Response | void` becaue you should not return anything if you aren't returning the `Response` ([#13199](https://github.com/remix-run/react-router/pull/13199))
106
- - UNSTABLE(BREAKING): If a middleware throws an error, ensure we only bubble the error itself via `next()` and are no longer leaking the `MiddlewareError` implementation detail ([#13180](https://github.com/remix-run/react-router/pull/13180))
107
-
108
- ## 7.3.0
3
+ ## 6.30.0
109
4
 
110
5
  ### Minor Changes
111
6
 
112
- - Add `fetcherKey` as a parameter to `patchRoutesOnNavigation` ([#13061](https://github.com/remix-run/react-router/pull/13061))
113
-
114
- - In framework mode, Lazy Route Discovery will now detect manifest version mismatches after a new deploy
115
- - On navigations to undiscovered routes, this mismatch will trigger a document reload of the destination path
116
- - On `fetcher` calls to undiscovered routes, this mismatch will trigger a document reload of the current path
7
+ - Add `fetcherKey` as a parameter to `patchRoutesOnNavigation` ([#13109](https://github.com/remix-run/react-router/pull/13109))
117
8
 
118
9
  ### Patch Changes
119
10
 
120
- - Skip resource route flow in dev server in SPA mode ([#13113](https://github.com/remix-run/react-router/pull/13113))
121
-
122
- - Support middleware on routes (unstable) ([#12941](https://github.com/remix-run/react-router/pull/12941))
123
-
124
- Middleware is implemented behind a `future.unstable_middleware` flag. To enable, you must enable the flag and the types in your `react-router-config.ts` file:
125
-
126
- ```ts
127
- import type { Config } from "@react-router/dev/config";
128
- import type { Future } from "react-router";
129
-
130
- declare module "react-router" {
131
- interface Future {
132
- unstable_middleware: true; // 👈 Enable middleware types
133
- }
134
- }
135
-
136
- export default {
137
- future: {
138
- unstable_middleware: true, // 👈 Enable middleware
139
- },
140
- } satisfies Config;
141
- ```
142
-
143
- ⚠️ Middleware is unstable and should not be adopted in production. There is at least one known de-optimization in route module loading for `clientMiddleware` that we will be addressing this before a stable release.
144
-
145
- ⚠️ Enabling middleware contains a breaking change to the `context` parameter passed to your `loader`/`action` functions - see below for more information.
146
-
147
- Once enabled, routes can define an array of middleware functions that will run sequentially before route handlers run. These functions accept the same parameters as `loader`/`action` plus an additional `next` parameter to run the remaining data pipeline. This allows middlewares to perform logic before and after handlers execute.
148
-
149
- ```tsx
150
- // Framework mode
151
- export const unstable_middleware = [serverLogger, serverAuth]; // server
152
- export const unstable_clientMiddleware = [clientLogger]; // client
153
-
154
- // Library mode
155
- const routes = [
156
- {
157
- path: "/",
158
- // Middlewares are client-side for library mode SPA's
159
- unstable_middleware: [clientLogger, clientAuth],
160
- loader: rootLoader,
161
- Component: Root,
162
- },
163
- ];
164
- ```
165
-
166
- Here's a simple example of a client-side logging middleware that can be placed on the root route:
167
-
168
- ```tsx
169
- const clientLogger: Route.unstable_ClientMiddlewareFunction = async (
170
- { request },
171
- next
172
- ) => {
173
- let start = performance.now();
174
-
175
- // Run the remaining middlewares and all route loaders
176
- await next();
177
-
178
- let duration = performance.now() - start;
179
- console.log(`Navigated to ${request.url} (${duration}ms)`);
180
- };
181
- ```
182
-
183
- Note that in the above example, the `next`/`middleware` functions don't return anything. This is by design as on the client there is no "response" to send over the network like there would be for middlewares running on the server. The data is all handled behind the scenes by the stateful `router`.
184
-
185
- For a server-side middleware, the `next` function will return the HTTP `Response` that React Router will be sending across the wire, thus giving you a chance to make changes as needed. You may throw a new response to short circuit and respond immediately, or you may return a new or altered response to override the default returned by `next()`.
186
-
187
- ```tsx
188
- const serverLogger: Route.unstable_MiddlewareFunction = async (
189
- { request, params, context },
190
- next
191
- ) => {
192
- let start = performance.now();
193
-
194
- // 👇 Grab the response here
195
- let res = await next();
196
-
197
- let duration = performance.now() - start;
198
- console.log(`Navigated to ${request.url} (${duration}ms)`);
199
-
200
- // 👇 And return it here (optional if you don't modify the response)
201
- return res;
202
- };
203
- ```
204
-
205
- You can throw a `redirect` from a middleware to short circuit any remaining processing:
206
-
207
- ```tsx
208
- import { sessionContext } from "../context";
209
- const serverAuth: Route.unstable_MiddlewareFunction = (
210
- { request, params, context },
211
- next
212
- ) => {
213
- let session = context.get(sessionContext);
214
- let user = session.get("user");
215
- if (!user) {
216
- session.set("returnTo", request.url);
217
- throw redirect("/login", 302);
218
- }
219
- };
220
- ```
221
-
222
- _Note that in cases like this where you don't need to do any post-processing you don't need to call the `next` function or return a `Response`._
223
-
224
- Here's another example of using a server middleware to detect 404s and check the CMS for a redirect:
225
-
226
- ```tsx
227
- const redirects: Route.unstable_MiddlewareFunction = async ({
228
- request,
229
- next,
230
- }) => {
231
- // attempt to handle the request
232
- let res = await next();
233
-
234
- // if it's a 404, check the CMS for a redirect, do it last
235
- // because it's expensive
236
- if (res.status === 404) {
237
- let cmsRedirect = await checkCMSRedirects(request.url);
238
- if (cmsRedirect) {
239
- throw redirect(cmsRedirect, 302);
240
- }
241
- }
242
-
243
- return res;
244
- };
245
- ```
246
-
247
- **`context` parameter**
248
-
249
- When middleware is enabled, your application will use a different type of `context` parameter in your loaders and actions to provide better type safety. Instead of `AppLoadContext`, `context` will now be an instance of `ContextProvider` that you can use with type-safe contexts (similar to `React.createContext`):
250
-
251
- ```ts
252
- import { unstable_createContext } from "react-router";
253
- import { Route } from "./+types/root";
254
- import type { Session } from "./sessions.server";
255
- import { getSession } from "./sessions.server";
256
-
257
- let sessionContext = unstable_createContext<Session>();
258
-
259
- const sessionMiddleware: Route.unstable_MiddlewareFunction = ({
260
- context,
261
- request,
262
- }) => {
263
- let session = await getSession(request);
264
- context.set(sessionContext, session);
265
- // ^ must be of type Session
266
- };
267
-
268
- // ... then in some downstream middleware
269
- const loggerMiddleware: Route.unstable_MiddlewareFunction = ({
270
- context,
271
- request,
272
- }) => {
273
- let session = context.get(sessionContext);
274
- // ^ typeof Session
275
- console.log(session.get("userId"), request.method, request.url);
276
- };
277
-
278
- // ... or some downstream loader
279
- export function loader({ context }: Route.LoaderArgs) {
280
- let session = context.get(sessionContext);
281
- let profile = await getProfile(session.get("userId"));
282
- return { profile };
283
- }
284
- ```
285
-
286
- If you are using a custom server with a `getLoadContext` function, the return value for initial context values passed from the server adapter layer is no longer an object and should now return an `unstable_InitialContext` (`Map<RouterContext, unknown>`):
287
-
288
- ```ts
289
- let adapterContext = unstable_createContext<MyAdapterContext>();
290
-
291
- function getLoadContext(req, res): unstable_InitialContext {
292
- let map = new Map();
293
- map.set(adapterContext, getAdapterContext(req));
294
- return map;
295
- }
296
- ```
297
-
298
- - Fix types for loaderData and actionData that contained `Record`s ([#13139](https://github.com/remix-run/react-router/pull/13139))
299
-
300
- UNSTABLE(BREAKING):
301
-
302
- `unstable_SerializesTo` added a way to register custom serialization types in Single Fetch for other library and framework authors like Apollo.
303
- It was implemented with branded type whose branded property that was made optional so that casting arbitrary values was easy:
304
-
305
- ```ts
306
- // without the brand being marked as optional
307
- let x1 = 42 as unknown as unstable_SerializesTo<number>;
308
- // ^^^^^^^^^^
309
-
310
- // with the brand being marked as optional
311
- let x2 = 42 as unstable_SerializesTo<number>;
312
- ```
313
-
314
- However, this broke type inference in `loaderData` and `actionData` for any `Record` types as those would now (incorrectly) match `unstable_SerializesTo`.
315
- This affected all users, not just those that depended on `unstable_SerializesTo`.
316
- To fix this, the branded property of `unstable_SerializesTo` is marked as required instead of optional.
317
-
318
- For library and framework authors using `unstable_SerializesTo`, you may need to add `as unknown` casts before casting to `unstable_SerializesTo`.
319
-
320
- - \[REMOVE] Remove middleware depth logic and always call middlware for all matches ([#13172](https://github.com/remix-run/react-router/pull/13172))
321
-
322
- - Fix single fetch `_root.data` requests when a `basename` is used ([#12898](https://github.com/remix-run/react-router/pull/12898))
323
-
324
- - Add `context` support to client side data routers (unstable) ([#12941](https://github.com/remix-run/react-router/pull/12941))
325
-
326
- Your application `loader` and `action` functions on the client will now receive a `context` parameter. This is an instance of `unstable_RouterContextProvider` that you use with type-safe contexts (similar to `React.createContext`) and is most useful with the corresponding `middleware`/`clientMiddleware` API's:
327
-
328
- ```ts
329
- import { unstable_createContext } from "react-router";
330
-
331
- type User = {
332
- /*...*/
333
- };
334
-
335
- let userContext = unstable_createContext<User>();
336
-
337
- function sessionMiddleware({ context }) {
338
- let user = await getUser();
339
- context.set(userContext, user);
340
- }
341
-
342
- // ... then in some downstream loader
343
- function loader({ context }) {
344
- let user = context.get(userContext);
345
- let profile = await getProfile(user.id);
346
- return { profile };
347
- }
348
- ```
349
-
350
- Similar to server-side requests, a fresh `context` will be created per navigation (or `fetcher` call). If you have initial data you'd like to populate in the context for every request, you can provide an `unstable_getContext` function at the root of your app:
351
-
352
- - Library mode - `createBrowserRouter(routes, { unstable_getContext })`
353
- - Framework mode - `<HydratedRouter unstable_getContext>`
354
-
355
- This function should return an value of type `unstable_InitialContext` which is a `Map<unstable_RouterContext, unknown>` of context's and initial values:
356
-
357
- ```ts
358
- const loggerContext = unstable_createContext<(...args: unknown[]) => void>();
359
-
360
- function logger(...args: unknown[]) {
361
- console.log(new Date.toISOString(), ...args);
362
- }
363
-
364
- function unstable_getContext() {
365
- let map = new Map();
366
- map.set(loggerContext, logger);
367
- return map;
368
- }
369
- ```
11
+ - Updated dependencies:
12
+ - `@remix-run/router@1.23.0`
370
13
 
371
- ## 7.2.0
14
+ ## 6.29.0
372
15
 
373
16
  ### Minor Changes
374
17
 
375
- - New type-safe `href` utility that guarantees links point to actual paths in your app ([#13012](https://github.com/remix-run/react-router/pull/13012))
18
+ - Provide the request `signal` as a parameter to `patchRoutesOnNavigation` ([#12900](https://github.com/remix-run/react-router/pull/12900))
376
19
 
377
- ```tsx
378
- import { href } from "react-router";
379
-
380
- export default function Component() {
381
- const link = href("/blog/:slug", { slug: "my-first-post" });
382
- return (
383
- <main>
384
- <Link to={href("/products/:id", { id: "asdf" })} />
385
- <NavLink to={href("/:lang?/about", { lang: "en" })} />
386
- </main>
387
- );
388
- }
389
- ```
20
+ - This can be used to abort any manifest fetches if the in-flight navigation/fetcher is aborted
390
21
 
391
22
  ### Patch Changes
392
23
 
393
- - Fix typegen for repeated params ([#13012](https://github.com/remix-run/react-router/pull/13012))
394
-
395
- In React Router, path parameters are keyed by their name.
396
- So for a path pattern like `/a/:id/b/:id?/c/:id`, the last `:id` will set the value for `id` in `useParams` and the `params` prop.
397
- For example, `/a/1/b/2/c/3` will result in the value `{ id: 3 }` at runtime.
398
-
399
- Previously, generated types for params incorrectly modeled repeated params with an array.
400
- So `/a/1/b/2/c/3` generated a type like `{ id: [1,2,3] }`.
401
-
402
- To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters.
403
- So `/a/1/b/2/c/3` now generates a type like `{ id: 3 }`.
404
-
405
- - Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request ([#12948](https://github.com/remix-run/react-router/pull/12948))
406
-
407
- - Properly handle revalidations to across a prerender/SPA boundary ([#13021](https://github.com/remix-run/react-router/pull/13021))
408
-
409
- - In "hybrid" applications where some routes are pre-rendered and some are served from a SPA fallback, we need to avoid making `.data` requests if the path wasn't pre-rendered because the request will 404
410
- - We don't know all the pre-rendered paths client-side, however:
411
- - All `loader` data in `ssr:false` mode is static because it's generated at build time
412
- - A route must use a `clientLoader` to do anything dynamic
413
- - Therefore, if a route only has a `loader` and not a `clientLoader`, we disable revalidation by default because there is no new data to retrieve
414
- - We short circuit and skip single fetch `.data` request logic if there are no server loaders with `shouldLoad=true` in our single fetch `dataStrategy`
415
- - This ensures that the route doesn't cause a `.data` request that would 404 after a submission
416
-
417
- - Error at build time in `ssr:false` + `prerender` apps for the edge case scenario of: ([#13021](https://github.com/remix-run/react-router/pull/13021))
418
-
419
- - A parent route has only a `loader` (does not have a `clientLoader`)
420
- - The parent route is pre-rendered
421
- - The parent route has children routes which are not prerendered
422
- - This means that when the child paths are loaded via the SPA fallback, the parent won't have any `loaderData` because there is no server on which to run the `loader`
423
- - This can be resolved by either adding a parent `clientLoader` or pre-rendering the child paths
424
- - If you add a `clientLoader`, calling the `serverLoader()` on non-prerendered paths will throw a 404
425
-
426
- - Add unstable support for splitting route modules in framework mode via `future.unstable_splitRouteModules` ([#11871](https://github.com/remix-run/react-router/pull/11871))
427
-
428
- - Add `unstable_SerializesTo` brand type for library authors to register types serializable by React Router's streaming format (`turbo-stream`) ([`ab5b05b02`](https://github.com/remix-run/react-router/commit/ab5b05b02f99f062edb3c536c392197c88eb6c77))
429
-
430
- - Align dev server behavior with static file server behavior when `ssr:false` is set ([#12948](https://github.com/remix-run/react-router/pull/12948))
431
-
432
- - When no `prerender` config exists, only SSR down to the root `HydrateFallback` (SPA Mode)
433
- - When a `prerender` config exists but the current path is not prerendered, only SSR down to the root `HydrateFallback` (SPA Fallback)
434
- - Return a 404 on `.data` requests to non-pre-rendered paths
435
-
436
- - Improve prefetch performance of CSS side effects in framework mode ([#12889](https://github.com/remix-run/react-router/pull/12889))
437
-
438
- - Disable Lazy Route Discovery for all `ssr:false` apps and not just "SPA Mode" because there is no runtime server to serve the search-param-configured `__manifest` requests ([#12894](https://github.com/remix-run/react-router/pull/12894))
439
-
440
- - We previously only disabled this for "SPA Mode" which is `ssr:false` and no `prerender` config but we realized it should apply to all `ssr:false` apps, including those prerendering multiple pages
441
- - In those `prerender` scenarios we would prerender the `/__manifest` file assuming the static file server would serve it but that makes some unneccesary assumptions about the static file server behaviors
442
-
443
- - Properly handle interrupted manifest requests in lazy route discovery ([#12915](https://github.com/remix-run/react-router/pull/12915))
444
-
445
- ## 7.1.5
446
-
447
- ### Patch Changes
448
-
449
- - Fix regression introduced in `7.1.4` via [#12800](https://github.com/remix-run/react-router/pull/12800) that caused issues navigating to hash routes inside splat routes for applications using Lazy Route Discovery (`patchRoutesOnNavigation`) ([#12927](https://github.com/remix-run/react-router/pull/12927))
450
-
451
- ## 7.1.4
452
-
453
- ### Patch Changes
454
-
455
- - Internal reorg to clean up some duplicated route module types ([#12799](https://github.com/remix-run/react-router/pull/12799))
456
- - Properly handle status codes that cannot have a body in single fetch responses (204, etc.) ([#12760](https://github.com/remix-run/react-router/pull/12760))
457
- - Stop erroring on resource routes that return raw strings/objects and instead serialize them as `text/plain` or `application/json` responses ([#12848](https://github.com/remix-run/react-router/pull/12848))
458
- - This only applies when accessed as a resource route without the `.data` extension
459
- - When accessed from a Single Fetch `.data` request, they will still be encoded via `turbo-stream`
460
- - Optimize Lazy Route Discovery path discovery to favor a single `querySelectorAll` call at the `body` level instead of many calls at the sub-tree level ([#12731](https://github.com/remix-run/react-router/pull/12731))
461
- - Properly bubble headers as `errorHeaders` when throwing a `data()` result ([#12846](https://github.com/remix-run/react-router/pull/12846))
462
- - Avoid duplication of `Set-Cookie` headers could be duplicated if also returned from `headers`
463
- - Optimize route matching by skipping redundant `matchRoutes` calls when possible ([#12800](https://github.com/remix-run/react-router/pull/12800))
464
-
465
- ## 7.1.3
466
-
467
- _No changes_
468
-
469
- ## 7.1.2
470
-
471
- ### Patch Changes
472
-
473
- - Fix issue with fetcher data cleanup in the data layer on fetcher unmount ([#12681](https://github.com/remix-run/react-router/pull/12681))
474
- - Do not rely on `symbol` for filtering out `redirect` responses from loader data ([#12694](https://github.com/remix-run/react-router/pull/12694))
475
-
476
- Previously, some projects were getting type checking errors like:
477
-
478
- ```ts
479
- error TS4058: Return type of exported function has or is using name 'redirectSymbol' from external module "node_modules/..." but cannot be named.
480
- ```
481
-
482
- Now that `symbol`s are not used for the `redirect` response type, these errors should no longer be present.
483
-
484
- ## 7.1.1
485
-
486
- _No changes_
487
-
488
- ## 7.1.0
489
-
490
- ### Patch Changes
491
-
492
- - Throw unwrapped single fetch redirect to align with pre-single fetch behavior ([#12506](https://github.com/remix-run/react-router/pull/12506))
493
- - Ignore redirects when inferring loader data types ([#12527](https://github.com/remix-run/react-router/pull/12527))
494
- - Remove `<Link prefetch>` warning which suffers from false positives in a lazy route discovery world ([#12485](https://github.com/remix-run/react-router/pull/12485))
24
+ - Do not log v7 deprecation warnings in production builds ([#12794](https://github.com/remix-run/react-router/pull/12794))
25
+ - Limit matchRoutes optimization to client side routers ([#12881](https://github.com/remix-run/react-router/pull/12881))
26
+ - Optimize route matching by skipping redundant `matchRoutes` calls when possible ([#12169](https://github.com/remix-run/react-router/pull/12169))
27
+ - Updated dependencies:
28
+ - `@remix-run/router@1.22.0`
495
29
 
496
- ## 7.0.2
30
+ ## 6.28.2
497
31
 
498
32
  ### Patch Changes
499
33
 
500
- - temporarily only use one build in export map so packages can have a peer dependency on react router ([#12437](https://github.com/remix-run/react-router/pull/12437))
501
- - Generate wide `matches` and `params` types for current route and child routes ([#12397](https://github.com/remix-run/react-router/pull/12397))
502
-
503
- At runtime, `matches` includes child route matches and `params` include child route path parameters.
504
- But previously, we only generated types for parent routes in `matches`; for `params`, we only considered the parent routes and the current route.
505
- To align our generated types more closely to the runtime behavior, we now generate more permissive, wider types when accessing child route information.
506
-
507
- ## 7.0.1
508
-
509
- _No changes_
510
-
511
- ## 7.0.0
512
-
513
- ### Major Changes
514
-
515
- - Remove the original `defer` implementation in favor of using raw promises via single fetch and `turbo-stream`. This removes these exports from React Router: ([#11744](https://github.com/remix-run/react-router/pull/11744))
516
-
517
- - `defer`
518
- - `AbortedDeferredError`
519
- - `type TypedDeferredData`
520
- - `UNSAFE_DeferredData`
521
- - `UNSAFE_DEFERRED_SYMBOL`,
522
-
523
- - - Collapse `@remix-run/router` into `react-router` ([#11505](https://github.com/remix-run/react-router/pull/11505))
524
- - Collapse `react-router-dom` into `react-router`
525
- - Collapse `@remix-run/server-runtime` into `react-router`
526
- - Collapse `@remix-run/testing` into `react-router`
527
-
528
- - Remove single fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
529
-
530
- - Drop support for Node 16, React Router SSR now requires Node 18 or higher ([#11391](https://github.com/remix-run/react-router/pull/11391))
531
-
532
- - Remove `future.v7_startTransition` flag ([#11696](https://github.com/remix-run/react-router/pull/11696))
533
-
534
- - - Expose the underlying router promises from the following APIs for compsition in React 19 APIs: ([#11521](https://github.com/remix-run/react-router/pull/11521))
535
- - `useNavigate()`
536
- - `useSubmit`
537
- - `useFetcher().load`
538
- - `useFetcher().submit`
539
- - `useRevalidator.revalidate`
540
-
541
- - Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
542
-
543
- - For Remix consumers migrating to React Router, the `crypto` global from the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is now required when using cookie and session APIs. This means that the following APIs are provided from `react-router` rather than platform-specific packages: ([#11837](https://github.com/remix-run/react-router/pull/11837))
544
-
545
- - `createCookie`
546
- - `createCookieSessionStorage`
547
- - `createMemorySessionStorage`
548
- - `createSessionStorage`
549
-
550
- For consumers running older versions of Node, the `installGlobals` function from `@remix-run/node` has been updated to define `globalThis.crypto`, using [Node's `require('node:crypto').webcrypto` implementation.](https://nodejs.org/api/webcrypto.html)
551
-
552
- Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
553
-
554
- - `createCookieFactory`
555
- - `createSessionStorageFactory`
556
- - `createCookieSessionStorageFactory`
557
- - `createMemorySessionStorageFactory`
558
-
559
- - Imports/Exports cleanup ([#11840](https://github.com/remix-run/react-router/pull/11840))
560
-
561
- - Removed the following exports that were previously public API from `@remix-run/router`
562
- - types
563
- - `AgnosticDataIndexRouteObject`
564
- - `AgnosticDataNonIndexRouteObject`
565
- - `AgnosticDataRouteMatch`
566
- - `AgnosticDataRouteObject`
567
- - `AgnosticIndexRouteObject`
568
- - `AgnosticNonIndexRouteObject`
569
- - `AgnosticRouteMatch`
570
- - `AgnosticRouteObject`
571
- - `TrackedPromise`
572
- - `unstable_AgnosticPatchRoutesOnMissFunction`
573
- - `Action` -> exported as `NavigationType` via `react-router`
574
- - `Router` exported as `DataRouter` to differentiate from RR's `<Router>`
575
- - API
576
- - `getToPathname` (`@private`)
577
- - `joinPaths` (`@private`)
578
- - `normalizePathname` (`@private`)
579
- - `resolveTo` (`@private`)
580
- - `stripBasename` (`@private`)
581
- - `createBrowserHistory` -> in favor of `createBrowserRouter`
582
- - `createHashHistory` -> in favor of `createHashRouter`
583
- - `createMemoryHistory` -> in favor of `createMemoryRouter`
584
- - `createRouter`
585
- - `createStaticHandler` -> in favor of wrapper `createStaticHandler` in RR Dom
586
- - `getStaticContextFromError`
587
- - Removed the following exports that were previously public API from `react-router`
588
- - `Hash`
589
- - `Pathname`
590
- - `Search`
591
-
592
- - update minimum node version to 18 ([#11690](https://github.com/remix-run/react-router/pull/11690))
593
-
594
- - Remove `future.v7_prependBasename` from the ionternalized `@remix-run/router` package ([#11726](https://github.com/remix-run/react-router/pull/11726))
595
-
596
- - Migrate Remix type generics to React Router ([#12180](https://github.com/remix-run/react-router/pull/12180))
597
-
598
- - These generics are provided for Remix v2 migration purposes
599
- - These generics and the APIs they exist on should be considered informally deprecated in favor of the new `Route.*` types
600
- - Anyone migrating from React Router v6 should probably not leverage these new generics and should migrate straight to the `Route.*` types
601
- - For React Router v6 users, these generics are new and should not impact your app, with one exception
602
- - `useFetcher` previously had an optional generic (used primarily by Remix v2) that expected the data type
603
- - This has been updated in v7 to expect the type of the function that generates the data (i.e., `typeof loader`/`typeof action`)
604
- - Therefore, you should update your usages:
605
- - ❌ `useFetcher<LoaderData>()`
606
- - ✅ `useFetcher<typeof loader>()`
607
-
608
- - Remove `future.v7_throwAbortReason` from internalized `@remix-run/router` package ([#11728](https://github.com/remix-run/react-router/pull/11728))
609
-
610
- - Add `exports` field to all packages ([#11675](https://github.com/remix-run/react-router/pull/11675))
611
-
612
- - node package no longer re-exports from react-router ([#11702](https://github.com/remix-run/react-router/pull/11702))
613
-
614
- - renamed RemixContext to FrameworkContext ([#11705](https://github.com/remix-run/react-router/pull/11705))
615
-
616
- - updates the minimum React version to 18 ([#11689](https://github.com/remix-run/react-router/pull/11689))
617
-
618
- - PrefetchPageDescriptor replaced by PageLinkDescriptor ([#11960](https://github.com/remix-run/react-router/pull/11960))
619
-
620
- - - Consolidate types previously duplicated across `@remix-run/router`, `@remix-run/server-runtime`, and `@remix-run/react` now that they all live in `react-router` ([#12177](https://github.com/remix-run/react-router/pull/12177))
621
- - Examples: `LoaderFunction`, `LoaderFunctionArgs`, `ActionFunction`, `ActionFunctionArgs`, `DataFunctionArgs`, `RouteManifest`, `LinksFunction`, `Route`, `EntryRoute`
622
- - The `RouteManifest` type used by the "remix" code is now slightly stricter because it is using the former `@remix-run/router` `RouteManifest`
623
- - `Record<string, Route> -> Record<string, Route | undefined>`
624
- - Removed `AppData` type in favor of inlining `unknown` in the few locations it was used
625
- - Removed `ServerRuntimeMeta*` types in favor of the `Meta*` types they were duplicated from
626
-
627
- - - Remove the `future.v7_partialHydration` flag ([#11725](https://github.com/remix-run/react-router/pull/11725))
628
- - This also removes the `<RouterProvider fallbackElement>` prop
629
- - To migrate, move the `fallbackElement` to a `hydrateFallbackElement`/`HydrateFallback` on your root route
630
- - Also worth nothing there is a related breaking changer with this future flag:
631
- - Without `future.v7_partialHydration` (when using `fallbackElement`), `state.navigation` was populated during the initial load
632
- - With `future.v7_partialHydration`, `state.navigation` remains in an `"idle"` state during the initial load
633
-
634
- - Remove `v7_relativeSplatPath` future flag ([#11695](https://github.com/remix-run/react-router/pull/11695))
635
-
636
- - Drop support for Node 18, update minimum Node vestion to 20 ([#12171](https://github.com/remix-run/react-router/pull/12171))
637
-
638
- - Remove `installGlobals()` as this should no longer be necessary
639
-
640
- - Remove remaining future flags ([#11820](https://github.com/remix-run/react-router/pull/11820))
641
-
642
- - React Router `v7_skipActionErrorRevalidation`
643
- - Remix `v3_fetcherPersist`, `v3_relativeSplatPath`, `v3_throwAbortReason`
644
-
645
- - rename createRemixStub to createRoutesStub ([#11692](https://github.com/remix-run/react-router/pull/11692))
646
-
647
- - Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties` ([#11751](https://github.com/remix-run/react-router/pull/11751))
648
-
649
- - Add `react-router/dom` subpath export to properly enable `react-dom` as an optional `peerDependency` ([#11851](https://github.com/remix-run/react-router/pull/11851))
650
-
651
- - This ensures that we don't blindly `import ReactDOM from "react-dom"` in `<RouterProvider>` in order to access `ReactDOM.flushSync()`, since that would break `createMemoryRouter` use cases in non-DOM environments
652
- - DOM environments should import from `react-router/dom` to get the proper component that makes `ReactDOM.flushSync()` available:
653
- - If you are using the Vite plugin, use this in your `entry.client.tsx`:
654
- - `import { HydratedRouter } from 'react-router/dom'`
655
- - If you are not using the Vite plugin and are manually calling `createBrowserRouter`/`createHashRouter`:
656
- - `import { RouterProvider } from "react-router/dom"`
657
-
658
- - Remove `future.v7_fetcherPersist` flag ([#11731](https://github.com/remix-run/react-router/pull/11731))
659
-
660
- - Update `cookie` dependency to `^1.0.1` - please see the [release notes](https://github.com/jshttp/cookie/releases) for any breaking changes ([#12172](https://github.com/remix-run/react-router/pull/12172))
661
-
662
- ### Minor Changes
663
-
664
- - - Add support for `prerender` config in the React Router vite plugin, to support existing SSG use-cases ([#11539](https://github.com/remix-run/react-router/pull/11539))
665
- - You can use the `prerender` config to pre-render your `.html` and `.data` files at build time and then serve them statically at runtime (either from a running server or a CDN)
666
- - `prerender` can either be an array of string paths, or a function (sync or async) that returns an array of strings so that you can dynamically generate the paths by talking to your CMS, etc.
667
-
668
- ```ts
669
- // react-router.config.ts
670
- import type { Config } from "@react-router/dev/config";
671
-
672
- export default {
673
- async prerender() {
674
- let slugs = await fakeGetSlugsFromCms();
675
- // Prerender these paths into `.html` files at build time, and `.data`
676
- // files if they have loaders
677
- return ["/", "/about", ...slugs.map((slug) => `/product/${slug}`)];
678
- },
679
- } satisfies Config;
680
-
681
- async function fakeGetSlugsFromCms() {
682
- await new Promise((r) => setTimeout(r, 1000));
683
- return ["shirt", "hat"];
684
- }
685
- ```
686
-
687
- - Params, loader data, and action data as props for route component exports ([#11961](https://github.com/remix-run/react-router/pull/11961))
688
-
689
- ```tsx
690
- export default function Component({ params, loaderData, actionData }) {}
691
-
692
- export function HydrateFallback({ params }) {}
693
- export function ErrorBoundary({ params, loaderData, actionData }) {}
694
- ```
695
-
696
- - Remove duplicate `RouterProvider` impliementations ([#11679](https://github.com/remix-run/react-router/pull/11679))
697
-
698
- - ### Typesafety improvements ([#12019](https://github.com/remix-run/react-router/pull/12019))
699
-
700
- React Router now generates types for each of your route modules.
701
- You can access those types by importing them from `./+types.<route filename without extension>`.
702
- For example:
703
-
704
- ```ts
705
- // app/routes/product.tsx
706
- import type * as Route from "./+types.product";
707
-
708
- export function loader({ params }: Route.LoaderArgs) {}
709
-
710
- export default function Component({ loaderData }: Route.ComponentProps) {}
711
- ```
712
-
713
- This initial implementation targets type inference for:
714
-
715
- - `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
716
- - `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
717
- - `ActionData` : Action data from `action` and/or `clientAction` within your route module
718
-
719
- In the future, we plan to add types for the rest of the route module exports: `meta`, `links`, `headers`, `shouldRevalidate`, etc.
720
- We also plan to generate types for typesafe `Link`s:
721
-
722
- ```tsx
723
- <Link to="/products/:id" params={{ id: 1 }} />
724
- // ^^^^^^^^^^^^^ ^^^^^^^^^
725
- // typesafe `to` and `params` based on the available routes in your app
726
- ```
727
-
728
- Check out our docs for more:
729
-
730
- - [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
731
- - [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
732
-
733
- - Stabilize `unstable_dataStrategy` ([#11969](https://github.com/remix-run/react-router/pull/11969))
34
+ - Updated dependencies:
35
+ - `@remix-run/router@1.21.1`
734
36
 
735
- - Stabilize `unstable_patchRoutesOnNavigation` ([#11970](https://github.com/remix-run/react-router/pull/11970))
37
+ ## 6.28.1
736
38
 
737
39
  ### Patch Changes
738
40
 
739
- - No changes ([`506329c4e`](https://github.com/remix-run/react-router/commit/506329c4e2e7aba9837cbfa44df6103b49423745))
740
-
741
- - chore: re-enable development warnings through a `development` exports condition. ([#12269](https://github.com/remix-run/react-router/pull/12269))
742
-
743
- - Remove unstable upload handler. ([#12015](https://github.com/remix-run/react-router/pull/12015))
744
-
745
- - Remove unneeded dependency on @web3-storage/multipart-parser ([#12274](https://github.com/remix-run/react-router/pull/12274))
746
-
747
- - Fix redirects returned from loaders/actions using `data()` ([#12021](https://github.com/remix-run/react-router/pull/12021))
748
-
749
- - fix(react-router): (v7) fix static prerender of non-ascii characters ([#12161](https://github.com/remix-run/react-router/pull/12161))
750
-
751
- - Replace `substr` with `substring` ([#12080](https://github.com/remix-run/react-router/pull/12080))
752
-
753
- - Remove the deprecated `json` utility ([#12146](https://github.com/remix-run/react-router/pull/12146))
754
-
755
- - You can use [`Response.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json_static) if you still need to construct JSON responses in your app
756
-
757
- - Remove unneeded dependency on source-map ([#12275](https://github.com/remix-run/react-router/pull/12275))
41
+ - Allow users to opt out of deprecation warnings by setting flags to false ([#12441](https://github.com/remix-run/react-router/pull/12441))
758
42
 
759
43
  ## 6.28.0
760
44
 
761
45
  ### Minor Changes
762
46
 
763
- - - Log deprecation warnings for v7 flags ([#11750](https://github.com/remix-run/react-router/pull/11750))
47
+ - Log deprecation warnings for v7 flags ([#11750](https://github.com/remix-run/react-router/pull/11750))
764
48
  - Add deprecation warnings to `json`/`defer` in favor of returning raw objects
765
49
  - These methods will be removed in React Router v7
766
50