Are you an LLM? You can read better optimized documentation at /plugins/plugin-react-query/recipes/wrap-hooks-with-shared-options.md for this page in Markdown format
Wrap every hook with shared options
Set customOptions to route every generated hook through your own function, so shared behavior like onSuccess or select stays in one place instead of repeated per call. The plugin also emits a HookOptions type so your wrapper stays in sync with the generated hooks.
kubb.config.ts
typescript
import { defineConfig } from 'kubb/config'
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', clean: true },
plugins: [
pluginTs(),
pluginFetch(),
pluginReactQuery({
hooks: true,
customOptions: {
importPath: './useCustomHookOptions',
name: 'useCustomHookOptions',
},
}),
],
})