Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Next.js @ jotai 1.5.1] atomWithStorage : localStorage is not defined #949

Closed
comingAlive opened this issue Jan 11, 2022 · 4 comments · Fixed by #951
Closed

[Next.js @ jotai 1.5.1] atomWithStorage : localStorage is not defined #949

comingAlive opened this issue Jan 11, 2022 · 4 comments · Fixed by #951

Comments

@comingAlive
Copy link

import { useAtom } from "jotai";
import { atomWithStorage } from "jotai/utils";

const counterAtom = atomWithStorage("counter", 0);

export default function HomePage() {
  const [c] = useAtom(counterAtom);
  return <div>{c}</div>;
}

<=1.5.0 working as expected.

@comingAlive comingAlive changed the title [Next.js @ jotai 1.5.1] atomWithStorage throws: localStorage is not defined [Next.js @ jotai 1.5.1] atomWithStorage : localStorage is not defined Jan 11, 2022
@dai-shi
Copy link
Member

dai-shi commented Jan 11, 2022

Oops! Will make a fix soon. Thanks for reporting.

@dai-shi
Copy link
Member

dai-shi commented Jan 11, 2022

Can you try #951 to see if it really fixes the issue?
https://ci.codesandbox.io/status/pmndrs/jotai/pr/951
☝️ See "Local Install Instructions"

@comingAlive
Copy link
Author

It does. Amazing library btw :) Thank you for your work.

@dai-shi
Copy link
Member

dai-shi commented Jan 12, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants