kubb init
The interactive setup wizard. Answer a few questions and Kubb creates a package.json if one is missing, installs your chosen plugins, and writes a ready-to-use kubb.config.ts.
Usage
Run the command in the directory where you want your Kubb project to live:
npx kubb initThe wizard prompts for:
- The path to your OpenAPI/Swagger spec (local file or URL).
- The output directory for generated files.
- Which plugins to install (clients, hooks, validators, mocks, and more).
- Your preferred package manager (
bun,pnpm,npm, oryarn).
When the wizard finishes, you have:
- A
kubb.config.tswired up with the plugins you selected. - A
package.jsonwithkubband the chosen plugins added as dev dependencies. - All selected dependencies installed.
Options
| Option | Default | Description |
|---|---|---|
--yes, -y | false | Skip all prompts and use the default values. |
--input, -i | — | Path to the OpenAPI specification (local file or URL). Bypasses the spec path prompt. |
--output, -o | — | Output directory for generated files. Bypasses the output directory prompt. |
--plugins | — | Comma-separated list of plugins to install. Bypasses the plugin selection prompt. Valid values: plugin-ts, plugin-client, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc. |
Each flag bypasses only its specific prompt and composes freely with --yes. Providing all three non-boolean flags runs the wizard completely non-interactively without needing --yes.
Examples
Initialize a project from scratch:
npx kubb initInitialize non-interactively with the defaults:
npx kubb init --yesInitialize with a specific spec and output directory:
npx kubb init --input ./openapi.yaml --output ./src/genInitialize fully non-interactively with specific plugins:
npx kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zodInitialize with a plugin selection but still prompt for the spec path:
npx kubb init --plugins plugin-ts,plugin-client,plugin-react-queryTIP
To wire things up by hand instead, see the Installation guide for a manual setup walkthrough.
See also
- Installation: manual setup guide
- Configuration: full
kubb.config.tsreference - Plugins: browse available plugins