Replies: 2 comments 8 replies
-
zustand/src/middleware/persist.ts Line 230 in 43791eb That message is shown if you don't have the |
Beta Was this translation helpful? Give feedback.
-
You can lazy load the component using next/dynamic. Client components are also rendered on the server, but hydrated on the client unlike server components, which causes the error when trying to access web storage on the server. Using lazy loading on the component will solve the problem, avoid extra renders and allow you to pass a fallback. Make sure to pass import dynamic from 'next/dynamic'
const DynamicStoreConsumer = dynamic(() => import('../components/my-component'), {
ssr: false,
}) |
Beta Was this translation helpful? Give feedback.
-
I am getting a warning message logged to the Terminal of my Next.js 13 application when using Zustand with the persist middleware
I understand that the storage is not available on the server, and I am not trying to use it on the server - at least as far as I am aware. All pages where I use the storage have the
"use client"
directive at the top. So I don't understand why I receive this warning? Or what it is that is triggering it?Is Next.js trying to use Zustand on the server as part of its internal workings / SSR / hydration / magic? If so, should Next.js and/or Zustand make a change to ensure this isn't happening? As far as I understand it, using persist should not be possible on the server, so whatever triggers this warning should not be happening in the first place?
Either way, how can I stop this warning from appearing in my Terminal, please?
For context, please see the following issue, which I believe is where the warning message originated: #283. It is closed though, so I am not sure if I will receive a reply there.
Beta Was this translation helpful? Give feedback.
All reactions