kubb add
Run kubb add to install an extension from the Kubb registry at the version the registry pins. It checks that the extension supports your Kubb and Node.js versions, asks for confirmation, and installs the package as a dev dependency. For a plugin, it also adds the plugin to kubb.config.ts. For an adapter or parser, it prints the code to add.
Kubb detects the package manager (npm, pnpm, yarn, or bun) from your project.
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-installnpm or GitHub
An extension on npm installs as <package>@<version>. An extension pinned to a GitHub release installs as github:<owner>/<repo>#<commit>.
npx kubb add plugin-zod
# installs @kubb/plugin-zod@<version>npx kubb add acme/kubb-plugin-example
# installs github:acme/kubb-plugin-example#<commit>Arguments
| 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. |
--yes in scripts and CI, where no one can answer the prompt.Config changes
For a plugin, kubb add adds its import and a call at the end of the plugins array. A plugin already in the array is left alone.
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.
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.