Dùng create từ 'zustand', truyền vào initializer function nhận (set, get) và trả về object chứa cả state lẫn actions trong cùng một chỗ. set() merge partial state (không cần spread toàn bộ như Redux). get() đọc state hiện tại từ bên trong action.
Ví dụ đầy đủ: const useCartStore = create((set, get) => ({ items: [], total: 0, addItem: (item) => set((s) => ({ items: [...s.items, item], total: s.total + item.price })), clearCart: () => set({ items: [], total: 0 }), getItemCount: () => get().items.length })).