---
layout: doc
title: Install Kubb with npm, pnpm, Yarn, or Bun
description: 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.
outline: [2, 3]
order: 1
navigation:
  title: Installation
  icon: i-iconoir-download
---

> Index of every page on this site: [llms.txt](https://kubb.dev/llms.txt)

# 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](/docs/5.x/tutorials/quickstart).

## Prerequisites

- [Node.js](https://nodejs.org/) 22.22 or later.
- TypeScript 5 or later to type-check the generated code. Kubb works with TypeScript 7, the native compiler.

## 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.

::code-group{sync="package-manager"}

```shell [pnpm]
pnpm dlx kubb init
```

```shell [npm]
npx kubb init
```

```shell [yarn]
yarn dlx kubb init
```

```shell [bun]
bunx kubb init
```

::

[`kubb init`](/docs/5.x/reference/commands/init) lists its questions and flags, such as `--yes`, `--input`, and `--plugins`.

## Install by hand

::steps{level="3"}

### Install Kubb and your plugins

Install `kubb` and the [plugins](/extensions/kind/plugins) you need, one package per output. The example adds `@kubb/plugin-ts`:

:::code-group{sync="package-manager"}

```shell [pnpm]
pnpm add -D kubb @kubb/plugin-ts typescript
```

```shell [npm]
npm install -D kubb @kubb/plugin-ts typescript
```

```shell [yarn]
yarn add -D kubb @kubb/plugin-ts typescript
```

```shell [bun]
bun add -d kubb @kubb/plugin-ts typescript
```

:::

### Verify the installation

:::code-group{sync="package-manager"}

```shell [pnpm]
pnpm exec kubb --version
```

```shell [npm]
npx kubb --version
```

```shell [yarn]
yarn kubb --version
```

```shell [bun]
bunx 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](/docs/5.x/how-to/recipes#pick-a-stack), or see [Configuration](/docs/5.x/reference/configuration).

### Generate

:::code-group{sync="package-manager"}

```shell [pnpm]
pnpm exec kubb generate
```

```shell [npm]
npx kubb generate
```

```shell [yarn]
yarn kubb generate
```

```shell [bun]
bunx kubb generate
```

:::

Kubb writes the generated files to `output.path`.

::

## Install runtime libraries

> [!IMPORTANT]
> 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](/extensions):

| Command | What it does |
| --- | --- |
| [`kubb add plugin-zod`](/docs/5.x/reference/commands/add) | Installs the plugin at the version the registry pins and adds it to `kubb.config.ts` |
| [`kubb list`](/docs/5.x/reference/commands/list) | Lists installed extensions, their versions, and available updates |
| [`kubb update`](/docs/5.x/reference/commands/update) | Moves installed extensions to the pinned versions, generates again, and summarizes the file changes |
| [`kubb remove plugin-zod`](/docs/5.x/reference/commands/remove) | Removes the plugin from `kubb.config.ts` and uninstalls its package |

## Sitemap

See the full [sitemap](https://kubb.dev/sitemap.md) for all pages.
