Gathering detailed insights and metrics for @udecode/zustood
Gathering detailed insights and metrics for @udecode/zustood
Gathering detailed insights and metrics for @udecode/zustood
Gathering detailed insights and metrics for @udecode/zustood
Zustand store factory for a best-in-class developer experience.
npm install @udecode/zustood
Typescript
Module System
Node Version
NPM Version
95.4
Supply Chain
99.6
Quality
79.6
Maintenance
100
Vulnerability
100
License
zustand-x@6.1.1
Updated on Jun 17, 2025
zustand-x@6.1.0
Updated on Feb 15, 2025
zustand-x@6.0.3
Updated on Feb 05, 2025
zustand-x@6.0.2
Updated on Feb 05, 2025
zustand-x@6.0.1
Updated on Feb 05, 2025
zustand-x@6.0.0
Updated on Feb 04, 2025
TypeScript (75.13%)
JavaScript (24.87%)
Total Downloads
9,581,787
Last Day
1,606
Last Week
35,281
Last Month
147,683
Last Year
2,593,584
MIT License
420 Stars
247 Commits
28 Forks
10 Watchers
2 Branches
9 Contributors
Updated on Jun 25, 2025
Minified
Minified + Gzipped
Latest Version
2.0.0
Package Id
@udecode/zustood@2.0.0
Unpacked Size
844.82 kB
Size
110.56 kB
File Count
44
NPM Version
8.19.4
Node Version
16.20.1
Published on
Jul 08, 2023
Cumulative downloads
Total Downloads
Last Day
14%
1,606
Compared to previous day
Last Week
-8.5%
35,281
Compared to previous week
Last Month
3.2%
147,683
Compared to previous month
Last Year
-27.2%
2,593,584
Compared to previous year
2
1
Zustand is a small, fast and scalable state-management solution battle-tested against common pitfalls, like the dreaded zombie child problem, react concurrency, and context loss between mixed renderers. It may be the one state-manager in the React space that gets all of these right.
As zustand is un-opinionated by design, it's challenging to find out the best patterns to use when creating stores, often leading to boilerplate code.
Zustood, built on top of zustand, is providing a powerful store factory which solves these challenges, so you can focus on your app.
1yarn add zustand @udecode/zustood
Visit zustood.udecode.io for the API.
immer
, devtools
and persist
middlewares1import { createStore } from '@udecode/zustood' 2 3const repoStore = createStore('repo')({ 4 name: 'zustood', 5 stars: 0, 6})
Note that the zustand store is accessible through:
1// hook store 2repoStore.useStore 3 4// vanilla store 5repoStore.store
Use the hooks in React components, no providers needed. Select your
state and the component will re-render on changes. Use the use
method:
1repoStore.use.name() 2repoStore.use.stars()
We recommend using the global hooks (see below) to support ESLint hook linting.
Don't overuse hooks. If you don't need to subscribe to the state, use
instead the get
method:
1repoStore.get.name() 2repoStore.get.stars()
You can also get the whole state:
1repoStore.get.state()
You generally want to write derived selectors (those depending on other selectors) for reusability. Zustood supports extending selectors with full typescript support:
1const repoStore = createStore('repo')({ 2 name: 'zustood ', 3 stars: 0, 4}) 5 .extendSelectors((set, get, api) => ({ 6 validName: () => get.name().trim(), 7 // other selectors 8 })) 9 .extendSelectors((set, get, api) => ({ 10 // get.validName is accessible 11 title: (prefix: string) => 12 `${prefix + get.validName()} with ${get.stars()} stars`, 13 })) 14 // extend again...
Update your store from anywhere by using the set
method:
1repoStore.set.name('new name') 2repoStore.set.stars(repoStore.get.stars + 1)
You can update the whole state from your app:
1store.set.state((draft) => { 2 draft.name = 'test'; 3 draft.stars = 1; 4});
However, you generally want to create derived actions for reusability. Zustood supports extending actions with full typescript support:
1const repoStore = createStore('repo')({ 2 name: 'zustood', 3 stars: 0, 4}) 5 .extendActions((set, get, api) => ({ 6 validName: (name: string) => { 7 set.name(name.trim()); 8 }, 9 // other actions 10 })) 11 .extendActions((set, get, api) => ({ 12 reset: (name: string) => { 13 // set.validName is accessible 14 set.validName(name); 15 set.stars(0); 16 }, 17 })) 18 // extend again...
After having created many stores, it can be difficult to remember which one to import. By combining all the stores, selectors and actions, just pick what you need using TS autocomplete.
1import { mapValuesKey } from '@udecode/zustood'; 2 3// Global store 4export const rootStore = { 5 auth: authStore, 6 combobox: comboboxStore, 7 contextMenu: contextMenuStore, 8 editor: editorStore, 9 modal: modalStore, 10 repo: repoStore, 11 toolbar: toolbarStore, 12}; 13 14// Global hook selectors 15export const useStore = () => mapValuesKey('use', rootStore); 16 17// Global getter selectors 18export const store = mapValuesKey('get', rootStore); 19 20// Global actions 21export const actions = mapValuesKey('set', rootStore);
1useStore().repo.name() 2useStore().modal.isOpen()
By using useStore()
, ESLint will correctly lint hook errors.
1store.repo.name() 2store.modal.isOpen()
These can be used anywhere.
1actions.repo.stars(store.repo.stars + 1) 2actions.modal.open()
These can be used anywhere.
The second parameter of createStore
is for options:
1export interface CreateStoreOptions<T extends State> { 2 middlewares?: any[]; 3 devtools?: DevtoolsOptions; 4 immer?: ImmerOptions; 5 persist?: PersistOptions; 6}
Zustood is using these middlewares:
immer
: required. Autofreeze can be enabled using
immer.enabledAutoFreeze
option.devtools
: enabled if devtools.enabled
option is true
.persist
: enabled if persist.enabled
option is true
. persist
implements PersistOptions
interface from
zustandmiddlewares
optionDiscussions is the best place for bringing opinions and contributions. Letting us know if we're going in the right or wrong direction is great feedback and will be much appreciated!
🌟 Stars and 📥 Pull requests are welcome! Don't hesitate to share your feedback here. Read our contributing guide to get started.
No vulnerabilities found.
No security vulnerabilities found.