Back to Calendar

Day 16 Remote Functions: Optimistic Updates

Even the fastest reindeer can't outrun network latency. When Santa's workshop dashboard feels sluggish because the server takes time to process updates, optimistic updates come to the rescue!

Building on yesterday's command example, we tackle the problem of slow responses. Instead of waiting for the server to confirm that a wish list item is processed, we update the UI immediately and let the server catch up.

Chain .updates() to your command call, pass in the query you want to update, and call .withOverride() on it. You receive the current state and return what the UI should show right now. The interface responds instantly — no more waiting for that strikethrough to appear!

The best part? Optimistic updates automatically revert when the request completes, whether it succeeds or fails. If something goes wrong, the UI snaps back to reality. Fast, smooth, and safe — just like Santa's sleigh on Christmas Eve!

Read the docs

Credits

Illustrations by Icons 8:

  • Santa Hat
  • Santa sleigh
  • Cookie
  • Heart
  • Santa face
  • Present
  • ID
  • Snowflake
  • Snow Globe
  • Question Mark
  • Fairy Lights
  • Piggy Bank
  • Globe
  • Present #2

Illustrations by Elisabet Guba:

  • Clock

Icons by Obra Icons

Challenges by Svelte Ambassadors:

  • Stanislav Khromov
  • Willow (GHOST)
  • Paolo Ricciuti

Santa Tracker Data by NORAD via Danielle Vass