0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
query/packages/vue-query
github-actions[bot] 19ccf2794b
ci: Version Packages (#11339)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
History 2026-09-16 09:03:53 +02:00
..
media feat: vue-query adapter (#4254) 2022-10-02 22:07:30 +02:00
src chore(*): use eslint description syntax for grandfathered 'no-restricted-syntax' disables (#11508) 2026-09-16 10:43:43 +09:00
CHANGELOG.md ci: Version Packages (#11339) 2026-09-16 09:03:53 +02:00
eslint.config.js chore: update eslint-plugin-vue (#9691) 2025-09-26 22:02:02 +10:00
package.json ci: Version Packages (#11339) 2026-09-16 09:03:53 +02:00
README.md docs: use the dynamic README header endpoint (#11136) 2026-08-03 13:43:19 +02:00
root.eslint.config.js chore: composite monorepo (#8560) 2025-01-27 15:58:10 +01:00
root.tsdown.config.js chore: tsup -> tsdown (#11222) 2026-08-18 15:19:43 +02:00
test-setup.ts feat(vue-query): support injectable contexts (#5886) 2023-08-30 10:11:28 +02:00
tsconfig.json docs(query-core): add JSDoc across the package and expose it in generated reference docs (#11438) 2026-09-07 18:22:38 +02:00
tsconfig.legacy.json chore: composite monorepo (#8560) 2025-01-27 15:58:10 +01:00
tsconfig.prod.json fix(build): exclude config files from production DTS rollup (#10358) 2026-04-01 09:40:46 +02:00
tsdown.config.ts chore: tsup -> tsdown (#11222) 2026-08-18 15:19:43 +02:00
vite.config.ts chore: update to ts 7 and move cut-off to 5.6 (#11212) 2026-08-17 22:50:18 +02:00

TanStack Vue Query
[![Vue Query logo](https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.png)](https://github.com/TanStack/query/tree/main/packages/vue-query)

npm version npm license bundle size npm

Vue Query

Hooks for fetching, caching and updating asynchronous data in Vue.

Support for Vue 2.x via vue-demi

Documentation

Visit https://tanstack.com/query/latest/docs/vue/overview

Quick Features

  • Transport/protocol/backend agnostic data fetching (REST, GraphQL, promises, whatever!)
  • Auto Caching + Refetching (stale-while-revalidate, Window Refocus, Polling/Realtime)
  • Parallel + Dependent Queries
  • Mutations + Reactive Query Refetching
  • Multi-layer Cache + Automatic Garbage Collection
  • Paginated + Cursor-based Queries
  • Load-More + Infinite Scroll Queries w/ Scroll Recovery
  • Request Cancellation
  • (experimental) Suspense + Fetch-As-You-Render Query Prefetching
  • (experimental) SSR support
  • Dedicated Devtools
  • npm bundle size (depending on features imported)

Quick Start

  1. Install vue-query

    $ npm i @tanstack/vue-query
    

    or

    $ pnpm add @tanstack/vue-query
    

    or

    $ yarn add @tanstack/vue-query
    

    or

    $ bun add @tanstack/vue-query
    

    If you are using Vue 2.6, make sure to also setup @vue/composition-api

  2. Initialize Vue Query via VueQueryPlugin

    import { createApp } from 'vue'
    import { VueQueryPlugin } from '@tanstack/vue-query'
    
    import App from './App.vue'
    
    createApp(App).use(VueQueryPlugin).mount('#app')
    
  3. Use query

    import { defineComponent } from 'vue'
    import { useQuery } from '@tanstack/vue-query'
    
    export default defineComponent({
      name: 'MyComponent',
      setup() {
        const query = useQuery({ queryKey: ['todos'], queryFn: getTodos })
    
        return {
          query,
        }
      },
    })
    
  4. If you need to update options on your query dynamically, make sure to pass them as reactive variables

    const id = ref(1)
    const enabled = ref(false)
    
    const query = useQuery({
      queryKey: ['todos', id],
      queryFn: () => getTodos(id),
      enabled,
    })