Skip to content

Integrations

Kubb runs from the CLI and the places you already work. A bundler integration generates during your build. Kubb Studio starts generation in a connected agent or shared sandbox from a browser tab, and a CI job publishes a snapshot a reviewer can install.

Bundlers

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

output.postGenerate runs commands after generation. It works with the CLI only, not with unplugin. Use kubb generate when you need a post-generation command.

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
shell
pnpm add -D kubb
shell
npm install --save-dev kubb
shell
yarn add -D kubb

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: './petStore.yaml',
  output: { path: './src/gen', clean: true },
  plugins: [pluginTs({ output: { path: 'models' } })],
}

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

Kubb Studio

Kubb Studio lets you start and review generation from a browser tab. Connect a local project with kubb studio, run a Docker agent for a team, or try the shared sandbox without setup. A connected agent runs Kubb in its own environment. The sandbox runs on shared infrastructure.

Use Studio when you want to change plugin options and inspect generated files. Use a bundler integration when generation should run as part of your build.

Continuous integration

kubb studio snapshot runs generation on a build agent and publishes the result to Studio as an installable tarball a reviewer can try.

Bitbucket Pipelines and CircleCI are detected too, and any other CI works once you pass --id. See Snapshot from CI for what they share.