Skip to content
Build tools

Generate code from your API spec with Vite

Add the kubb/vite plugin to vite.config.ts so every Vite build generates code from your API spec with the plugins in your kubb.config.ts.

kubb/vite generates code from your kubb.config.ts once, before vite build continues. It ships with kubb.

Kubb runs on vite build only, not in the dev server. Run kubb generate before vite dev.

Install Kubb and your plugins

Follow Installation.

Add Kubb to vite.config.ts

Pass one config object from your kubb.config.ts as config, not an array or a function.

vite.config.ts
import kubb from 'kubb/vite'
import { defineConfig } from 'vite'
import config from './kubb.config.ts'

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

Run the build

Run vite build. If Kubb fails, the build fails.

How the build runs Kubb covers defaults, reports, and watch rebuilds.