API Reference

useConvexMutation

Reference for the shared mutation composable.

useConvexMutation wraps a generated Convex mutation and tracks pending state and the latest error.

Import

Nuxt
const { mutate } = useConvexMutation(api.tasks.add)
Vue
import { useConvexMutation } from 'vue-convex'

Signature

function useConvexMutation<Mutation extends FunctionReference<'mutation'>>(
  mutation: Mutation,
  options?: {
    optimisticUpdate?: OptimisticUpdate<FunctionArgs<Mutation>>
  },
): {
  mutate: (args: MaybeRefOrGetter<FunctionArgs<Mutation>>) => Promise<FunctionReturnType<Mutation>>
  error: Ref<Error | null>
  isPending: ComputedRef<boolean>
}

Parameters

ParameterTypeMeaning
mutationFunctionReference<'mutation'>Generated Convex mutation reference
options.optimisticUpdateOptimisticUpdate<FunctionArgs<Mutation>>Optional optimistic cache update forwarded to the Convex client

Return value

FieldTypeMeaning
mutate(args) => Promise<T>Executes the mutation
errorRef<Error | null>Latest mutation error
isPendingComputedRef<boolean>true while one or more calls are in flight

Behavior

  • Requires a connected realtime client
  • Accepts reactive args through MaybeRefOrGetter
  • Supports optimistic updates through the underlying Convex client
Copyright © 2026