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