Skip to content

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