Deployment fails with `ReferenceError: localStorage is not defined`
Unanswered
Bonga shad posted this in #help-forum
Bonga shadOP
Maybe a bug but I'm not sure!
I'm using the local storage in a hook defined in a "use client" module. And the only component that consumes it, it's also a client component.
I tried to add guards like
next dev works correctly but next build fails and thus the deployment.I'm using the local storage in a hook defined in a "use client" module. And the only component that consumes it, it's also a client component.
I tried to add guards like
typeof window !== 'undefined' ? localStorage?.getItem('someKey') : null to no avail