Skip to content
Officialv5.5.9MITkubb >=5.0.0node >=22

@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.

api-clientfetchhttp-clientcodegenopenapivalidator
Stijn Van Hulle

Stijn Van Hulle

@stijnvanhulle

Downloads
83.6K/ mo
Stars
8
Bundle size
450.8 kB
Updated
2h ago

Generate typed API calls with the native Fetch API.

  • One async function per OpenAPI operation.
  • Grouped request parameters and status-keyed results.

Installation

bun add -d @kubb/plugin-fetch

Or run kubb add plugin-fetch to install the version the Kubb registry pins and add pluginFetch() to kubb.config.ts.

Dependencies

  • Add pluginTs or pluginZod with inferred: true for operation types. pluginTs takes precedence.
  • Add pluginZod for validation.

Example

kubb.config.ts
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginFetch } from '@kubb/plugin-fetch'

export default defineConfig({
  input: './petStore.yaml',
  output: { path: './src/gen' },
  plugins: [
    pluginTs(),
    pluginFetch({ baseURL: 'https://petstore.swagger.io/v2' }),
  ],
})

See also