Skip to content
masterclass Buddy

T3 Stack · Concept

Optimistic updates

Optimistic updates change the UI before a mutation finishes. Save the old cached data, roll back on failure, and refresh from the server after the mutation settles.

Last updated

Syntax

api.post.create.useMutation({ onMutate, onError, onSettled })

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • tRPC
  • React Query
  • useMutation
  • useUtils
  • queryCache
  • invalidate

Source: tRPC • Create T3 App. Checked 2026-11-03.