Open 0x3dev opened 3 weeks ago
I have run into the same issue after attempting to implement the SSR guide on the wagmi docs. I came looking for this after noticing a recurring issue whereby the current wallet seems to persist after calling disconnect()
with the UI or wagmi
, leading to a Metamask error when you try to connect the same or another wallet again. Only when the page is fully refreshed can you connect again. I assumed this issue lies in some incomplete configuration for Next.js, which is why i have added this here to the SSR implementation issues.
This is currently observable in your docs too here. You can follow these steps to reproduce: (1) Connect with MM (2) Disconnect (without page refresh) (3) Connect again with MM (4) MM error (5) Refresh page and connect with MM succeeds.
See demo below:
https://github.com/family/connectkit/assets/16241905/b6114847-e401-47c6-9f12-d3ad66b8c1b1
Describe the bug
When trying to implement the steps outlined in Wagmi SSR page, specifically Persistence using Cookies, NextJS throws this error:
Error: (0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext) is not a function
eval node_modules/.pnpm/framer-motion@6.5.1_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/framer-motion/dist/es/context/LazyContext.mjs (3:32) (rsc)/./node_modules/.pnpm/framer-motion@6.5.1_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/framer-motion/dist/es/context/LazyContext.mjs
To reproduce
Create a new project with
npm create wagmi --template next
and addconnectkit
to it. The error will show at first run.Additional context
If we don't pass the initialState like this,
const initialState = cookieToInitialState( getConfig(), headers().get("cookie") );
The error is gone, so it seems the method
getDefaultConfig
from connectkit doesn't support SSR.