Plugin
plugins: [pluginReactQuery()]Officialv5.3.2kubb >=5.8.0node >=22
React Query
@kubb/plugin-react-query
Generates typed TanStack Query hooks for React from your OpenAPI spec, so reads and writes call your API through useQuery, useMutation, and useInfiniteQuery without hand-written boilerplate.
kubb add plugin-react-query
react-querytanstack-queryreacthooksdata-fetchingcodegenopenapi
- Downloads400.4K/ monthnpm, last 30 days
- GitHub stars8kubb-labs/plugins
- Unpacked size609.5kBv5.3.2 on npm
- Latest release1h agov5.3.2 · Oct 13, 2026
Generates TanStack Query helpers for React from your OpenAPI spec. By default you get queryOptions and mutationOptions factories with their cache keys. Set hooks: true to also get useQuery, useSuspenseQuery, useInfiniteQuery, and useMutation hooks.
The plugin ships no HTTP client. Each helper calls a function generated by a client plugin.
Installation
bun add -d @kubb/plugin-react-querypnpm add -D @kubb/plugin-react-querynpm install --save-dev @kubb/plugin-react-queryyarn add -D @kubb/plugin-react-queryOr run kubb add plugin-react-query to install the version the Kubb registry pins and add pluginReactQuery() to kubb.config.ts.
Setup
- Add
@kubb/plugin-tsand a client plugin:@kubb/plugin-fetchor@kubb/plugin-axios. - Install
@tanstack/react-queryv5 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.hooksadds theuse*hooks on top of the option factories.suspenseaddsuseSuspenseQueryhooks.infiniteadds infinite queries for pagination. Setinfinite.queryParamto the query parameter that holds the page cursor.queryandmutationset which HTTP methods become queries (GET) and mutations (POST,PUT,PATCH,DELETE), and where the TanStack Query runtime is imported from. Set either tofalseto skip it.customOptionsroutes every hook through your own function that returns extra options.
Dependencies
No extension dependencies.