Run Kubb with Astro
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
Install kubb as a dev dependency.
shell
bun add -d kubb@betashell
pnpm add -D kubb@betashell
npm install --save-dev kubb@betashell
yarn add -D kubb@betaConfigure
Add the integration to your astro.config.mjs and pass it your Kubb config.
typescript
import { defineConfig } from 'astro/config'
import kubb from 'kubb/astro'
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 defineConfig({
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.