Open History to see the last commit
1---
2id: useIsFetching
3title: useIsFetching
4redirect_from:
5 - framework/vue/reference/useIsFetching
6---
7β
8<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
9β
10```ts
11function useIsFetching(fetchingFilters?: UseIsFetchingFilters, queryClient?: QueryClient): Ref<number>;
12```
13β
14Defined in: [packages/vue-query/src/useIsFetching.ts:55](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useIsFetching.ts#L55)
15β
16The `useIsFetching` composable returns a `ref` to the `number` of the queries that your application is
17loading or fetching in the background (useful for app-wide loading indicators).
18β
19`fetchingFilters` may be a plain object, `MaybeRefDeep`, or a reactive getter (`() => ({ ... })`) β pass a
20getter if the filters themselves depend on other reactive state.
21β
22## Parameters
23β
24### fetchingFilters?
25β
26[`UseIsFetchingFilters`](../type-aliases/UseIsFetchingFilters.md) = `{}`
27β
28The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries.
29β
30### queryClient?
31β
32[`QueryClient`](../classes/QueryClient.md)
33β
34Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
35will be used.
36β
37## Returns
38β
39`Ref`\<`number`\>
40β
41A `ref` to the `number` of the queries that your application is currently loading or fetching in
42the background.
43β
44## Examples
45β
46```vue
47<script setup lang="ts">
48import { useIsFetching } from '@tanstack/vue-query'
49β
50// How many queries matching the posts prefix are fetching?
51const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
52</script>
53β
54<template>
55 <span v-if="isFetchingPosts">Refreshing posts...</span>
56</template>
57```
58β
59A global loading indicator for any query fetching in the background, not just the ones on screen:
60```vue
61<script setup lang="ts">
62import { useIsFetching } from '@tanstack/vue-query'
63β
64const isFetching = useIsFetching()
65</script>
66β
67<template>
68 <div v-if="isFetching">Queries are fetching in the background...</div>
69</template>
70```