Open History to see the last commit
1---
2id: useIsFetching
3title: useIsFetching
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function useIsFetching(filters?: Omit<QueryFilters<readonly unknown[]>, "fetchStatus">, queryClient?: QueryClient): ReactiveValue<number>;
10```
11β
12Defined in: [packages/svelte-query/src/useIsFetching.svelte.ts:40](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/useIsFetching.svelte.ts#L40)
13β
14The `useIsFetching` function returns the `number` of the queries that your application is loading or
15fetching in the background (useful for app-wide loading indicators).
16β
17## Parameters
18β
19### filters?
20β
21`Omit`\<[`QueryFilters`](../interfaces/QueryFilters.md)\<readonly `unknown`[]\>, `"fetchStatus"`\>
22β
23[QueryFilters](../interfaces/QueryFilters.md) to narrow down which queries to count. Omit to count every fetching
24query.
25β
26<a id="filters-properties"></a>
27β
28#### `filters` properties
29β
30Built from [`QueryFilters`](../interfaces/QueryFilters.md#properties). See the type above for what it changes.
31β
32### queryClient?
33β
34[`QueryClient`](../classes/QueryClient.md)
35β
36Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
37be used.
38β
39## Returns
40β
41`ReactiveValue`\<`number`\>
42β
43A reactive value β read `.current` to get how many matching queries are currently fetching.
44β
45## Examples
46β
47```svelte
48<script lang="ts">
49 import { useIsFetching } from '@tanstack/svelte-query'
50β
51 // How many queries matching the posts prefix are fetching?
52 const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
53</script>
54β
55{#if isFetchingPosts.current}
56 <span>Refreshing posts...</span>
57{/if}
58```
59β
60A global loading indicator for any query fetching in the background, not just the ones on screen:
61```svelte
62<script lang="ts">
63 import { useIsFetching } from '@tanstack/svelte-query'
64β
65 const isFetching = useIsFetching()
66</script>
67β
68{#if isFetching.current}
69 <div>Queries are fetching in the background...</div>
70{/if}
71```