Mobx
mobx
Simple, scalable state management.
State Management
mobx
mobservable
observable
react-component
react
reactjs
reactive
model
frp
functional-reactive-programming
Stars
28k
Weekly
3.3M
Open issues
58
Bundle
~25 kB
Installation
npm install mobxCode example
import { create } from "mobx";
const useStore = create((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 Michel Weststrate
- 3.3M weekly downloads. Battle tested
- First-class TypeScript definitions
- MIT licensed
Considerations
- Adds roughly ~25 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 58 open issues on GitHub