Open History to see the last commit
1---
2id: useIsFetching
3title: useIsFetching
4---
5β
6# Function: useIsFetching()
7β
8```ts
9function useIsFetching(
10 host,
11 filters,
12 queryClient?): IsFetchingAccessor;
13```
14β
15Defined in: [packages/lit-query/src/useIsFetching.ts:147](https://github.com/TanStack/query/blob/main/packages/lit-query/src/useIsFetching.ts#L147)
16β
17Creates a Lit reactive controller that tracks how many matching queries are
18currently fetching.
19β
20When `filters` is a function, it is re-read during host updates so the count
21can follow reactive host state. If `queryClient` is omitted, the controller
22resolves the client from the nearest connected `QueryClientProvider`.
23β
24## Parameters
25β
26### host
27β
28`ReactiveControllerHost`
29β
30The Lit reactive controller host that owns the cache
31subscription.
32β
33### filters
34β
35[`Accessor`](../type-aliases/Accessor.md)\<`QueryFilters`\<readonly `unknown`[]\>\> = `{}`
36β
37Query filters, or a getter that returns query filters.
38β
39### queryClient?
40β
41`QueryClient`
42β
43Optional explicit query client. Provide this for
44controllers that should not resolve a client from Lit context.
45β
46## Returns
47β
48[`IsFetchingAccessor`](../type-aliases/IsFetchingAccessor.md)
49β
50An accessor for the current number of matching fetching queries.
51β
52## Example
53β
54```ts
55import { LitElement, html } from 'lit'
56import { useIsFetching } from '@tanstack/lit-query'
57β
58class TodosStatus extends LitElement {
59 private readonly todosFetching = useIsFetching(this, {
60 queryKey: ['todos'],
61 })
62β
63 render() {
64 return html`<span>${this.todosFetching()} active todo fetches</span>`
65 }
66}
67```