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.
bun add -d kubb@betapnpm add -D kubb@betanpm install --save-dev kubb@betayarn add -D kubb@betaPick 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.
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 })],
})