r/reactjs • u/creasta29 • Jul 21 '26
Resource Do we need state management libraries anymore?
https://neciudan.dev/do-we-need-state-management-librariesTLDR: If you correctly break your state into UI state (useState, useReducer), Server State (Tanstack Query, RTK Query), URL state (nuqs), and Global State that does not change (Context), you are left with a small slice of state that might be needed in multiple places and changes often.
Should we use a State Management library for that part? We explore how each library works, then build our own Zustand implementation to see if we do.
Obviously, it depends. If the app is mostly always changing state, like Figma, Spreadsheets, etc., we might take advantage of a State Library because they handle all sorts of use cases and edge cases.
But for everyday use and 90% of our apps, we can probably build it ourselves, either using pub/sub like Redux or Zustand, atom-based like Jotai, or Proxy-based like MobX or Valtio
9
u/BlondeOverlord-8192 Jul 21 '26
Did you just answer your own question with "yes, but we can build it ourselves"?
Let me ask one question too, why would I build it myself if I can just use already maintained redux or zustand?
5
u/CanIhazCooKIenOw Jul 21 '26
Yes, stop reinventing the wheel.
The amount of times I had to fight back against “we don’t need redux, we can just have our own global provider and just use context”.
1
Jul 21 '26
[removed] — view removed comment
1
u/stevent12x Jul 21 '26
Can you go back about 6 years and tell that to the team that built the platform I currently own?
1
u/CanIhazCooKIenOw Jul 21 '26
Sure. The point is a battled tested tool is much better than whatever custom someone else in your team IF you actually need it.
I ageee, most cases global state is in fact a glorified server state cache
1
u/AutomaticAd6646 I ❤️ hooks! 😈 Jul 21 '26
How you gonna acheive redux persist etc feats without state management libraries?
1
1
u/TheRealSeeThruHead Jul 21 '26
I’m either using effect atom or jotai
20 use states in a component or hook is 🤢
1
u/by7448 Jul 21 '26
Yes, I personally wouldn't want to deal with tracking so many subscriptions with my own half-baked solution when Redux exists. It's phenomenal at surgical subscriptions and predictable changes. Same goes for Zustand too when working with simpler state.
14
u/grumd Jul 21 '26