Error using atomWithStorage with getOnInit in Next.js: "localStorage is not defined" #2691
Answered
by
dai-shi
beingtyson
asked this question in
General
-
I am trying to use atomWithStorage in Jotai with getOnInit set to true in a Next.js environment, but I encounter an error: "ReferenceError: localStorage is not defined" Due to this error, my client application resets to the initial value every time I refresh the page, even though I change the state. |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Aug 2, 2024
Replies: 1 comment 3 replies
-
Don't use |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
beingtyson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't use
getOnInit
with SSR framework, such as Next.js. It's for pure client apps.