Replies: 1 comment
-
Our decision was that we don't solve dual module hazard on the library end. So, basically, you have to make sure to use CJS only in your project. import { createStore, Provider } from 'jotai';
const store = createStore();
// in root component
<Provider store={store}> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
On the server, jotai is being loaded in different formats:
In workspaces/, jotai is resolved as CJS
In workspaces/shared, jotai is resolved as ESM
This inconsistency causes separate store instances to be created on the server, so when the app hydrates, changes are not reflected in shared
Environment
Next.js: v12
Node.js: v18
Project Module Format: CommonJS (CJS)
How can I ensure that libraries like jotai are loaded consistently as either ESM or CJS in the server environment to maintain a single store instance...??!
Beta Was this translation helpful? Give feedback.
All reactions