|
Download react-query/docs/framework/vue/installation.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/vue/installation.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/vue/installation.md
-
curl -L -o installation.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/vue/installation.md
1.53 kB
metadata
id: installation
title: Installation
You can install Vue Query via NPM.
NPM
npm i @tanstack/vue-query
or
pnpm add @tanstack/vue-query
or
yarn add @tanstack/vue-query
or
bun add @tanstack/vue-query
Wanna give it a spin before you download? Try out the basic example!
Vue Query is compatible with Vue 2.x and 3.x
If you are using Vue 2.6, make sure to also setup @vue/composition-api
Vue Query Initialization
Before using Vue Query, you need to initialize it using VueQueryPlugin
import { VueQueryPlugin } from '@tanstack/vue-query'
app.use(VueQueryPlugin)
Use of Composition API with <script setup>
All examples in our documentation use <script setup> syntax.
Vue 2 users can also use that syntax using this plugin. Please check the plugin documentation for installation details.
If 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.
<script setup>
import { useQuery } from '@tanstack/vue-query'
const { isPending, isFetching, isError, data, error } = useQuery({
queryKey: ['todos'],
queryFn: getTodos,
})
</script>
<template>...</template>