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