Open History to see the last commit
1---
2id: VueQueryPlugin
3title: VueQueryPlugin
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9const VueQueryPlugin: object;
10```
11β
12Defined in: [packages/vue-query/src/vueQueryPlugin.ts:75](https://github.com/TanStack/query/blob/main/packages/vue-query/src/vueQueryPlugin.ts#L75)
13β
14Installs a `QueryClient` on the Vue app, making it available to every descendant component through
15`useQueryClient` β the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
16instead of a wrapping component.
17β
18## Type Declaration
19β
20### install
21β
22```ts
23install: (app: any, options: VueQueryPluginOptions) => void;
24```
25β
26#### Parameters
27β
28##### app
29β
30`any`
31β
32##### options?
33β
34[`VueQueryPluginOptions`](../type-aliases/VueQueryPluginOptions.md) = `{}`
35β
36#### Returns
37β
38`void`
39β
40## Examples
41β
42```ts
43import { createApp } from 'vue'
44import { VueQueryPlugin } from '@tanstack/vue-query'
45β
46const app = createApp(App)
47app.use(VueQueryPlugin)
48```
49β
50Pass a `queryClient` you constructed yourself β useful for SSR, where you need a fresh `QueryClient` per
51request, or when the same instance also needs to be used outside of Vue components:
52```ts
53import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
54β
55const queryClient = new QueryClient()
56app.use(VueQueryPlugin, { queryClient })
57```
58β
59Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
60```ts
61app.use(VueQueryPlugin, {
62 queryClientConfig: {
63 defaultOptions: { queries: { staleTime: 5 * 1000 } },
64 },
65})
66```