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
11npm i @tanstack/vue-query
12```
13β
14or
15β
16```bash
17pnpm add @tanstack/vue-query
18```
19β
20or
21β
22```bash
23yarn add @tanstack/vue-query
24```
25β
26or
27β
28```bash
29bun add @tanstack/vue-query
30```
31β
32> Wanna give it a spin before you download? Try out the [basic](../examples/basic) example!
33β
34Vue Query is compatible with Vue 2.x and 3.x
35β
36> If you are using Vue 2.6, make sure to also setup [@vue/composition-api](https://github.com/vuejs/composition-api)
37β
38### Vue Query Initialization
39β
40Before using Vue Query, you need to initialize it using `VueQueryPlugin`
41β
42```tsx
43import { VueQueryPlugin } from '@tanstack/vue-query'
44β
45app.use(VueQueryPlugin)
46```
47β
48### Use of Composition API with `<script setup>`
49β
50All examples in our documentation use [`<script setup>`](https://staging.vuejs.org/api/sfc-script-setup.html) syntax.
51β
52Vue 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.
53β
54If 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.
55β
56```vue
57<script setup>
58import { useQuery } from '@tanstack/vue-query'
59β
60const { isPending, isFetching, isError, data, error } = useQuery({
61 queryKey: ['todos'],
62 queryFn: getTodos,
63})
64</script>
65β
66<template>...</template>
67```