Install Kubb with npm, pnpm, Yarn, or Bun
Add Kubb to an existing project. To learn with a sample spec first, follow Generate your first client.
Prerequisites
- Node.js 22.22 or later.
- TypeScript 5 or later to type-check the generated code.
Set up with the wizard
kubb init installs kubb and the plugins you pick, writes kubb.config.ts, adds a generate script to package.json if it has none, and runs Kubb once. It uses the package manager in your packageManager field or lockfile, or npm.
pnpm dlx kubb initnpx kubb inityarn dlx kubb initbunx kubb initkubb init lists its questions and flags, such as --yes, --input, and --plugins.
Install by hand
Install Kubb and your plugins
Install kubb and the plugins you need, one package per output. The example adds @kubb/plugin-ts:
pnpm add -D kubb @kubb/plugin-ts typescriptnpm install -D kubb @kubb/plugin-ts typescriptyarn add -D kubb @kubb/plugin-ts typescriptbun add -d kubb @kubb/plugin-ts typescriptVerify the installation
pnpm exec kubb --versionnpx kubb --versionyarn kubb --versionbunx kubb --versionCreate the config
Write kubb.config.ts in the project root with your spec as input, an output.path, and your plugins. Start from Pick a stack, or see Configuration.
Generate
pnpm exec kubb generatenpx kubb generateyarn kubb generatebunx kubb generateKubb writes the generated files to output.path.
Install runtime libraries
kubb init and kubb add install only Kubb packages. An Axios client needs axios, and React Query hooks need react and @tanstack/react-query. Each plugin page lists its requirements.Add plugins later
After kubb.config.ts exists, manage extensions from the extension registry:
| Command | What it does |
|---|---|
kubb add plugin-zod | Installs the plugin at the version the registry pins and adds it to kubb.config.ts |
kubb list | Lists installed extensions, their versions, and available updates |
kubb update | Moves installed extensions to the pinned versions, generates again, and summarizes the file changes |
kubb remove plugin-zod | Removes the plugin from kubb.config.ts and uninstalls its package |
