Open History to see the last commit
1---
2id: installation
3title: Installation
4---
5β
6You can install Vue Query via [NPM](https://npmjs.com).
7β
8### NPM
9β
10```bash
11$ npm i @tanstack/vue-query
12# or
13$ pnpm add @tanstack/vue-query
14# or
15$ yarn add @tanstack/vue-query
16```
17β
18> Wanna give it a spin before you download? Try out the [basic](/query/v4/docs/vue/examples/vue/basic) example!
19β
20Vue Query is compatible with Vue 2.x and 3.x
21β
22> If you are using Vue 2.6, make sure to also setup [@vue/composition-api](https://github.com/vuejs/composition-api)
23β
24### Vue Query Initialization
25β
26Before using Vue Query, you need to initialize it using `VueQueryPlugin`
27β
28```tsx
29import { VueQueryPlugin } from "@tanstack/vue-query";
30β
31app.use(VueQueryPlugin)
32```
33β
34### Use of Composition API with `<script setup>`
35β
36All examples in our documentation use [`<script setup>`](https://staging.vuejs.org/api/sfc-script-setup.html) syntax.
37β
38Vue 2 users can also use that syntax using [this plugin](https://github.com/antfu/unplugin-vue2-script-setup). Please check the plugin documentation for installation details.
39β
40If you are not a fan of `<script setup>` syntax, you can easily translate all the examples into normal Composition API syntax by moving the code under `setup()` function and returning the values used in the template.
41β
42```vue
43<script setup>
44import { useQuery } from "@tanstack/vue-query";
45β
46const { isLoading, isFetching, isError, data, error } = useQuery({
47 queryKey: ['todos'],
48 queryFn: getTodos,
49})
50</script>
51β
52<template>...</template>
53```