react-router-dom 0.0.0-experimental-e16afd9b7 → 0.0.0-experimental-52e9b8eb3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,849 @@
1
+ # `react-router-dom`
2
+
3
+ ## 6.23.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Check for `document` existence when checking `startViewTransition` ([#11544](https://github.com/remix-run/react-router/pull/11544))
8
+ - Change the `react-router-dom/server` import back to `react-router-dom` instead of `index.ts` ([#11514](https://github.com/remix-run/react-router/pull/11514))
9
+ - Updated dependencies:
10
+ - `@remix-run/router@1.16.1`
11
+ - `react-router@6.23.1`
12
+
13
+ ## 6.23.0
14
+
15
+ ### Minor Changes
16
+
17
+ - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098))
18
+ - This option allows Data Router applications to take control over the approach for executing route loaders and actions
19
+ - The default implementation is today's behavior, to fetch all loaders in parallel, but this option allows users to implement more advanced data flows including Remix single-fetch, middleware/context APIs, automatic loader caching, and more
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies:
24
+ - `@remix-run/router@1.16.0`
25
+ - `react-router@6.23.0`
26
+
27
+ ## 6.22.3
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies:
32
+ - `@remix-run/router@1.15.3`
33
+ - `react-router@6.22.3`
34
+
35
+ ## 6.22.2
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies:
40
+ - `@remix-run/router@1.15.2`
41
+ - `react-router@6.22.2`
42
+
43
+ ## 6.22.1
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies:
48
+ - `react-router@6.22.1`
49
+ - `@remix-run/router@1.15.1`
50
+
51
+ ## 6.22.0
52
+
53
+ ### Minor Changes
54
+
55
+ - Include a `window__reactRouterVersion` tag for CWV Report detection ([#11222](https://github.com/remix-run/react-router/pull/11222))
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies:
60
+ - `@remix-run/router@1.15.0`
61
+ - `react-router@6.22.0`
62
+
63
+ ## 6.21.3
64
+
65
+ ### Patch Changes
66
+
67
+ - Fix `NavLink` `isPending` when a `basename` is used ([#11195](https://github.com/remix-run/react-router/pull/11195))
68
+ - Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
69
+ - Updated dependencies:
70
+ - `react-router@6.21.3`
71
+
72
+ ## 6.21.2
73
+
74
+ ### Patch Changes
75
+
76
+ - Leverage `useId` for internal fetcher keys when available ([#11166](https://github.com/remix-run/react-router/pull/11166))
77
+ - Updated dependencies:
78
+ - `@remix-run/router@1.14.2`
79
+ - `react-router@6.21.2`
80
+
81
+ ## 6.21.1
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies:
86
+ - `react-router@6.21.1`
87
+ - `@remix-run/router@1.14.1`
88
+
89
+ ## 6.21.0
90
+
91
+ ### Minor Changes
92
+
93
+ - Add a new `future.v7_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. ([#11087](https://github.com/remix-run/react-router/pull/11087))
94
+
95
+ This fix was originally added in [#10983](https://github.com/remix-run/react-router/issues/10983) and was later reverted in [#11078](https://github.com/remix-run/react-router/pull/11078) because it was determined that a large number of existing applications were relying on the buggy behavior (see [#11052](https://github.com/remix-run/react-router/issues/11052))
96
+
97
+ **The Bug**
98
+ The buggy behavior is that without this flag, the default behavior when resolving relative paths is to _ignore_ any splat (`*`) portion of the current route path.
99
+
100
+ **The Background**
101
+ This decision was originally made thinking that it would make the concept of nested different sections of your apps in `<Routes>` easier if relative routing would _replace_ the current splat:
102
+
103
+ ```jsx
104
+ <BrowserRouter>
105
+ <Routes>
106
+ <Route path="/" element={<Home />} />
107
+ <Route path="dashboard/*" element={<Dashboard />} />
108
+ </Routes>
109
+ </BrowserRouter>
110
+ ```
111
+
112
+ Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
113
+
114
+ ```jsx
115
+ function Dashboard() {
116
+ return (
117
+ <div>
118
+ <h2>Dashboard</h2>
119
+ <nav>
120
+ <Link to="/">Dashboard Home</Link>
121
+ <Link to="team">Team</Link>
122
+ <Link to="projects">Projects</Link>
123
+ </nav>
124
+
125
+ <Routes>
126
+ <Route path="/" element={<DashboardHome />} />
127
+ <Route path="team" element={<DashboardTeam />} />
128
+ <Route path="projects" element={<DashboardProjects />} />
129
+ </Routes>
130
+ </div>
131
+ );
132
+ }
133
+ ```
134
+
135
+ Now, all links and route paths are relative to the router above them. This makes code splitting and compartmentalizing your app really easy. You could render the `Dashboard` as its own independent app, or embed it into your large app without making any changes to it.
136
+
137
+ **The Problem**
138
+
139
+ The problem is that this concept of ignoring part of a path breaks a lot of other assumptions in React Router - namely that `"."` always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using `"."`:
140
+
141
+ ```jsx
142
+ // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
143
+ function DashboardTeam() {
144
+ // ❌ This is broken and results in <a href="/dashboard">
145
+ return <Link to=".">A broken link to the Current URL</Link>;
146
+
147
+ // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
148
+ return <Link to="./team">A broken link to the Current URL</Link>;
149
+ }
150
+ ```
151
+
152
+ We've also introduced an issue that we can no longer move our `DashboardTeam` component around our route hierarchy easily - since it behaves differently if we're underneath a non-splat route, such as `/dashboard/:widget`. Now, our `"."` links will, properly point to ourself _inclusive of the dynamic param value_ so behavior will break from it's corresponding usage in a `/dashboard/*` route.
153
+
154
+ Even worse, consider a nested splat route configuration:
155
+
156
+ ```jsx
157
+ <BrowserRouter>
158
+ <Routes>
159
+ <Route path="dashboard">
160
+ <Route path="*" element={<Dashboard />} />
161
+ </Route>
162
+ </Routes>
163
+ </BrowserRouter>
164
+ ```
165
+
166
+ Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
167
+
168
+ Another common issue arose in Data Routers (and Remix) where any `<Form>` should post to it's own route `action` if you the user doesn't specify a form action:
169
+
170
+ ```jsx
171
+ let router = createBrowserRouter({
172
+ path: "/dashboard",
173
+ children: [
174
+ {
175
+ path: "*",
176
+ action: dashboardAction,
177
+ Component() {
178
+ // ❌ This form is broken! It throws a 405 error when it submits because
179
+ // it tries to submit to /dashboard (without the splat value) and the parent
180
+ // `/dashboard` route doesn't have an action
181
+ return <Form method="post">...</Form>;
182
+ },
183
+ },
184
+ ],
185
+ });
186
+ ```
187
+
188
+ This is just a compounded issue from the above because the default location for a `Form` to submit to is itself (`"."`) - and if we ignore the splat portion, that now resolves to the parent route.
189
+
190
+ **The Solution**
191
+ If you are leveraging this behavior, it's recommended to enable the future flag, move your splat to it's own route, and leverage `../` for any links to "sibling" pages:
192
+
193
+ ```jsx
194
+ <BrowserRouter>
195
+ <Routes>
196
+ <Route path="dashboard">
197
+ <Route index path="*" element={<Dashboard />} />
198
+ </Route>
199
+ </Routes>
200
+ </BrowserRouter>
201
+
202
+ function Dashboard() {
203
+ return (
204
+ <div>
205
+ <h2>Dashboard</h2>
206
+ <nav>
207
+ <Link to="..">Dashboard Home</Link>
208
+ <Link to="../team">Team</Link>
209
+ <Link to="../projects">Projects</Link>
210
+ </nav>
211
+
212
+ <Routes>
213
+ <Route path="/" element={<DashboardHome />} />
214
+ <Route path="team" element={<DashboardTeam />} />
215
+ <Route path="projects" element={<DashboardProjects />} />
216
+ </Router>
217
+ </div>
218
+ );
219
+ }
220
+ ```
221
+
222
+ This way, `.` means "the full current pathname for my route" in all cases (including static, dynamic, and splat routes) and `..` always means "my parents pathname".
223
+
224
+ ### Patch Changes
225
+
226
+ - Updated dependencies:
227
+ - `@remix-run/router@1.14.0`
228
+ - `react-router@6.21.0`
229
+
230
+ ## 6.20.1
231
+
232
+ ### Patch Changes
233
+
234
+ - Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see <https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329>). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
235
+ - Updated dependencies:
236
+ - `react-router@6.20.1`
237
+ - `@remix-run/router@1.13.1`
238
+
239
+ ## 6.20.0
240
+
241
+ ### Minor Changes
242
+
243
+ - Export the `PathParam` type from the public API ([#10719](https://github.com/remix-run/react-router/pull/10719))
244
+
245
+ ### Patch Changes
246
+
247
+ - Updated dependencies:
248
+ - `react-router@6.20.0`
249
+ - `@remix-run/router@1.13.0`
250
+
251
+ ## 6.19.0
252
+
253
+ ### Minor Changes
254
+
255
+ - Add `unstable_flushSync` option to `useNavigate`/`useSumbit`/`fetcher.load`/`fetcher.submit` to opt-out of `React.startTransition` and into `ReactDOM.flushSync` for state updates ([#11005](https://github.com/remix-run/react-router/pull/11005))
256
+ - Allow `unstable_usePrompt` to accept a `BlockerFunction` in addition to a `boolean` ([#10991](https://github.com/remix-run/react-router/pull/10991))
257
+
258
+ ### Patch Changes
259
+
260
+ - Fix issue where a changing fetcher `key` in a `useFetcher` that remains mounted wasn't getting picked up ([#11009](https://github.com/remix-run/react-router/pull/11009))
261
+ - Fix `useFormAction` which was incorrectly inheriting the `?index` query param from child route `action` submissions ([#11025](https://github.com/remix-run/react-router/pull/11025))
262
+ - Fix `NavLink` `active` logic when `to` location has a trailing slash ([#10734](https://github.com/remix-run/react-router/pull/10734))
263
+ - Updated dependencies:
264
+ - `react-router@6.19.0`
265
+ - `@remix-run/router@1.12.0`
266
+
267
+ ## 6.18.0
268
+
269
+ ### Minor Changes
270
+
271
+ - Add support for manual fetcher key specification via `useFetcher({ key: string })` so you can access the same fetcher instance from different components in your application without prop-drilling ([RFC](https://github.com/remix-run/remix/discussions/7698)) ([#10960](https://github.com/remix-run/react-router/pull/10960))
272
+
273
+ - Fetcher keys are now also exposed on the fetchers returned from `useFetchers` so that they can be looked up by `key`
274
+
275
+ - Add `navigate`/`fetcherKey` params/props to `useSumbit`/`Form` to support kicking off a fetcher submission under the hood with an optionally user-specified `key` ([#10960](https://github.com/remix-run/react-router/pull/10960))
276
+
277
+ - Invoking a fetcher in this way is ephemeral and stateless
278
+ - If you need to access the state of one of these fetchers, you will need to leverage `useFetcher({ key })` to look it up elsewhere
279
+
280
+ ### Patch Changes
281
+
282
+ - Adds a fetcher context to `RouterProvider` that holds completed fetcher data, in preparation for the upcoming future flag that will change the fetcher persistence/cleanup behavior ([#10961](https://github.com/remix-run/react-router/pull/10961))
283
+ - Fix the `future` prop on `BrowserRouter`, `HashRouter` and `MemoryRouter` so that it accepts a `Partial<FutureConfig>` instead of requiring all flags to be included. ([#10962](https://github.com/remix-run/react-router/pull/10962))
284
+ - Updated dependencies:
285
+ - `@remix-run/router@1.11.0`
286
+ - `react-router@6.18.0`
287
+
288
+ ## 6.17.0
289
+
290
+ ### Minor Changes
291
+
292
+ - Add experimental support for the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition) via `document.startViewTransition` to enable CSS animated transitions on SPA navigations in your application. ([#10916](https://github.com/remix-run/react-router/pull/10916))
293
+
294
+ The simplest approach to enabling a View Transition in your React Router app is via the new `<Link unstable_viewTransition>` prop. This will cause the navigation DOM update to be wrapped in `document.startViewTransition` which will enable transitions for the DOM update. Without any additional CSS styles, you'll get a basic cross-fade animation for your page.
295
+
296
+ If you need to apply more fine-grained styles for your animations, you can leverage the `unstable_useViewTransitionState` hook which will tell you when a transition is in progress and you can use that to apply classes or styles:
297
+
298
+ ```jsx
299
+ function ImageLink(to, src, alt) {
300
+ let isTransitioning = unstable_useViewTransitionState(to);
301
+ return (
302
+ <Link to={to} unstable_viewTransition>
303
+ <img
304
+ src={src}
305
+ alt={alt}
306
+ style={{
307
+ viewTransitionName: isTransitioning ? "image-expand" : "",
308
+ }}
309
+ />
310
+ </Link>
311
+ );
312
+ }
313
+ ```
314
+
315
+ You can also use the `<NavLink unstable_viewTransition>` shorthand which will manage the hook usage for you and automatically add a `transitioning` class to the `<a>` during the transition:
316
+
317
+ ```css
318
+ a.transitioning img {
319
+ view-transition-name: "image-expand";
320
+ }
321
+ ```
322
+
323
+ ```jsx
324
+ <NavLink to={to} unstable_viewTransition>
325
+ <img src={src} alt={alt} />
326
+ </NavLink>
327
+ ```
328
+
329
+ For an example usage of View Transitions with React Router, check out [our fork](https://github.com/brophdawg11/react-router-records) of the [Astro Records](https://github.com/Charca/astro-records) demo.
330
+
331
+ For more information on using the View Transitions API, please refer to the [Smooth and simple transitions with the View Transitions API](https://developer.chrome.com/docs/web-platform/view-transitions/) guide from the Google Chrome team.
332
+
333
+ Please note, that because the `ViewTransition` API is a DOM API, we now export a specific `RouterProvider` from `react-router-dom` with this functionality. If you are importing `RouterProvider` from `react-router`, then it will not support view transitions. ([#10928](https://github.com/remix-run/react-router/pull/10928)
334
+
335
+ ### Patch Changes
336
+
337
+ - Log a warning and fail gracefully in `ScrollRestoration` when `sessionStorage` is unavailable ([#10848](https://github.com/remix-run/react-router/pull/10848))
338
+ - Updated dependencies:
339
+ - `@remix-run/router@1.10.0`
340
+ - `react-router@6.17.0`
341
+
342
+ ## 6.16.0
343
+
344
+ ### Minor Changes
345
+
346
+ - Updated dependencies:
347
+ - `@remix-run/router@1.9.0`
348
+ - `react-router@6.16.0`
349
+
350
+ ### Patch Changes
351
+
352
+ - Properly encode rendered URIs in server rendering to avoid hydration errors ([#10769](https://github.com/remix-run/react-router/pull/10769))
353
+
354
+ ## 6.15.0
355
+
356
+ ### Minor Changes
357
+
358
+ - Add's a new `redirectDocument()` function which allows users to specify that a redirect from a `loader`/`action` should trigger a document reload (via `window.location`) instead of attempting to navigate to the redirected location via React Router ([#10705](https://github.com/remix-run/react-router/pull/10705))
359
+
360
+ ### Patch Changes
361
+
362
+ - Fixes an edge-case affecting web extensions in Firefox that use `URLSearchParams` and the `useSearchParams` hook. ([#10620](https://github.com/remix-run/react-router/pull/10620))
363
+ - Do not include hash in `useFormAction()` for unspecified actions since it cannot be determined on the server and causes hydration issues ([#10758](https://github.com/remix-run/react-router/pull/10758))
364
+ - Reorder effects in `unstable_usePrompt` to avoid throwing an exception if the prompt is unblocked and a navigation is performed synchronously ([#10687](https://github.com/remix-run/react-router/pull/10687), [#10718](https://github.com/remix-run/react-router/pull/10718))
365
+ - Updated dependencies:
366
+ - `@remix-run/router@1.8.0`
367
+ - `react-router@6.15.0`
368
+
369
+ ## 6.14.2
370
+
371
+ ### Patch Changes
372
+
373
+ - Properly decode element id when emulating hash scrolling via `<ScrollRestoration>` ([#10682](https://github.com/remix-run/react-router/pull/10682))
374
+ - Add missing `<Form state>` prop to populate `history.state` on submission navigations ([#10630](https://github.com/remix-run/react-router/pull/10630))
375
+ - Support proper hydration of `Error` subclasses such as `ReferenceError`/`TypeError` ([#10633](https://github.com/remix-run/react-router/pull/10633))
376
+ - Updated dependencies:
377
+ - `@remix-run/router@1.7.2`
378
+ - `react-router@6.14.2`
379
+
380
+ ## 6.14.1
381
+
382
+ ### Patch Changes
383
+
384
+ - Updated dependencies:
385
+ - `react-router@6.14.1`
386
+ - `@remix-run/router@1.7.1`
387
+
388
+ ## 6.14.0
389
+
390
+ ### Minor Changes
391
+
392
+ - Add support for `application/json` and `text/plain` encodings for `useSubmit`/`fetcher.submit`. To reflect these additional types, `useNavigation`/`useFetcher` now also contain `navigation.json`/`navigation.text` and `fetcher.json`/`fetcher.text` which include the json/text submission if applicable ([#10413](https://github.com/remix-run/react-router/pull/10413))
393
+
394
+ ```jsx
395
+ // The default behavior will still serialize as FormData
396
+ function Component() {
397
+ let navigation = useNavigation();
398
+ let submit = useSubmit();
399
+ submit({ key: "value" }, { method: "post" });
400
+ // navigation.formEncType => "application/x-www-form-urlencoded"
401
+ // navigation.formData => FormData instance
402
+ }
403
+
404
+ async function action({ request }) {
405
+ // request.headers.get("Content-Type") => "application/x-www-form-urlencoded"
406
+ // await request.formData() => FormData instance
407
+ }
408
+ ```
409
+
410
+ ```js
411
+ // Opt-into JSON encoding with `encType: "application/json"`
412
+ function Component() {
413
+ let navigation = useNavigation();
414
+ let submit = useSubmit();
415
+ submit({ key: "value" }, { method: "post", encType: "application/json" });
416
+ // navigation.formEncType => "application/json"
417
+ // navigation.json => { key: "value" }
418
+ }
419
+
420
+ async function action({ request }) {
421
+ // request.headers.get("Content-Type") => "application/json"
422
+ // await request.json() => { key: "value" }
423
+ }
424
+ ```
425
+
426
+ ```js
427
+ // Opt-into text encoding with `encType: "text/plain"`
428
+ function Component() {
429
+ let navigation = useNavigation();
430
+ let submit = useSubmit();
431
+ submit("Text submission", { method: "post", encType: "text/plain" });
432
+ // navigation.formEncType => "text/plain"
433
+ // navigation.text => "Text submission"
434
+ }
435
+
436
+ async function action({ request }) {
437
+ // request.headers.get("Content-Type") => "text/plain"
438
+ // await request.text() => "Text submission"
439
+ }
440
+ ```
441
+
442
+ ### Patch Changes
443
+
444
+ - When submitting a form from a `submitter` element, prefer the built-in `new FormData(form, submitter)` instead of the previous manual approach in modern browsers (those that support the new `submitter` parameter) ([#9865](https://github.com/remix-run/react-router/pull/9865), [#10627](https://github.com/remix-run/react-router/pull/10627))
445
+ - For browsers that don't support it, we continue to just append the submit button's entry to the end, and we also add rudimentary support for `type="image"` buttons
446
+ - If developers want full spec-compliant support for legacy browsers, they can use the `formdata-submitter-polyfill`
447
+ - Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering ([#10448](https://github.com/remix-run/react-router/pull/10448))
448
+ - ⚠️ However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.)
449
+ - Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622))
450
+ - Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
451
+ - Updated dependencies:
452
+ - `react-router@6.14.0`
453
+ - `@remix-run/router@1.7.0`
454
+
455
+ ## 6.13.0
456
+
457
+ ### Minor Changes
458
+
459
+ - Move [`React.startTransition`](https://react.dev/reference/react/startTransition) usage behind a [future flag](https://reactrouter.com/en/main/guides/api-development-strategy) to avoid issues with existing incompatible `Suspense` usages. We recommend folks adopting this flag to be better compatible with React concurrent mode, but if you run into issues you can continue without the use of `startTransition` until v7. Issues usually boils down to creating net-new promises during the render cycle, so if you run into issues you should either lift your promise creation out of the render cycle or put it behind a `useMemo`. ([#10596](https://github.com/remix-run/react-router/pull/10596))
460
+
461
+ Existing behavior will no longer include `React.startTransition`:
462
+
463
+ ```jsx
464
+ <BrowserRouter>
465
+ <Routes>{/*...*/}</Routes>
466
+ </BrowserRouter>
467
+
468
+ <RouterProvider router={router} />
469
+ ```
470
+
471
+ If you wish to enable `React.startTransition`, pass the future flag to your component:
472
+
473
+ ```jsx
474
+ <BrowserRouter future={{ v7_startTransition: true }}>
475
+ <Routes>{/*...*/}</Routes>
476
+ </BrowserRouter>
477
+
478
+ <RouterProvider router={router} future={{ v7_startTransition: true }}/>
479
+ ```
480
+
481
+ ### Patch Changes
482
+
483
+ - Work around webpack/terser `React.startTransition` minification bug in production mode ([#10588](https://github.com/remix-run/react-router/pull/10588))
484
+ - Updated dependencies:
485
+ - `react-router@6.13.0`
486
+
487
+ ## 6.12.1
488
+
489
+ > \[!WARNING]
490
+ > Please use version `6.13.0` or later instead of `6.12.1`. This version suffers from a `webpack`/`terser` minification issue resulting in invalid minified code in your resulting production bundles which can cause issues in your application. See [#10579](https://github.com/remix-run/react-router/issues/10579) for more details.
491
+
492
+ ### Patch Changes
493
+
494
+ - Adjust feature detection of `React.startTransition` to fix webpack + react 17 compilation error ([#10569](https://github.com/remix-run/react-router/pull/10569))
495
+ - Updated dependencies:
496
+ - `react-router@6.12.1`
497
+
498
+ ## 6.12.0
499
+
500
+ ### Minor Changes
501
+
502
+ - Wrap internal router state updates with `React.startTransition` if it exists ([#10438](https://github.com/remix-run/react-router/pull/10438))
503
+
504
+ ### Patch Changes
505
+
506
+ - Re-throw `DOMException` (`DataCloneError`) when attempting to perform a `PUSH` navigation with non-serializable state. ([#10427](https://github.com/remix-run/react-router/pull/10427))
507
+ - Updated dependencies:
508
+ - `@remix-run/router@1.6.3`
509
+ - `react-router@6.12.0`
510
+
511
+ ## 6.11.2
512
+
513
+ ### Patch Changes
514
+
515
+ - Export `SetURLSearchParams` type ([#10444](https://github.com/remix-run/react-router/pull/10444))
516
+ - Updated dependencies:
517
+ - `react-router@6.11.2`
518
+ - `@remix-run/router@1.6.2`
519
+
520
+ ## 6.11.1
521
+
522
+ ### Patch Changes
523
+
524
+ - Updated dependencies:
525
+ - `react-router@6.11.1`
526
+ - `@remix-run/router@1.6.1`
527
+
528
+ ## 6.11.0
529
+
530
+ ### Minor Changes
531
+
532
+ - Enable `basename` support in `useFetcher` ([#10336](https://github.com/remix-run/react-router/pull/10336))
533
+ - If you were previously working around this issue by manually prepending the `basename` then you will need to remove the manually prepended `basename` from your `fetcher` calls (`fetcher.load('/basename/route') -> fetcher.load('/route')`)
534
+
535
+ ### Patch Changes
536
+
537
+ - Fix inadvertent re-renders when using `Component` instead of `element` on a route definition ([#10287](https://github.com/remix-run/react-router/pull/10287))
538
+ - Fail gracefully on `<Link to="//">` and other invalid URL values ([#10367](https://github.com/remix-run/react-router/pull/10367))
539
+ - Switched from `useSyncExternalStore` to `useState` for internal `@remix-run/router` router state syncing in `<RouterProvider>`. We found some [subtle bugs](https://codesandbox.io/s/use-sync-external-store-loop-9g7b81) where router state updates got propagated _before_ other normal `useState` updates, which could lead to footguns in `useEffect` calls. ([#10377](https://github.com/remix-run/react-router/pull/10377), [#10409](https://github.com/remix-run/react-router/pull/10409))
540
+ - Add static prop to `StaticRouterProvider`'s internal `Router` component ([#10401](https://github.com/remix-run/react-router/pull/10401))
541
+ - When using a `RouterProvider`, `useNavigate`/`useSubmit`/`fetcher.submit` are now stable across location changes, since we can handle relative routing via the `@remix-run/router` instance and get rid of our dependence on `useLocation()`. When using `BrowserRouter`, these hooks remain unstable across location changes because they still rely on `useLocation()`. ([#10336](https://github.com/remix-run/react-router/pull/10336))
542
+ - Updated dependencies:
543
+ - `react-router@6.11.0`
544
+ - `@remix-run/router@1.6.0`
545
+
546
+ ## 6.10.0
547
+
548
+ ### Minor Changes
549
+
550
+ - Added support for [**Future Flags**](https://reactrouter.com/en/main/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
551
+
552
+ - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
553
+ - `useNavigation().formMethod` is lowercase
554
+ - `useFetcher().formMethod` is lowercase
555
+ - When `future.v7_normalizeFormMethod === true`:
556
+ - `useNavigation().formMethod` is uppercase
557
+ - `useFetcher().formMethod` is uppercase
558
+
559
+ ### Patch Changes
560
+
561
+ - Fix `createStaticHandler` to also check for `ErrorBoundary` on routes in addition to `errorElement` ([#10190](https://github.com/remix-run/react-router/pull/10190))
562
+ - Updated dependencies:
563
+ - `@remix-run/router@1.5.0`
564
+ - `react-router@6.10.0`
565
+
566
+ ## 6.9.0
567
+
568
+ ### Minor Changes
569
+
570
+ - React Router now supports an alternative way to define your route `element` and `errorElement` fields as React Components instead of React Elements. You can instead pass a React Component to the new `Component` and `ErrorBoundary` fields if you choose. There is no functional difference between the two, so use whichever approach you prefer 😀. You shouldn't be defining both, but if you do `Component`/`ErrorBoundary` will "win". ([#10045](https://github.com/remix-run/react-router/pull/10045))
571
+
572
+ **Example JSON Syntax**
573
+
574
+ ```jsx
575
+ // Both of these work the same:
576
+ const elementRoutes = [{
577
+ path: '/',
578
+ element: <Home />,
579
+ errorElement: <HomeError />,
580
+ }]
581
+
582
+ const componentRoutes = [{
583
+ path: '/',
584
+ Component: Home,
585
+ ErrorBoundary: HomeError,
586
+ }]
587
+
588
+ function Home() { ... }
589
+ function HomeError() { ... }
590
+ ```
591
+
592
+ **Example JSX Syntax**
593
+
594
+ ```jsx
595
+ // Both of these work the same:
596
+ const elementRoutes = createRoutesFromElements(
597
+ <Route path='/' element={<Home />} errorElement={<HomeError /> } />
598
+ );
599
+
600
+ const componentRoutes = createRoutesFromElements(
601
+ <Route path='/' Component={Home} ErrorBoundary={HomeError} />
602
+ );
603
+
604
+ function Home() { ... }
605
+ function HomeError() { ... }
606
+ ```
607
+
608
+ - **Introducing Lazy Route Modules!** ([#10045](https://github.com/remix-run/react-router/pull/10045))
609
+
610
+ In order to keep your application bundles small and support code-splitting of your routes, we've introduced a new `lazy()` route property. This is an async function that resolves the non-route-matching portions of your route definition (`loader`, `action`, `element`/`Component`, `errorElement`/`ErrorBoundary`, `shouldRevalidate`, `handle`).
611
+
612
+ Lazy routes are resolved on initial load and during the `loading` or `submitting` phase of a navigation or fetcher call. You cannot lazily define route-matching properties (`path`, `index`, `children`) since we only execute your lazy route functions after we've matched known routes.
613
+
614
+ Your `lazy` functions will typically return the result of a dynamic import.
615
+
616
+ ```jsx
617
+ // In this example, we assume most folks land on the homepage so we include that
618
+ // in our critical-path bundle, but then we lazily load modules for /a and /b so
619
+ // they don't load until the user navigates to those routes
620
+ let routes = createRoutesFromElements(
621
+ <Route path="/" element={<Layout />}>
622
+ <Route index element={<Home />} />
623
+ <Route path="a" lazy={() => import("./a")} />
624
+ <Route path="b" lazy={() => import("./b")} />
625
+ </Route>
626
+ );
627
+ ```
628
+
629
+ Then in your lazy route modules, export the properties you want defined for the route:
630
+
631
+ ```jsx
632
+ export async function loader({ request }) {
633
+ let data = await fetchData(request);
634
+ return json(data);
635
+ }
636
+
637
+ // Export a `Component` directly instead of needing to create a React Element from it
638
+ export function Component() {
639
+ let data = useLoaderData();
640
+
641
+ return (
642
+ <>
643
+ <h1>You made it!</h1>
644
+ <p>{data}</p>
645
+ </>
646
+ );
647
+ }
648
+
649
+ // Export an `ErrorBoundary` directly instead of needing to create a React Element from it
650
+ export function ErrorBoundary() {
651
+ let error = useRouteError();
652
+ return isRouteErrorResponse(error) ? (
653
+ <h1>
654
+ {error.status} {error.statusText}
655
+ </h1>
656
+ ) : (
657
+ <h1>{error.message || error}</h1>
658
+ );
659
+ }
660
+ ```
661
+
662
+ An example of this in action can be found in the [`examples/lazy-loading-router-provider`](https://github.com/remix-run/react-router/tree/main/examples/lazy-loading-router-provider) directory of the repository.
663
+
664
+ 🙌 Huge thanks to @rossipedia for the [Initial Proposal](https://github.com/remix-run/react-router/discussions/9826) and [POC Implementation](https://github.com/remix-run/react-router/pull/9830).
665
+
666
+ - Updated dependencies:
667
+ - `react-router@6.9.0`
668
+ - `@remix-run/router@1.4.0`
669
+
670
+ ## 6.8.2
671
+
672
+ ### Patch Changes
673
+
674
+ - Treat same-origin absolute URLs in `<Link to>` as external if they are outside of the router `basename` ([#10135](https://github.com/remix-run/react-router/pull/10135))
675
+ - Fix `useBlocker` to return `IDLE_BLOCKER` during SSR ([#10046](https://github.com/remix-run/react-router/pull/10046))
676
+ - Fix SSR of absolute `<Link to>` urls ([#10112](https://github.com/remix-run/react-router/pull/10112))
677
+ - Properly escape HTML characters in `StaticRouterProvider` serialized hydration data ([#10068](https://github.com/remix-run/react-router/pull/10068))
678
+ - Updated dependencies:
679
+ - `@remix-run/router@1.3.3`
680
+ - `react-router@6.8.2`
681
+
682
+ ## 6.8.1
683
+
684
+ ### Patch Changes
685
+
686
+ - Improved absolute url detection in `Link` component (now also supports `mailto:` urls) ([#9994](https://github.com/remix-run/react-router/pull/9994))
687
+ - Fix partial object (search or hash only) pathnames losing current path value ([#10029](https://github.com/remix-run/react-router/pull/10029))
688
+ - Updated dependencies:
689
+ - `react-router@6.8.1`
690
+ - `@remix-run/router@1.3.2`
691
+
692
+ ## 6.8.0
693
+
694
+ ### Minor Changes
695
+
696
+ - Support absolute URLs in `<Link to>`. If the URL is for the current origin, it will still do a client-side navigation. If the URL is for a different origin then it will do a fresh document request for the new origin. ([#9900](https://github.com/remix-run/react-router/pull/9900))
697
+
698
+ ```tsx
699
+ <Link to="https://neworigin.com/some/path"> {/* Document request */}
700
+ <Link to="//neworigin.com/some/path"> {/* Document request */}
701
+ <Link to="https://www.currentorigin.com/path"> {/* Client-side navigation */}
702
+ ```
703
+
704
+ ### Patch Changes
705
+
706
+ - Fix bug with search params removal via `useSearchParams` ([#9969](https://github.com/remix-run/react-router/pull/9969))
707
+ - Respect `preventScrollReset` on `<fetcher.Form>` ([#9963](https://github.com/remix-run/react-router/pull/9963))
708
+ - Fix navigation for hash routers on manual URL changes ([#9980](https://github.com/remix-run/react-router/pull/9980))
709
+ - Use `pagehide` instead of `beforeunload` for `<ScrollRestoration>`. This has better cross-browser support, specifically on Mobile Safari. ([#9945](https://github.com/remix-run/react-router/pull/9945))
710
+ - Updated dependencies:
711
+ - `@remix-run/router@1.3.1`
712
+ - `react-router@6.8.0`
713
+
714
+ ## 6.7.0
715
+
716
+ ### Minor Changes
717
+
718
+ - Add `unstable_useBlocker` hook for blocking navigations within the app's location origin ([#9709](https://github.com/remix-run/react-router/pull/9709))
719
+ - Add `unstable_usePrompt` hook for blocking navigations within the app's location origin ([#9932](https://github.com/remix-run/react-router/pull/9932))
720
+ - Add `preventScrollReset` prop to `<Form>` ([#9886](https://github.com/remix-run/react-router/pull/9886))
721
+
722
+ ### Patch Changes
723
+
724
+ - Added pass-through event listener options argument to `useBeforeUnload` ([#9709](https://github.com/remix-run/react-router/pull/9709))
725
+ - Streamline jsdom bug workaround in tests ([#9824](https://github.com/remix-run/react-router/pull/9824))
726
+ - Updated dependencies:
727
+ - `@remix-run/router@1.3.0`
728
+ - `react-router@6.7.0`
729
+
730
+ ## 6.6.2
731
+
732
+ ### Patch Changes
733
+
734
+ - Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
735
+ - Updated dependencies:
736
+ - `react-router@6.6.2`
737
+
738
+ ## 6.6.1
739
+
740
+ ### Patch Changes
741
+
742
+ - Updated dependencies:
743
+ - `@remix-run/router@1.2.1`
744
+ - `react-router@6.6.1`
745
+
746
+ ## 6.6.0
747
+
748
+ ### Minor Changes
749
+
750
+ - Add `useBeforeUnload()` hook ([#9664](https://github.com/remix-run/react-router/pull/9664))
751
+ - Remove `unstable_` prefix from `createStaticHandler`/`createStaticRouter`/`StaticRouterProvider` ([#9738](https://github.com/remix-run/react-router/pull/9738))
752
+
753
+ ### Patch Changes
754
+
755
+ - Proper hydration of `Error` objects from `StaticRouterProvider` ([#9664](https://github.com/remix-run/react-router/pull/9664))
756
+ - Support uppercase `<Form method>` and `useSubmit` method values ([#9664](https://github.com/remix-run/react-router/pull/9664))
757
+ - Skip initial scroll restoration for SSR apps with `hydrationData` ([#9664](https://github.com/remix-run/react-router/pull/9664))
758
+ - Fix `<button formmethod>` form submission overriddes ([#9664](https://github.com/remix-run/react-router/pull/9664))
759
+ - Updated dependencies:
760
+ - `@remix-run/router@1.2.0`
761
+ - `react-router@6.6.0`
762
+
763
+ ## 6.5.0
764
+
765
+ ### Patch Changes
766
+
767
+ - Updated dependencies:
768
+ - `react-router@6.5.0`
769
+ - `@remix-run/router@1.1.0`
770
+
771
+ ## 6.4.5
772
+
773
+ ### Patch Changes
774
+
775
+ - Updated dependencies:
776
+ - `@remix-run/router@1.0.5`
777
+ - `react-router@6.4.5`
778
+
779
+ ## 6.4.4
780
+
781
+ ### Patch Changes
782
+
783
+ - Fix issues with encoded characters in `NavLink` and descendant `<Routes>` ([#9589](https://github.com/remix-run/react-router/pull/9589), [#9647](https://github.com/remix-run/react-router/pull/9647))
784
+ - Properly serialize/deserialize `ErrorResponse` instances when using built-in hydration ([#9593](https://github.com/remix-run/react-router/pull/9593))
785
+ - Support `basename` in static data routers ([#9591](https://github.com/remix-run/react-router/pull/9591))
786
+ - Updated dependencies:
787
+ - `@remix-run/router@1.0.4`
788
+ - `react-router@6.4.4`
789
+
790
+ ## 6.4.3
791
+
792
+ ### Patch Changes
793
+
794
+ - Fix hrefs generated for `createHashRouter` ([#9409](https://github.com/remix-run/react-router/pull/9409))
795
+ - fix encoding/matching issues with special chars ([#9477](https://github.com/remix-run/react-router/pull/9477), [#9496](https://github.com/remix-run/react-router/pull/9496))
796
+ - Properly support `index` routes with a `path` in `useResolvedPath` ([#9486](https://github.com/remix-run/react-router/pull/9486))
797
+ - Respect `relative=path` prop on `NavLink` ([#9453](https://github.com/remix-run/react-router/pull/9453))
798
+ - Fix `NavLink` behavior for root urls ([#9497](https://github.com/remix-run/react-router/pull/9497))
799
+ - Updated dependencies:
800
+ - `@remix-run/router@1.0.3`
801
+ - `react-router@6.4.3`
802
+
803
+ ## 6.4.2
804
+
805
+ ### Patch Changes
806
+
807
+ - Respect `basename` in `useFormAction` ([#9352](https://github.com/remix-run/react-router/pull/9352))
808
+ - Enhance console error messages for invalid usage of data router hooks ([#9311](https://github.com/remix-run/react-router/pull/9311))
809
+ - If an index route has children, it will result in a runtime error. We have strengthened our `RouteObject`/`RouteProps` types to surface the error in TypeScript. ([#9366](https://github.com/remix-run/react-router/pull/9366))
810
+ - Updated dependencies:
811
+ - `react-router@6.4.2`
812
+ - `@remix-run/router@1.0.2`
813
+
814
+ ## 6.4.1
815
+
816
+ ### Patch Changes
817
+
818
+ - Updated dependencies:
819
+ - `react-router@6.4.1`
820
+ - `@remix-run/router@1.0.1`
821
+
822
+ ## 6.4.0
823
+
824
+ Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the [docs](https://reactrouter.com), especially the [feature overview](https://reactrouter.com/start/overview) and the [tutorial](https://reactrouter.com/start/tutorial).
825
+
826
+ **New APIs**
827
+
828
+ - Create your router with `createMemoryRouter`/`createBrowserRouter`/`createHashRouter`
829
+ - Render your router with `<RouterProvider>`
830
+ - Load data with a Route `loader` and mutate with a Route `action`
831
+ - Handle errors with Route `errorElement`
832
+ - Submit data with the new `<Form>` component
833
+ - Perform in-page data loads and mutations with `useFetcher()`
834
+ - Defer non-critical data with `defer` and `Await`
835
+ - Manage scroll position with `<ScrollRestoration>`
836
+
837
+ **New Features**
838
+
839
+ - Perform path-relative navigations with `<Link relative="path">` (#9160)
840
+
841
+ **Bug Fixes**
842
+
843
+ - Path resolution is now trailing slash agnostic (#8861)
844
+ - `useLocation` returns the scoped location inside a `<Routes location>` component (#9094)
845
+ - respect the `<Link replace>` prop if it is defined (#8779)
846
+
847
+ **Updated Dependencies**
848
+
849
+ - `react-router@6.4.0`