What precisely is "server state"? #10602
Replies: 1 comment
-
|
Server state is data whose authoritative copy lives on a remote system (a database, an API, another service) and can only be accessed asynchronously. Your app holds a local snapshot of it, not the source of truth. Three properties make it different from regular state:
Client state is the opposite: modal open/closed, active tab, what's in a search box. You own it, it's synchronous, and it never goes stale on you. TanStack Query's job is bridging that gap: fetching the snapshot, tracking when it's stale, refreshing in the background, and sharing it across components without duplicate requests. Its tagline is "asynchronous state management", not "server state management". That framing is deliberate: "server" is shorthand for "the thing you don't own and can't access synchronously." A WebSocket feed, an IndexedDB read, or any other async source qualifies, as long as your local copy can diverge from the truth without your app being notified. The overview page does actually define this in the Motivation section, though it's easy to miss since it appears mid-page rather than called out like React's state definition:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The TanStack Query overview repeatedly mentions "server state" without ever defining what exactly that is.
React has an entire page devoted to state, with an opening paragraph that concisely defines it.
So what is the definition of server state, from TanStack Query's perspective?
Beta Was this translation helpful? Give feedback.
All reactions