Next.js Discord

Discord Forum

Next js state management

Unanswered
Giant Chinchilla posted this in #help-forum
Open in Discord
Avatar
Giant ChinchillaOP
Redux or zustand example or any other way people which have big projects how they handle state management ?
Only think i not like no one telling about this think properly?
If we use in client side component how we can in next js?

21 Replies

Avatar
Giant ChinchillaOP
Any help?
Avatar
Pls don’t repost the question, I’ll delete the repost
Avatar
Well.... you are free to use redux or zustand.... I typically stay away from them though. What state do you need shared across the project that you cant just use local storage for?
A quick google search gave tons of results on how to set zustand up with nextjs though... https://zustand.docs.pmnd.rs/guides/nextjs
Oh sorry, I see this is the repost, ignore me looks like your questions was answered in the other thread
Avatar
Giant ChinchillaOP
i know how to use zustand i want to know. When we have big projects how we able to handle state management because so many people say not use any state management
Avatar
You stated the answer... zustand.
I dont use it.
I just stick to using local storage when I need to save state across everything.
Thats why its there.
I prefer local storage instead of using the 'closure' that zust uses.
zustand has an option to use local storage as well.
Avatar
Giant ChinchillaOP
Thanks for sharing your approach! Using local storage for persisting state across sessions makes sense. I was more curious about managing transient UI state and global states as projects scale. Do you find using local storage manageable in such cases, or do you combine it with something else for dynamic state needs? Also, have you noticed any performance issues with local storage in larger apps, especially when reading/writing frequently or handling bigger datasets?
Avatar
local storage can impact perfomance yes
its not always directly available on the client so u always have to account for that
most of the times u are better of just saving important things in a server side cookie with in a jwt format
local storage can be used for things that are not important and can be offloaded passively in the background
Example -> Some settings for client only components that display different type of data depending on the state
since they need to be rendered first u can sneak in the local storage part without users noticing a loadingtime
Avatar
Giant ChinchillaOP
Okay thanks, I’ll give that a try!
One other thing—how do you handle prop drilling? I know we can use useContext, but it tends to have performance issues, especially in larger apps. Do you have a preferred way to avoid prop drilling without impacting performance?
Avatar
Create a provider context if prop drilling gets to be too much.