Sanity Library Reference Docs
    Preparing search index...

    Interface MutationHookResult<TInput, TResult>

    The value returned by a mutation-backed hook. The write-side counterpart to FetcherHookResult: local {mutate, isPending, error, data, reset} state around a core mutation action.

    interface MutationHookResult<TInput, TResult> {
        data: TResult | undefined;
        error: unknown;
        isPending: boolean;
        mutate: (input: TInput) => Promise<TResult>;
        reset: () => void;
    }

    Type Parameters

    • TInput
    • TResult
    Index

    Properties

    data: TResult | undefined

    The last successful server response, or undefined before the first success.

    error: unknown

    The most recent failure; cleared by the next mutate or reset.

    isPending: boolean

    A mutation is currently in flight.

    mutate: (input: TInput) => Promise<TResult>

    Runs the mutation. Resolves with the server response; rejects on failure (the failure is also captured in MutationHookResult.error, so a fire-and-forget caller should read error and an awaiting caller should try/catch).

    reset: () => void

    Clears state back to idle and abandons any in-flight result.