Skip to content
qt

Advanced

Optimistic Updates + Server Confirmation

When you add a todo, it appears instantly in amber as an 'optimistic' entry. Once the server confirms it via SSE, the item transitions to a green 'confirmed' state before settling into the list.

What to watch for

  • Add a todo — it appears instantly in amber (optimistic)
  • Within ~500ms the item turns green (server confirmed via SSE)
  • The confirmed badge fades after 1.5 seconds
  • On error, the optimistic entry disappears (rolled back)
View Source

Todo List

  • No todos yet.

Add todo

Two-phase lifecycle

Phase 1 — Optimistic

Item appears immediately in the UI. Rendered from local state — no server round-trip yet.

Phase 2 — Confirmed

Server mutation succeeds. SSE event triggers a query refetch. The real item replaces the optimistic placeholder.

Error — Rollback

If the mutation fails, the optimistic entry is removed and the cache is restored.