Skip to content
How-to guides

Install Kubb with npm, pnpm, Yarn, or Bun

Set up Kubb in an existing project with the kubb init wizard or by hand with npm, pnpm, Yarn, or Bun, verify the version, and add plugins later with kubb add.

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 init

kubb 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 typescript

Verify the installation

pnpm exec kubb --version

Create 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 generate

Kubb writes the generated files to output.path.

Install runtime libraries

Install the libraries your generated code imports yourself. 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:

CommandWhat it does
kubb add plugin-zodInstalls the plugin at the version the registry pins and adds it to kubb.config.ts
kubb listLists installed extensions, their versions, and available updates
kubb updateMoves installed extensions to the pinned versions, generates again, and summarizes the file changes
kubb remove plugin-zodRemoves the plugin from kubb.config.ts and uninstalls its package