What is the difference between server state and client state?

React data fetching and state libraries · Freshers and experienced

Model answer

Client state is owned by the browser: a modal being open, a form draft, a selected tab. Server state lives on a backend, can change without you knowing, and needs caching and syncing. Treating server data as plain client state leads to stale data and a lot of manual code.

Use a data-fetching library for server state and useState or a small store for client state.

Learn this topic

TanStack Query (React Query): Fetching, Caching and Updating Server Data in the course React.js Full Course: Beginner to Advanced.

Sign in to add your own answer.

More questions