wevm / wagmi

Reactive primitives for Ethereum apps
https://wagmi.sh
MIT License
5.91k stars 1.02k forks source link

issue with implementing persistence using cookies using nextjs@^14.0.4, wagmi@^2.5.5, viem@2.7.3 #3658

Closed brunolune closed 6 months ago

brunolune commented 7 months ago

What is the type of issue?

Example code is not working

What is the issue?

In terminal:

⨯ Error: Cannot access storage.key on the server. You cannot dot into a client module from a server component. You can only pass the imported name through. at RootLayout (./src/app/layout.tsx:36:85) at stringify () at AsyncLocalStorage.run (node:async_hooks:346:14)

In Console:

Unhandled Runtime Error Error: Cannot access storage.key on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.

Source src/app/layout.tsx (26:44) @ config

24 | children: React.ReactNode; 25 | }) {

26 | const initialState = cookieToInitialState(config, headers().get("cookie")); | ^ 27 | 28 | return ( 29 | Show collapsed frames

Where did you find it?

https://wagmi.sh/react/guides/ssr

Yuripetusko commented 6 months ago

Hm I just tried running this code: https://github.com/wevm/wagmi/tree/main/playgrounds/next

And it worked fine. It uses cookieStorage just like in docs. The only difference is nextjs version, but I tried updating to next 14 and it still worked without the error 🤔 Am I missing something?

github-actions[bot] commented 6 months ago

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion.