Plugin
plugins: [pluginSwr()]Officialv5.2.4kubb >=5.8.0node >=22
SWR
@kubb/plugin-swr
Generates typed SWR hooks from your OpenAPI spec, so data fetching stays in sync with the API.
kubb add plugin-swr
swrreacthooksdata-fetchingcodegenopenapi
- Downloads45.9K/ monthnpm, last 30 days
- GitHub stars8kubb-labs/plugins
- Unpacked size357.5kBv5.2.4 on npm
- Latest release1h agov5.2.4 · Oct 13, 2026
Generates typed SWR hooks from your OpenAPI spec: useSWR for reads and useSWRMutation for writes.
The plugin ships no HTTP client. Each hook calls a function generated by a client plugin.
Installation
bun add -d @kubb/plugin-swrpnpm add -D @kubb/plugin-swrnpm install --save-dev @kubb/plugin-swryarn add -D @kubb/plugin-swrOr run kubb add plugin-swr to install the version the Kubb registry pins and add pluginSwr() to kubb.config.ts.
Setup
- Add
@kubb/plugin-tsand a client plugin:@kubb/plugin-fetchor@kubb/plugin-axios. - Install SWR v2 or higher in the app that uses the generated code.
- Configure validation on the client plugin, not here.
Options worth knowing
clientpicksfetchoraxioswhen both client plugins are registered. A single client is detected automatically.queryandmutationset which HTTP methods become queries (GET) and mutations (POST,PUT,PATCH,DELETE), and where SWR is imported from (swrandswr/mutation). Set either tofalseto skip it.
Dependencies
No extension dependencies.