kubb add
Run kubb add to install an extension from the Kubb registry at the version the registry pins. For a plugin, it also adds the plugin to kubb.config.ts. For an adapter or parser, it prints the code to add.
Usage
Add an official plugin by its slug:
kubb add plugin-zodAdd a community plugin by its full id, without the confirmation:
kubb add acme/plugin-graphql --yesEdit the config without installing the package:
kubb add plugin-zod --no-installArguments
| Argument | Required | Description |
|---|---|---|
<id> | true | Registry id as <owner>/<slug>, such as kubb-labs/plugin-react-query. A bare <slug> means kubb-labs/<slug>. Both parts use lowercase letters and digits joined by single hyphens. |
Options
| Option | Default | Description |
|---|---|---|
--config=<path>, -c <path> | Path to the Kubb config to edit. Only used for plugins. Without it, the CLI looks for the same config files as kubb generate, in the current directory and then in each parent directory. | |
--yes, -y | false | Skip the confirmation. |
--no-install | Do not install the package. A plugin is still added to the config. |
What it does
- Fetches
<registry>/<owner>/<slug>.json. An unknown id fails with"<id>" is not in the registry at <registry>. - Checks the manifest's
compatibilityagainst the running Kubb and Node.js versions. A mismatch fails with the same message Kubb prints at runtime, such as"plugin-zod" requires Node.js >=22, but 20.11.0 is running. - For a plugin, finds the config file. Without one, it fails with
No kubb.config.ts found. Run `kubb init` first, or pass --config. - Prints the extension's name, kind, and description, the
<package>@<version>it installs, and the config file it edits. Then it asksContinue?unless you pass--yes. - Installs
<package>@<version>as a dev dependency with the package manager of the current directory. - For a plugin, adds
import { <export> } from '<package>'and a<export>()call at the end of thepluginsarray. A plugin already in the array is left alone. For an adapter or parser, it prints the import and theadapterorparsersproperty to merge intodefineConfig.
The package manager comes from the packageManager field in package.json, then from a lock file (pnpm-lock.yaml, yarn.lock, bun.lock or bun.lockb, package-lock.json). Without either, the CLI uses npm.
When the config cannot be edited, the CLI prints Could not edit <file>: <reason> and the snippet to add by hand. This happens when plugins is not an array literal, or when the export name is already imported from another package.
--yes in scripts and CI, where no one can answer the prompt.Environment variables
| Variable | Default | Description |
|---|---|---|
KUBB_REGISTRY | https://kubb.dev/registry | Base URL of the registry to read. It must start with http:// or https://. Trailing slashes are removed. See Host your own registry. |
Exit codes
kubb add exits with code 1 when the id is invalid, the registry cannot be read or sends an invalid entry, the extension is incompatible, no config is found for a plugin, or the install fails. It exits with code 0 when you cancel at the prompt, and when it prints the snippet because the config could not be edited.
See also
kubb update: move installed extensions to the pinned versionkubb list: show installed extensions and available updates- Extension registry: ids, documents, and pinning
- Plugins: every official plugin