wevm / wagmi

React Hooks for Ethereum
https://wagmi.sh
MIT License
5.79k stars 968 forks source link

wallet get disconnected of page refreshes and cookies was not deleted this will happening when we dissconnect on the dynamic page #4073

Closed arunkumar201 closed 2 weeks ago

arunkumar201 commented 2 weeks ago

Check existing issues

Describe the bug

i am using wagmi and web3Modal (nextjs 14) , i am getting issue with wallet connection -The wallet connection occasionally disconnects upon page changes or occasional page refreshes. I've implemented cookies with SSR (server-side rendering) set to true.

i am using latest versions -i followed the https://github.com/wevm/wagmi/blob/main/playgrounds/next/src/wagmi.ts playground example

Link to Minimal Reproducible Example

https://github.com/arunkumar201/web3-siwe

Steps To Reproduce

https://github.com/wevm/wagmi/assets/70876302/aab68712-47a9-4a82-920f-b28a0cd86788

What Wagmi package(s) are you using?

wagmi, @wagmi/connectors, @wagmi/core

Wagmi Version

latest

Viem Version

latest

TypeScript Version

5.4.4

Anything else?

i am using nextjs + cookies based wallet session.

tmm commented 2 weeks ago

The example you provided is not minimal. Please attach a minimal reproduction that only uses Wagmi/Viem without third-party connect libraries.

arunkumar201 commented 2 weeks ago

@tmm ,i have tested using wagmi next playground example , same issue is being encountered .

tmm commented 1 week ago

Updated the SSR guide: https://wagmi.sh/react/guides/ssr#persistence-using-cookies

arunkumar201 commented 1 week ago

thanks @tmm, same issue still persists: When connecting on the home page and then navigating to any dynamic page, a hard refresh on the dynamic page causes problems. If we disconnect the wallet, return to the home page, reconnect the wallet, and refresh the page, the wallet disconnects again. The 'wagmi.io.metamask.disconnected' cookie value remains true and does not get updated. This issue was tested on the latest Next.js playground example using the updated version of getConfig() .

kr-arunp commented 3 days ago

Updated the SSR guide: https://wagmi.sh/react/guides/ssr#persistence-using-cookies

still wallet is getting disconnected - https://github.com/wevm/wagmi/issues/4073#issuecomment-2187856149