Plugin
plugins: [pluginFetch()]Officialv5.5.10kubb >=5.8.0node >=22
Fetch
@kubb/plugin-fetch
Generates a type-safe Fetch API client from your OpenAPI spec, one async function per operation, so each call stays in sync with the API.
kubb add plugin-fetch
api-clientfetchhttp-clientcodegenopenapivalidator
- Downloads83.6K/ monthnpm, last 30 days
- GitHub stars8kubb-labs/plugins
- Unpacked size487.4kBv5.5.10 on npm
- Latest release1h agov5.5.10 · Oct 13, 2026
Generates a type-safe HTTP client based on the native Fetch API from your OpenAPI spec. Each operation becomes one async function with grouped path, query, headers, and body parameters and a result keyed by status code.
This plugin provides the client runtime. Query plugins such as @kubb/plugin-react-query, @kubb/plugin-vue-query, @kubb/plugin-swr, and @kubb/plugin-mcp call the functions it generates.
Installation
bun add -d @kubb/plugin-fetchpnpm add -D @kubb/plugin-fetchnpm install --save-dev @kubb/plugin-fetchyarn add -D @kubb/plugin-fetchOr run kubb add plugin-fetch to install the version the Kubb registry pins and add pluginFetch() to kubb.config.ts.
Setup
- Add
@kubb/plugin-tsfor the operation types. Without it,@kubb/plugin-zodwithinferred: truesupplies them. - Add
@kubb/plugin-zodwhen you setvalidator. - No HTTP client package is needed.
Options worth knowing
baseURLis prepended to every request.validator: 'zod'validates request and response bodies with the schemas from@kubb/plugin-zod.sdkgenerates a class-based SDK, grouped by tag or flat, instead of standalone functions. Query plugins need the standalone functions, so leavesdkunset when you use them.returnType: 'data'makes a call resolve to the success body instead of the full result with status, data, and error.throwOnErrorDefault: falsereturns documented error responses as values instead of throwing. A single call can still passthrowOnError.
Dependencies
No extension dependencies.