Replies: 2 comments
-
Actually, I would like to push this idea #2740. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Very useful |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey zustand team!
I've been recently attempted to use Zustand in a Next.js project, and was annoyed with the amount of boilerplate code I had to copy / implement using the tutorial at https://zustand.docs.pmnd.rs/guides/nextjs#app-router.
Doing that, I've created a common utility for creating a Zustand store prepared for Next.js project, and thought it could be added to the project similar to the
zustand/react
integration, as likezustand/nextjs
.I would appreciate your feedback and ideas about this, as well as some help potentially contributing it into zustand 😁
What does it look like
The utility looks like this (copy-paste this as
zustand-nextjs.tsx
to your project)Then you can simply create your store like this
Install the provider in the
layout.tsx
or where ever your want:Then use it inside your client components
The full example is available at https://github.com/danyi1212/zustand-next
Beta Was this translation helpful? Give feedback.
All reactions