Open History to see the last commit
1---
2id: useQueryClient
3title: useQueryClient
4redirect_from:
5 - framework/vue/reference/useQueryClient
6---
7β
8```ts
9function useQueryClient(id?: string): QueryClient;
10```
11β
12Defined in: [packages/vue-query/src/useQueryClient.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueryClient.ts#L27)
13β
14Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
15`setup()` or another function that supports an injection context.
16β
17## Parameters
18β
19### id?
20β
21`string` = `''`
22β
23The `queryClientKey` passed to `VueQueryPlugin` β only needed when multiple `QueryClient`s are
24installed in the same app.
25β
26## Returns
27β
28[`QueryClient`](../classes/QueryClient.md)
29β
30The installed `QueryClient`.
31β
32## Throws
33β
34If called outside an injection context, or if no `QueryClient` was installed via
35`VueQueryPlugin`.
36β
37## Example
38β
39```vue
40<script setup lang="ts">
41import { useQueryClient } from '@tanstack/vue-query'
42β
43const queryClient = useQueryClient()
44β
45function invalidate() {
46 queryClient.invalidateQueries({ queryKey: ['todos'] })
47}
48</script>
49```