Astro
unplugin-kubb/astro runs Kubb as an Astro integration. It hooks into Astro's Vite layer and generates during a build. Pass your Kubb config to the config option.
Install
shell
bun add -d unplugin-kubb@betashell
pnpm add -D unplugin-kubb@betashell
npm install --save-dev unplugin-kubb@betashell
yarn add -D unplugin-kubb@betaConfigure
typescript
import { defineConfig as defineAstroConfig } from 'astro/config'
import kubb from 'unplugin-kubb/astro'
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 defineAstroConfig({
integrations: [kubb({ config })],
})NOTE
The Astro integration runs through Vite with apply: 'build'. Generation runs during astro build only. Run kubb generate before you start the dev server.