I’m trying to set up a global state with Zustand in Nextjs.(Followed the instructions in the docs)
I need to have a list of advertisements stored throughout the application, so global state to seems ok in this case.
I want to display this advertisements in multiple places in a page. (sidebar, posts, feed, etc.).
I had an idea to store a nextAdvertisement number in the store as well to keep track which advertisement I should display next, but for some reason this index increments not how I assume it should.
Another thing is I need to fetch the init data from DB I did this in layout and passed to Provider..
This is the demo repo: https://github.com/DZsolt01/nextjs-zustand-demo
If anyone has an idea what I did wrong please let me know!
Store the data in the whole application, the initial data need to be fetched
Adek01 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.