Next.js Discord

Discord Forum

Passing states from Navbar to {children} nested children

Answered
Southeastern blueberry bee posted this in #help-forum
Open in Discord
Southeastern blueberry beeOP
Hey, anyone can help me with passing state "globally" in React Next? I am trying to create a shop for portfolio and I got stuck there. My main idea was to have one navbar component that holds my cart and its items and it works, but I struggle on how to pass this state to rest of page (first screenshot). I have layout set up like this (screenshot 2). But I don't know how to pass from nav to children and to components on site: (screenshot 3)
Answered by @ts-ignore
use either context api or any state management library like zustand
View full answer

4 Replies

Answer
Southeastern blueberry beeOP
Thank you @@ts-ignore , I tried to use Zustand few projects ago wihtout Next and thought there is some "smarter" way with Next 13 but I will try Zustand - have a great day.
Southeastern blueberry beeOP
Thanks 🙂
@@ts-ignore