Nuxt
unplugin-kubb/nuxt runs Kubb as a Nuxt module. It works with Nuxt 3 and Nuxt 4 and registers Kubb as both a Vite and webpack plugin depending on your Nuxt renderer.
Install
shell
bun add -d unplugin-kubbshell
pnpm add -D unplugin-kubbshell
npm install --save-dev unplugin-kubbshell
yarn add -D unplugin-kubbConfigure
Pass your Kubb config as the second element in the module tuple. defineNuxtConfig is auto-imported by Nuxt and does not need an explicit import.
typescript
import { defineConfig } from 'kubb'
import { pluginTs } from '@kubb/plugin-ts'
const config = defineConfig({
root: '.',
input: { path: './petStore.yaml' },
output: { path: './src/gen', clean: true },
plugins: [pluginTs({ output: { path: 'models' } })],
})
export default defineNuxtConfig({
modules: [['unplugin-kubb/nuxt', { config }]],
})NOTE
Because the Nuxt module delegates to the Vite plugin under the hood, generation only runs during nuxt build. It does not run during nuxt dev. Run kubb generate before starting the dev server.