Kit API
kubb/kit contains everything you need to build your own plugin and custom logic. Plugins, generators, resolvers, renderers, adapters, parsers, and storage backends all start here. It is a subpath of the top-level kubb package, so there is nothing extra to install. Import straight from kubb/kit.
Big concepts
The seven pieces you reach for when you build something new. Each has its own page.
| Concept | Entry point | What it does |
|---|---|---|
| Plugins | definePlugin | The main extension point. Owns file naming, the output folder, and the lifecycle hooks. |
| Generators | defineGenerator | Walks the AST and emits files. A plugin registers one or more. |
| Resolvers | createResolver | Decides file names and output paths. Other plugins read them by name. |
| Renderers | createRenderer, jsxRenderer | Turns the elements a generator returns into FileNodes. |
| Adapters | createAdapter | Converts an input spec into the universal AST every plugin reads. |
| Parsers | defineParser | Turns a FileNode into the source string written to disk. |
| Storage | createStorage, fsStorage, memoryStorage | Decides where generated files land. |
Other parts
| Part | Entry point | What it does |
|---|---|---|
| AST and node builders | ast | The namespace behind factory builders, visitors, guards, macros, and printers. |
| Diagnostics | Diagnostics | Builds and narrows the structured errors Kubb collects during a build. |
| Engine and configuration | defineConfig, createKubb | The kubb-package surface that runs your plugins. |
| Testing | kubb/kit/testing | Vitest-backed helpers for testing plugins, generators, and adapters. |
See also
- Kit concepts for why the authoring toolkit is a separate surface from the engine
- JSX API reference for
kubb/jsx, the JSX renderer - Plugin concepts for lifecycle hooks, generators, resolvers, and the plugin registry
- AST concepts for
InputNode,OperationNode,SchemaNode, and traversal - Adapter concepts on how adapters convert specs to the universal AST
- Parser concepts on converting
FileNodeAST to source strings - Macros concepts for
defineMacro,composeMacros, andapplyMacros - Barrel files for barrel generation with
@kubb/plugin-barrel - Creating plugins for a step-by-step guide to building a full plugin
- Programmatic usage recipes with
createKubbusage patterns - Configuration reference for all
defineConfigoptions