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