Skip to main content
The useMutation hook is used to create, update, or delete data. Unlike queries, mutations are typically used to perform side effects on the server.

Import

Signature

Parameters

object
required
The mutation options object.
QueryClient
Override the default QueryClient.

Returns

object
The mutation result object.

Examples

Basic Usage

With Optimistic Updates

Using mutateAsync

With Callbacks

Serial Mutations with Scope

Notes

Unlike useQuery, mutations do not automatically execute. You must call mutate or mutateAsync to trigger them.
The mutate function does not return the mutation result. Use mutateAsync if you need to await the result.
Callbacks passed to mutate will override the callbacks defined in the hook options for that specific mutation call.