Configuration File
Thecreate-zustand-store CLI supports saving your preferences to a configuration file. This allows you to set default values for all options, making it faster to create new stores with consistent settings.
File Location
The configuration file is stored at the root of your project:Creating a Configuration
You can create a configuration file in two ways:1. Via Interactive Prompt
When running the CLI, answer “Yes” to the final prompt:2. Manual Creation
Create azustand-store-config.json file in your project root:
Configuration Schema
All fields in the configuration file are optional. If a field is missing, the CLI will use its built-in default value.Default name for new stores.
Default file type. Must be either
"JavaScript" or "TypeScript".Whether to add persistence by default.
Default initial state as a JSON object.Example:
Default actions as a comma-separated string.Example:
Default package manager. Must be either
"npm" or "yarn".Default directory path for store files.
Example Configurations
TypeScript Project with Persistence
Counter Store Template
Authentication Store Template
How Configuration Loading Works
- When you run
create-zustand-store, the CLI checks forzustand-store-config.jsonin the current directory - If found, the CLI loads the configuration and displays a success message:
- The loaded values are used as defaults in the interactive prompts
- You can override any default by simply changing the value in the prompt
- If you choose to save the configuration again, it will overwrite the existing file with your new values
Editing Configuration
You can edit the configuration file at any time:- Open
zustand-store-config.jsonin your editor - Modify the values you want to change
- Save the file
- Run
create-zustand-storeagain to use the updated defaults