Zustand là thư viện quản lý state nhỏ gọn cho React, không yêu cầu boilerplate như Redux — không cần actions, reducers, dispatch, hay Provider wrapper.
- API chỉ gồm hàm
createtrả về một hook, state và actions định nghĩa cùng chỗ. - Bundle size ~1KB so với Redux Toolkit ~40KB khi đầy đủ.
Ví dụ tạo store đơn giản: const useStore = create(set => ({ count: 0, inc: () => set(s => ({ count: s.count + 1 })) })), dùng trong component: const count = useStore(s => s.count).
Pitfall quan trọng: luôn dùng selector khi lấy state (useStore(s => s.count) thay vì useStore()) để tránh re-render không cần thiết khi phần state khác thay đổi.