Closed yuya-tani closed 6 months ago
I found the following answer from the swr issue. https://github.com/vercel/swr/issues/2125#issuecomment-1504812584
We have confirmed that there are no errors using this setting method. I should have looked at the swr issue first instead of swr-site. sorry.
I would be happy if the above example was also included in the sample site. Best regard.
Hey. I would like to use "persistent cache using LocalStorage" in the URL below with Next.js v14 SSG. https://swr.vercel.app/ja/docs/advanced/cache#localstorage-based-persistent-cache
I created "SWRConfig" as a client component as shown below, but even if I use use client, I get an error "localStorage is not defined" when I build it. https://swr.vercel.app/ja/docs/with-nextjs#client-components
Trying to get around it, use "typeof window !== 'undefined'" If you do it while there is a window object (client), as in "Hydration failed because the initial UI does not match what was rendered on the server." I got a hydration error.
Is there a way to avoid both?
localStorage is not defined ERROR
Hydration ERROR