Beta You're reading the docs for Kubb v5, which is currently in beta. View the stable v4 docs
Skip to content

Integrations

kubb's bundler entrypoints run code generation inside your build. You skip the separate kubb generate step. Pass the same config you write in kubb.config.ts, and Kubb runs it as part of your build instead. Each entrypoint is powered by unplugin-kubb under the hood, re-exported from kubb so you only install one package.

NOTE

hooks.done runs formatters and linters after generation. It works with the CLI only, not with unplugin. Use kubb generate when you need a post-generation callback.

IMPORTANT

Vite-based bundlers (Vite, Nuxt, Astro) generate during a build only. They skip generation on dev server startup. Run kubb generate before you start the dev server.

Installation

Install kubb as a dev dependency.

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

Pick your bundler

Each bundler has its own entrypoint.

Bundler Entrypoint Docs
Vite kubb/vite Vite
Rollup kubb/rollup Rollup
Rolldown kubb/rolldown Rolldown
webpack kubb/webpack webpack
Rspack kubb/rspack Rspack
esbuild kubb/esbuild esbuild
Farm kubb/farm Farm
Nuxt kubb/nuxt Nuxt
Astro kubb/astro Astro

Options

Pass your Kubb config to the config option. It takes a UserConfig object with the same shape as kubb.config.ts.

vite.config.ts
typescript
import kubb from 'kubb/vite'
import { defineConfig as defineViteConfig } from 'vite'
import { pluginTs } from '@kubb/plugin-ts'

const config = {
  root: '.',
  input: { path: './petStore.yaml' },
  output: { path: './src/gen', clean: true },
  plugins: [pluginTs({ output: { path: 'models' } })],
}

export default defineViteConfig({
  plugins: [kubb({ config })],
})