@vue/composition-api) and Vue 3.
Installation
For Vue 2, you also need to install
@vue/composition-api:Setup
Install the Vue Query plugin in your app:Plugin Options
Core Composables
useQuery
Fetch and cache data with theuseQuery composable:
Reactive Query Keys
Vue Query fully supports Vue’s reactivity system. Useref or computed for dynamic queries:
useMutation
Perform side effects with mutations:useInfiniteQuery
Implement infinite scrolling:Reactivity Patterns
MaybeRef and MaybeRefDeep
Vue Query accepts reactive values throughout the options:Watching Query Results
Query results are reactive refs that work with Vue’swatch:
Vue 2 vs Vue 3
Vue 2 with Composition API
Vue 3 with Script Setup
The API is identical between Vue 2 and Vue 3. The only difference is how you access the Composition API.
Advanced Features
useQueries
Execute multiple queries in parallel:Query Options Factory
useMutationState
Track all mutations globally:useIsFetching
Show a global loading indicator:Shallow Option
Control ref unwrapping with theshallow option:
TypeScript
Full TypeScript support with proper type inference:DevTools Integration
Vue Query integrates with Vue DevTools:SSR Support
For Nuxt or other SSR frameworks:Vue-Specific Gotchas
Ref Unwrapping: Vue Query automatically unwraps refs in query options, but query results are returned as refs. Always access them with
.value in script or directly in templates.