Skip to content
Reference

Options

Configuration options for @kubb/plugin-vue-query.

Pass these options to pluginVueQuery(). Shared options link to Shared plugin options, which documents their behavior once.

Options overview

OptionPurposeDefault
outputWhere the generated composables are written and exported.{ path: 'hooks', barrel: { type: 'named' } }
↳ output.pathChoose the output folder or file.'hooks'
↳ output.modeWrite a single file or a directory of files.Inferred from output.path
↳ output.barrelConfigure barrel exports.{ type: 'named' }
↳ output.bannerAdd content before generated code.None
↳ output.footerAdd content after generated code.None
groupSplit output into per-tag or per-path folders.None
↳ group.typeGroup operations by tag or URL path.Required with group
↳ group.nameCustomize output group names.camelCased tag or raw path segment
clientWhich registered client plugin the composables call.Auto-detected
infiniteAdd useInfiniteQuery composables for paginated reads.false
↳ infinite.queryParamChoose the query parameter that carries the cursor.'id'
↳ infinite.initialPageParamSet the first page parameter.0
↳ infinite.nextParamLocate the next-page cursor in the response.null
↳ infinite.previousParamLocate the previous-page cursor in the response.null
↳ infinite.cursorParamDeprecated cursor path. Use nextParam and previousParam instead.null
queryConfigure or disable query composables.{ methods: ['GET'], importPath: '@tanstack/vue-query' }
↳ query.methodsChoose which HTTP methods generate queries.['GET']
↳ query.importPathSet the module used for query imports.'@tanstack/vue-query'
queryKeyBuild the queryKey for each query composable.Built-in queryKeyTransformer
mutationConfigure or disable mutation composables.{ methods: ['POST', 'PUT', 'PATCH', 'DELETE'], importPath: '@tanstack/vue-query' }
↳ mutation.methodsChoose which HTTP methods generate mutations.['POST', 'PUT', 'PATCH', 'DELETE']
↳ mutation.importPathSet the module used for mutation imports.'@tanstack/vue-query'
mutationKeyBuild the mutationKey for each mutation composable.Built-in mutationKeyTransformer
hooksEmit use* composables on top of the factory helpers.false
includeKeep only operations that match.None
excludeSkip operations that match.[]
overrideApply different options per pattern.[]
resolverCustomize generated names and file paths.resolverVueQuery
macrosRewrite AST nodes before printing.[]

Option details

client

Selects which registered client plugin the composables call. A single registered client is auto-detected. Set client when several are registered.

Type'axios' | 'fetch'
Requiredfalse
'fetch'
Calls the operations generated by @kubb/plugin-fetch.
'axios'
Calls the operations generated by @kubb/plugin-axios.

infinite

Adds infinite-query output for cursor- or page-based pagination. Pass an object to configure how the cursor is read, or false (the default) to skip. Output is emitted for an operation only when it declares a query parameter matching infinite.queryParam and hooks is true. Without hooks: true, infinite produces no file at all, not even the factory.

TypePartial<Infinite> | false
Requiredfalse
Defaultfalse
infinite: {}, hooks: true
export function getPetsInfiniteQueryOptions(/* ... */) {
  return infiniteQueryOptions({ queryKey, queryFn, initialPageParam, getNextPageParam })
}

export function useGetPetsInfiniteQuery(/* ... */) {
  return useInfiniteQuery(getPetsInfiniteQueryOptions(/* ... */))
}

infinite.queryParam

Name of the query parameter that holds the page cursor.

Typestring
Requiredfalse
Default'id'

infinite.initialPageParam

Initial value for pageParam on the first fetch.

Typeunknown
Requiredfalse
Default0

infinite.nextParam

Path to the next-page cursor on the response, as dot notation ('pagination.next.id') or array form (['pagination', 'next', 'id']).

Typestring | Array<string> | null
Requiredfalse
Defaultnull

infinite.previousParam

Path to the previous-page cursor on the response, in the same dot or array form.

Typestring | Array<string> | null
Requiredfalse
Defaultnull

infinite.cursorParam

Deprecated path to the cursor field, read for both getNextPageParam and getPreviousPageParam when set. Use nextParam and previousParam instead.

Typestring | null
Requiredfalse
Defaultnull

infinite.getNextPageParam

Source of TanStack Query's getNextPageParam, inlined verbatim, for a next page that has to be computed rather than read from a field, such as '(lastPage) => (lastPage.hasNext ? lastPage.number + 1 : undefined)'. Takes precedence over nextParam and cursorParam. Type string | null, default null.

Without any of getNextPageParam, nextParam or cursorParam, the composable counts pages up from initialPageParam and stops on an empty array. That only works for responses that are arrays, so generation warns for an operation whose response is an object.

infinite.getPreviousPageParam

Source of TanStack Query's getPreviousPageParam, inlined verbatim. Takes precedence over previousParam and cursorParam. Type string | null, default null.

query

Decides which operations are treated as queries. The plugin generates a queryOptions factory for each match by default. Pass false to skip, or set hooks to also emit useQuery.

TypePartial<Query> | false
Requiredfalse
Default{ methods: ['GET'], importPath: '@tanstack/vue-query' }

query.methods

HTTP methods treated as queries. A matching operation generates a queryOptions factory instead of a mutation.

TypeArray<string>
Requiredfalse
Default['GET']

query.importPath

Module specifier for the generated import { queryOptions } from '...'.

Typestring
Requiredfalse
Default'@tanstack/vue-query'

queryKey

Builds the queryKey for each query composable. The callback receives the operation node, the active casing and the variant ('query' or 'infiniteQuery') and returns the key array. String values are inlined verbatim, so wrap literals in JSON.stringify(...). The default adds infinite: true to infinite keys so they never share a cache entry with the plain query.

Type(props: { node, casing, variant }) => Array<unknown>
Requiredfalse
DefaultBuilt-in queryKeyTransformer
queryKey: ({ node, variant }) => [JSON.stringify({ variant, operationId: node.operationId })]

mutation

Decides which operations are treated as mutations. The plugin generates a mutationKey helper for each match by default. Pass false to skip, or set hooks to also emit useMutation.

TypePartial<Mutation> | false
Requiredfalse
Default{ methods: ['POST', 'PUT', 'PATCH', 'DELETE'], importPath: '@tanstack/vue-query' }

mutation.methods

HTTP methods treated as mutations. A matching operation generates mutation output instead of a query.

TypeArray<string>
Requiredfalse
Default['POST', 'PUT', 'PATCH', 'DELETE']

mutation.importPath

Module specifier for the generated import { useMutation } from '...', emitted when hooks is set.

Typestring
Requiredfalse
Default'@tanstack/vue-query'

mutationKey

Builds the mutationKey for each mutation composable, useful for batching invalidations. It takes the same props as queryKey with variant: 'mutation' and inlines strings the same way, so wrap literals in JSON.stringify(...).

Type(props: { node, casing, variant }) => Array<unknown>
Requiredfalse
DefaultBuilt-in mutationKeyTransformer

hooks

Controls whether use* composables are emitted. The default false writes only the queryOptions, queryKey, and mutationKey factory helpers. Set true to also generate useQuery, useInfiniteQuery, and useMutation.

Typeboolean
Requiredfalse
Defaultfalse

infinite is gated on hooks too, writing nothing while hooks is false.

resolver

Overrides generated file and symbol names. Omitted members keep resolverVueQuery. The shared members (name, file, imports) and the this context are described under resolver.

TypeResolverPatch<ResolverVueQuery>
Requiredfalse
Partial override
type ResolverVueQueryPatch = {
  name?(name: string): string
  file?: {
    baseName?(params: { name: string; extname: string }): string
    path?(params: { baseName: string; output: Output }): string
  }
  imports?(options: ResolveImportsOptions): Array<ImportNode>
  query?: {
    name?(node: OperationNode): string
    optionsName?(node: OperationNode): string
    keyName?(node: OperationNode): string
    keyTypeName?(node: OperationNode): string
    clientName?(node: OperationNode): string
  }
  infiniteQuery?: { /* same members as query */ }
  mutation?: {
    name?(node: OperationNode): string
    keyName?(node: OperationNode): string
    typeName?(node: OperationNode): string
  }
}