Open History to see the last commit
1---
2id: useIsMutating
3title: useIsMutating
4---
5β
6# Function: useIsMutating()
7β
8```ts
9function useIsMutating(
10 host,
11 filters,
12 queryClient?): IsMutatingAccessor;
13```
14β
15Defined in: [packages/lit-query/src/useIsMutating.ts:147](https://github.com/TanStack/query/blob/main/packages/lit-query/src/useIsMutating.ts#L147)
16β
17Creates a Lit reactive controller that tracks how many matching mutations are
18currently pending.
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)\<`MutationFilters`\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}`
36β
37Mutation filters, or a getter that returns mutation 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[`IsMutatingAccessor`](../type-aliases/IsMutatingAccessor.md)
49β
50An accessor for the current number of matching pending mutations.
51β
52## Example
53β
54```ts
55import { LitElement, html } from 'lit'
56import { useIsMutating } from '@tanstack/lit-query'
57β
58class MutationStatus extends LitElement {
59 private readonly savesPending = useIsMutating(this, {
60 mutationKey: ['save-project'],
61 })
62β
63 render() {
64 return html`<span>${this.savesPending()} saves pending</span>`
65 }
66}
67```