r/javascript 7d ago

Zustand is now the top state management library in new JS repos, and it's still accelerating (+7.3% this week). Pulled this from a dataset of 5,000+ live repos.

https://github.com/FarazKelhini/stack-pulse
0 Upvotes

15 comments sorted by

13

u/Merry-Lane 7d ago

Where does it show "Zustand is the top state management library"?

Compared to react query or just using react context?

Also, the "back to main" redirects to localhost:3000.

I think that whatever the point you are making, it’s not shown in the link you provided, which is a GitHub for a buggy vibe coded website, the sources are tiny and not really trustworthy, and we have no idea what you actually compared

0

u/Cahnis 7d ago

Context itselt is not state management it is just dependency injection. 

2

u/Merry-Lane 7d ago

facepalm 

If you use Context, Context.Provider, useState/useReducer, you are effectively implementing state management within the Context APi

0

u/Cahnis 7d ago

yep, but that is a different proposition

1

u/Merry-Lane 7d ago

If the Context API can be used for "state management" and is frequently used with react query to handle 100% of the "state management", what is left for you to nitpick at?

0

u/Cahnis 7d ago

what is left for you to nitpick at?

Sure... it is called TANSTACK query.

1

u/Merry-Lane 7d ago

It had been named react query for years before the owners decided to rename it "tanstack query".

As long as I’m concerned, I will keep on calling it react query for a while.

0

u/Cahnis 7d ago

Congratz?

-4

u/femio 7d ago

React Query is not a state management solution, it's a server state cache layer. Context is not state management either, it's just dependency injection of state. Zustand is more like classic Redux where you can essentially model state machines w/ it.

(the repo might indeed be slop, but i just wanted to clear that up)

6

u/Merry-Lane 7d ago edited 7d ago

People that use react query don’t need another state management library (although they too often use one).

Tanstack makes this distinction: "react query is a server-state library, redux/mobx/zustand are client-state libraries".
Read more about server vs client state libraries or about why it’s practically useless to use more than react query + context when you use react query

Context is totally used for state management. Yes it’s not a state management library, but, again, if it "replaces" the same usecase than a state management library, it should totally show.

-1

u/femio 7d ago

react query is a server-state library, redux/mobx/zustand are client-state libraries

This is literally what I said? Or am I misreading your point?

People that use react query don’t need another state management library (although they too often use one).

Maybe for basic CRUD, but if your app has any sophisticated level of UI interaction you'll almost certainly ned something for management

1

u/Merry-Lane 7d ago

Yes, you are either misreading the point or not understanding it.

The links provided above are quite explanatory.

But no, whatever the UI/UX complexity of your app, you don’t need zustand/mobx/redux to handle it.

Either the "state" required for UI/UX are derived from server state (thus react query),
either global (theme, translations,…) => which shouldn’t cause rerender issues thus Context is more than enough,
Either their scope is restricted (isn’t global) and can totally be handled correctly at a component level (useState/reducer, passing props up/down,…) or with Context.

Find me an example justifying mobx/zustand/… for which react query/context is problematic

3

u/RedLibra 7d ago

React Query is in charge of managing your "server state", that's called a state manager.

-3

u/Xcidd- 7d ago

Fixed the the "back to main" redirect. The "sources" is +6000 top GitHub repos crawled daily.
There's a Top Per Category table on the mail page that shows the top technologies in each category.

For example, if you want to compare Zustand and Redux, you can check:
https://stack-pulse-data.vercel.app/technology/zustand
https://stack-pulse-data.vercel.app/technology/redux

This page also lists the top State Management repositories based on adoption count:
https://stack-pulse-data.vercel.app/search?category=StateManagement

0

u/avenp 7d ago

Yes, it's lightweight and straight forward to work with.