Skip to catalogue

132

client state vs server state

Server state is cached data from someone else. Client state is the draft, the tab, the open menu. Do not put both in one store.

What is client state vs server state?

Server state has a source of truth elsewhere: it can be stale, refetched, and shared. Client state exists only in this session: form drafts, selection, whether a popover is open. Treating a server record as a mutable global is how you lose refreshes and overwrite other people’s edits.

Why does client state vs server state matter when vibe coding?

Models copy the API response into a global store and edit it in place. Refetch clobbers the draft, or the draft never hits the server. Name the two and the boundary.

How do you do client state vs server state?

Fetch cache for server data. Local state for the draft. Submit the draft. On success, update the cache from the response. Do not make the cache the form.

How do you ask a model for client state vs server state?

Keep server state for (resource) in the query cache. Keep the draft in local form state. Do not edit the cached record in place. Submit, then replace the cache from the response.

What goes wrong with client state vs server state?

A global store that is both. Every keystroke notifies the whole app and you still do not know what to send.

adjacent