Skip to content

Commit 9db9dfd

Browse files
lcmohsenclaude
andcommitted
docs: address review on React Router v8 support
- Changeset no longer claims a peer dependency alone guarantees a single runtime router instance; it points at the Vite dedupe/noExternal setup. - Document that React Router v8 requires Node 22.22+ in the consuming app. - Vite examples: `dedupe` belongs under `resolve`, not `optimizeDeps`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 43887ce commit 9db9dfd

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎.changeset/react-router-v8-support.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@lambdacurry/forms": minor
33
---
44

5-
Support React Router v8. `react-router` is now a peer dependency (`^7.0.0 || ^8.0.0`) instead of a bundled dependency, so consumers always share a single router instance with the library, and the unused `react-router-dom` dependency/peer was dropped (that package no longer exists in React Router v8).
5+
Support React Router v8. `react-router` is now a peer dependency (`^7.0.0 || ^8.0.0`) instead of a bundled dependency, so the library resolves the router your application installs (keep the Vite `resolve.dedupe` / `ssr.noExternal` setup from the consumer guide so only one runtime instance is bundled), and the unused `react-router-dom` dependency/peer was dropped (that package no longer exists in React Router v8). React Router v8 requires Node 22.22 or newer.

‎README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const MyTable = () => {
6868

6969
## React Router v7 / v8 Integration
7070

71-
`react-router` (v7 or v8) and `remix-hook-form` are peer dependencies: install them in your application so every package shares the single router instance your app provides.
71+
`react-router` (v7 or v8) and `remix-hook-form` are peer dependencies: install them in your application so the library resolves the router your app provides. React Router v8 itself requires Node 22.22 or newer in the consuming application.
7272

7373
When using `@lambdacurry/forms` with `remix-hook-form` in a React Router v7 or v8 application, you need to configure Vite to bundle these packages together to share the router context. Without this, you may encounter the error:
7474

@@ -84,9 +84,11 @@ export default defineConfig({
8484
ssr: {
8585
noExternal: ['react-hook-form', 'remix-hook-form', '@lambdacurry/forms']
8686
},
87-
optimizeDeps: {
88-
include: ['react', 'react-dom', 'react-router', 'react-hook-form', 'remix-hook-form'],
87+
resolve: {
8988
dedupe: ['react', 'react-dom', 'react-router', 'react-hook-form', 'remix-hook-form']
89+
},
90+
optimizeDeps: {
91+
include: ['react', 'react-dom', 'react-router', 'react-hook-form', 'remix-hook-form']
9092
}
9193
});
9294
```

‎docs/consumer-setup-guide.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This guide covers how to integrate `@lambdacurry/forms` with React Router v7 or v8 applications using remix-hook-form.
44

5-
`react-router` (`^7 || ^8`) and `remix-hook-form` are peer dependencies of `@lambdacurry/forms`; install them in your application. The package no longer references `react-router-dom`, which was removed in React Router v8.
5+
`react-router` (`^7 || ^8`) and `remix-hook-form` are peer dependencies of `@lambdacurry/forms`; install them in your application. The package no longer references `react-router-dom`, which was removed in React Router v8. React Router v8 requires Node 22.22 or newer.
66

77
## React Router Vite Configuration
88

@@ -34,11 +34,13 @@ export default defineConfig({
3434
// CRITICAL: Bundle these packages with the app to share react-router context
3535
noExternal: ['react-hook-form', 'remix-hook-form', '@lambdacurry/forms']
3636
},
37-
optimizeDeps: {
38-
// Pre-bundle dependencies to avoid runtime context issues
39-
include: ['react', 'react-dom', 'react-router', 'react-hook-form', 'remix-hook-form'],
37+
resolve: {
4038
// Ensure single instances of these packages
4139
dedupe: ['react', 'react-dom', 'react-router', 'react-hook-form', 'remix-hook-form']
40+
},
41+
optimizeDeps: {
42+
// Pre-bundle dependencies to avoid runtime context issues
43+
include: ['react', 'react-dom', 'react-router', 'react-hook-form', 'remix-hook-form']
4244
}
4345
});
4446
```
@@ -49,7 +51,7 @@ export default defineConfig({
4951
|---------|---------|
5052
| `ssr.noExternal` | Forces Vite to bundle `remix-hook-form`, `react-hook-form`, and `@lambdacurry/forms` with the application instead of treating them as external dependencies. This ensures they share the same `react-router` instance. |
5153
| `optimizeDeps.include` | Pre-bundles these packages during dev, avoiding lazy loading that can cause context issues. |
52-
| `optimizeDeps.dedupe` | Ensures only one copy of each package exists, preventing multiple React or react-router instances. |
54+
| `resolve.dedupe` | Ensures only one copy of each package exists, preventing multiple React or react-router instances. |
5355

5456
## Recommended Form Pattern
5557

0 commit comments

Comments
 (0)