Skip to content
Plugin
Vue Query logo
plugins: [pluginVueQuery()]
Officialv5.11.0kubb >=5.19.0node >=22.22

OpenAPI to Vue Query generator

@kubb/plugin-vue-query

Generates typed TanStack Query helpers for Vue from your OpenAPI spec: queryOptions factories with query and mutation keys, plus optional composables.

kubb add plugin-vue-query
vue-querytanstack-queryvuecomposablesdata-fetchingcodegenopenapi

The Vue Query plugin generates TanStack Query queryOptions factories, query and mutation keys, and optional composables from your OpenAPI spec.

  • hooks: true adds useQuery and useMutation composables that take reactive parameters, with infinite variants on request.
  • The plugin ships no HTTP client. Each helper calls a function from your client plugin.

Installation

kubb add plugin-vue-query

kubb add installs the version the Kubb registry pins and adds pluginVueQuery() to kubb.config.ts. It needs a kubb.config.ts, so run kubb init first in a new project.

Setup

  • Add @kubb/plugin-ts, or pluginZod({ inferred: 'codec' }) with zod v4 in the app.
  • Add one client plugin: @kubb/plugin-fetch, @kubb/plugin-axios, @kubb/plugin-ky, or @kubb/plugin-client. Leave sdk unset on it.
  • Install @tanstack/vue-query 5.41 or a later v5 release and vue 3.3 or later in the app.
  • Set the base URL, auth, and validation on the client plugin. With @kubb/plugin-client, your client module owns them.

Options worth knowing

OptionWhat it does
clientPicks 'fetch', 'axios', 'ky', or 'client' when several client plugins are registered.
hooksAdds the use* composables. infinite needs it.
query, mutationWhich HTTP methods become queries and mutations. false skips them.
infiniteAdds infinite queries to operations with the infinite.queryParam parameter, 'id' by default.

Example

This config generates composables that call the Fetch client.

kubb.config.ts
import { defineConfig } from 'kubb/config'
import { adapterOas } from '@kubb/adapter-oas'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginFetch } from '@kubb/plugin-fetch'
import { pluginVueQuery } from '@kubb/plugin-vue-query'

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

See Options for every option. Next, call operations.

Dependencies

No extension dependencies.

Optional dependencies

Extensions Vue Query works with when they are in the config.