Skip to content

Installation

Prerequisites

The kubb init wizard detects your package manager, asks where your spec lives and where generated files should go, lets you pick plugins, installs everything, and writes a kubb.config.ts.

shell
npx kubb init

Then run:

shell
npx kubb generate

Manual installation

1. Install Kubb

shell
bun add -d kubb
shell
pnpm add -D kubb
shell
npm install --save-dev kubb
shell
yarn add -D kubb

NOTE

The kubb package includes the CLI, the core runtime, the OpenAPI adapter, and the TypeScript parser by default. You only need to add plugins for the outputs you want.

2. Add plugins

Each output format is its own package. Install only what you need.

shell
bun add -d @kubb/plugin-ts @kubb/plugin-client @kubb/plugin-react-query
shell
pnpm add -D @kubb/plugin-ts @kubb/plugin-client @kubb/plugin-react-query
shell
npm install --save-dev @kubb/plugin-ts @kubb/plugin-client @kubb/plugin-react-query
shell
yarn add -D @kubb/plugin-ts @kubb/plugin-client @kubb/plugin-react-query
Package Generates
@kubb/plugin-ts TypeScript types and interfaces
@kubb/plugin-client HTTP client functions (Axios, Fetch, custom)
@kubb/plugin-react-query TanStack Query hooks for React
@kubb/plugin-vue-query TanStack Query hooks for Vue
@kubb/plugin-zod Zod schemas for runtime validation
@kubb/plugin-faker Faker.js mock data generators
@kubb/plugin-msw MSW request handlers
@kubb/plugin-cypress Cypress end-to-end tests
@kubb/plugin-mcp MCP server from your spec
@kubb/plugin-redoc Redoc API documentation

See the plugins page for a complete list.

3. Create kubb.config.ts

The config points Kubb at your spec and your output directory. defineConfig applies the OpenAPI adapter automatically.

kubb.config.ts
typescript
import {  } from 'kubb'
import {  } from '@kubb/plugin-ts'

export default ({
  : '.',
  : { : './petStore.yaml' },
  : { : './src/gen', : true },
  : [()],
})

Kubb looks for kubb.config.ts (recommended) in the project root and the .config/ and configs/ subdirectories. JavaScript variants (.js, .mjs, .cjs) and TypeScript .mts/.cts are also supported.

TIP

Use --config <path> to point Kubb at a config file in a custom location.

4. Add a script

Add a generate script to package.json so generation is a single command:

package.json
json
{
  "scripts": {
    "generate": "kubb generate"
  }
}

5. Generate

shell
npm run generate

Generated files appear under output.path. Re-run this command whenever your spec changes.

Continue to Basic Usage to write a full config with multiple plugins, or jump to Configuration for every available option. To run generation as part of your bundler see Integrations.