Overview
When you runcreate-zustand-store, you’ll be prompted to configure the following options. If you have a saved configuration file, the CLI will load your previous settings as defaults.
Options Reference
The name of your Zustand store. This will be used as the filename and the export name.Examples:
useCounteruseUserStoreuseAuthStore
{storeName}.js or {storeName}.ts depending on your file type choice.The programming language for your store file.Choices:
JavaScript- Creates a.jsfileTypeScript- Creates a.tsfile with type definitions
Whether to add persistence to your store using Zustand’s persist middleware.When enabled, your store’s state will be automatically saved to localStorage and restored on page reload.Example:
true- Uses the persist templatefalse- Uses the standard template
Define the initial state properties for your store as a JSON object.Format: Must be valid JSON syntaxExamples:The CLI automatically infers TypeScript types from your initial state values:
- Numbers become
number - Strings become
string - Booleans become
boolean - Arrays become
any[] - Objects become
object
Define the actions (methods) for your store as a comma-separated list.Format: Comma-separated action names (no spaces)Examples:Each action is generated as a function that accepts the Generated implementation:
set function. You’ll need to implement the logic inside each action after generation.Generated TypeScript signature:Your preferred package manager for installing dependencies.Choices:
npm- Usesnpm installyarn- Usesyarn add
The directory path where your store file will be created.Examples:
store- Creates in./store/src/store- Creates in./src/store/src/stores- Creates in./src/stores/
Whether to save your current configuration as the default for future store creation.When enabled, your settings are saved to
zustand-store-config.json in your project root.Saved configuration includes:- storeName
- fileType
- addPersist
- initialState
- actions
- packageManager
- storePath
create-zustand-store, these values will be used as defaults in the prompts.Configuration File
When you save your configuration, it’s stored inzustand-store-config.json: