Server State vs Client State

Server state has different semantics from local UI state. It has ownership outside the browser, can become stale, may need caching, deduplication, retries, pagination, invalidation, optimistic updates, and synchronization.

Treating server data as a giant useState object often creates a lot of manual lifecycle code. A dedicated data-fetching/cache library can provide a more appropriate model.

Client state answers questions such as 'is the modal open?' Server state answers questions such as 'what data does the server currently say exists?'

Separate categories

A cache of remote data is not the same thing as a global UI store. Their invalidation, freshness, and ownership rules differ.

Key Takeaways
  • Remote data has freshness and invalidation concerns.
  • Avoid manually rebuilding a server-state cache unless requirements are simple.
  • Keep ephemeral UI state separate from remote data.