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] a6be1cede9
ci: Version Packages (#12391)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
History 2026-11-01 11:04:19 +01:00
..
media feat: vue-query adapter (#4254) 2022-10-02 22:07:30 +02:00
src docs({react,preact,angular,solid,svelte,vue}-query): describe when the 'Defined' and 'Undefined' 'initialData' overloads are selected (#12460) 2026-10-30 16:41:25 +09:00
CHANGELOG.md ci: Version Packages (#12391) 2026-11-01 11:04:19 +01:00
oxlint.config.ts chore(oxlint.config): add 'vueConfig' with native 'vue' rules for 'vue-query' and 'vue-query-devtools' (#12450) 2026-10-29 15:25:01 +09:00
package.json ci: Version Packages (#12391) 2026-11-01 11:04:19 +01:00
README.md docs: use the dynamic README header endpoint (#11136) 2026-08-03 13:43:19 +02:00
root.oxlint.config.ts chore: replace eslint with oxlint (#11938) 2026-10-09 16:35:33 +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 test({query-devtools,react-query-devtools,preact-query-devtools,vue-query}): enable 'unstubGlobals' and 'unstubEnvs' instead of calling 'vi.unstubAllGlobals' and 'vi.unstubAllEnvs' manually (#12276) 2026-10-22 16:36:35 +09: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,
    })