Zustand
zustand
🐻 Bear necessities for state management in React
State Management
react
state
manager
management
redux
store
zustand
State Management
javascript
npm
Stars
1.7k
Weekly
49M
Open issues
21
Bundle
~15 kB
Installation
npm install zustandCode example
import { create } from "zustand";
type Store = {
count: number;
inc: () => void;
};
const useStore = create<Store>((set) => ({
count: 0,
inc: () => set((s) => ({ count: s.count + 1 })),
}));
export function Example() {
const { count, inc } = useStore();
return (
<button type="button" onClick={inc}>
Count: {count}
</button>
);
}Pros & cons
Pros
- Actively maintained by Paul Henschel
- 49M weekly downloads. Battle tested
- First-class TypeScript definitions
- MIT licensed
Considerations
- Adds roughly ~15 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 21 open issues on GitHub