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

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

react-querytanstack-queryreacthooksdata-fetchingcodegenopenapi
Stijn Van Hulle

Stijn Van Hulle

@stijnvanhulle

Downloads
361.8K/ mo
Stars
8
Bundle size
556.8 kB
Updated
1d ago

@kubb/plugin-react-query generates TanStack Query option factories and cache keys from OpenAPI operations. Set hooks: true to also generate React hooks.

Installation

bun add -d @kubb/plugin-react-query

Dependencies

Add pluginTs and an Axios or Fetch client plugin. Generated output requires @tanstack/react-query v5 or higher. Configure validation on the client plugin.

Example

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

export default defineConfig({
  input: './petStore.yaml',
  output: { path: './src/gen' },
  plugins: [
    pluginTs(),
    pluginFetch(),
    pluginReactQuery({ hooks: true }),
  ],
})

Documentation

See also