CLI Interaction
When you runcreate-zustand-store, you’ll be prompted with a series of questions. Here’s how to configure a counter store:
Generated Store Code
The CLI generates the following store file based on your inputs:- TypeScript
- JavaScript
store/useCounterStore.ts
Customizing Actions
After generating the store, you’ll need to implement the action logic. The CLI creates placeholder actions that you can customize:- TypeScript
- JavaScript
Using the Store in a Component
Once you’ve generated and customized your counter store, you can use it in your React components:- TypeScript
- JavaScript
Counter.tsx
Alternative: Selecting Individual Actions
For better performance, you can select individual actions instead of destructuring the entire actions object:Next Steps
- Learn how to add persistence to your counter store
- Explore more complex examples like user management stores
- Check out todo list stores for array manipulation patterns