Introduction
Kubb is a meta framework for code generation. It runs a plugin-based pipeline on top of any API specification. An adapter reads your spec. Parsers turn the AST into source files. Plugins generate the output. The pipeline writes, formats, and lints the result, all from a single config file.
The default adapter reads OpenAPI 2.0, 3.0, and 3.1. From there Kubb generates TypeScript types, React Query hooks, Zod validators, MSW mocks, or a custom output. You stop hand-maintaining generated code. The output is deterministic. The same spec always produces the same result.
See it work
Here is the whole loop, start to finish. Install Kubb together with one plugin:
npm install -D @kubb/core@beta @kubb/plugin-ts@betaCreate a kubb.config.ts next to your spec. It points at the spec, sets an output directory, and lists the plugins you want. This one generates TypeScript types with @kubb/plugin-ts:
import { } from 'kubb'
import { } from '@kubb/plugin-ts'
export default ({
: { : './petStore.yaml' },
: { : './src/gen', : true },
: [({ : { : 'models' } })],
})Run the generator:
kubb generateKubb writes one .ts file per schema into ./src/gen/models. Import a type and the editor knows your API:
import type { } from './gen/models/Pet'
const : = { : 1, : 'Cat' }That is the full cycle. Change the spec, run kubb generate again, and the types follow.
Features
- Generate TypeScript types, React Query and Vue Query hooks, SWR hooks, Zod validators, Faker mocks, and MSW handlers, each from its own plugin.
- Generate a typed Axios or Fetch client with status-keyed results, auth, validation, file uploads, server-sent events, interceptors, and a swappable transport.
- Read any OpenAPI 2.0, 3.0, or 3.1 spec through the OpenAPI adapter, or add your own adapter.
- Shape the output by grouping files by tag or path, including or excluding operations, and writing to disk, memory, or a custom storage backend.
- Generate Cypress tests and a Model Context Protocol server, or write your own plugin.
- Run generation in Vite, Nuxt, and other bundlers with
unplugin-kubb, or from AI assistants and Claude Code.
Ready for more? Read Installation and Basic Usage, then reach for Configuration, Recipes, and Integrations when you need them.
Community
Join the Discord server, file an issue on GitHub, or sponsor the project on GitHub Sponsors or Open Collective.