Skip to content
Prompt Words
History

Optimistic update

Also called: optimistic UI, instant update, update first, confirm later.

The screen shows the result of your action right away, before the server has confirmed it. If the server then says no, the screen goes back to how it was and tells you it didn't work.

Tap the heart: it fills at once, and the server answers 1.2 s later. Turn on “Server fails” to see the like roll back.

Idle

Say it in a prompt

When the user taps Like, fill the heart and add 1 to the count immediately, then send POST /posts/:id/like. If the request fails or takes longer than 5 s, put the heart and the count back to what they were and show "Couldn't save your like" under the post for 4 s.

Seen on

  • React: The useOptimistic hook shows a temporary value while a request is running; the docs use a like button as the example.
  • TanStack Query: Its optimistic updates guide saves the old data in onMutate and puts it back in onError when the request fails.

You might describe it as

  • like button that changes instantly without waiting for the server
  • the heart fills right away even on slow internet
  • show the change first and undo it if saving fails