This episode traces the evolution of data fetching in React, from the manual useEffect plus fetch pattern to the birth of TanStack Query. You also understand the concept of server state that distinguishes it from client state, as well as this library's position in the data fetching ecosystem.

Every great library is born from pain. TanStack Query is no exception: it was born because a generation of React developers had to rewrite the same code — fetch, loading, error, then re-render — in every single component. Before you understand how to use it, it is important to know why this library exists and what problems it solves.
Episode 1 traces the evolution of data fetching in React, from the painful manual pattern to an automatic cache system. You will also understand the key concept that justifies this library's existence: server state and how it differs from client state.
In the early days of React, almost every application fetched data the same way: calling fetch inside useEffect, storing the result in useState, and managing loading and error manually:
function Profile({ userId }) {
const [user, setUser] = useState(null)
const [loading, setLoading] = useState(true)
useEffect(() => {
setLoading(true)
fetch(`/api/users/${userId}`)
.then((res) => res.json())
.then((data) => {
setUser(data)
setLoading(false)
})
}, [userId])
if (loading) return <p>Memuat...</p>
return <h1>{user.name}</h1>
}The problem isn't just the number of lines. This pattern has no cache, no deduplication, no consistent error handling, and no way to re-sync stale data. Every component that needs the same user has to fetch it again.
In 2019, Tanner Linsley released react-query. The idea was simple but revolutionary: don't store server data in component state, but in a global cache managed by the library. Components simply declare what data they need, and the library handles fetching, caching, and updates.
As more frameworks gained support, react-query was renamed to TanStack Query and reorganized into the TanStack monorepo. The TanStack name reflects its new mission: not just a React library, but a family of data-fetching libraries for many frameworks. Version v5 was released in 2023 and has been continuously updated through 2026 with improvements and new features.
The key to understanding lies in the term server state. Data that comes from the server — lists of users, posts, account balances — has characteristics that local state like input text or scroll position doesn't have:
That is why mimicking local storage for server data is the wrong approach. TanStack Query treats server data as a cache: stored, given an expiration time, and re-synced when needed.
Everything that used to be done manually is now automatic:
As a result, loading and error boilerplate shrinks dramatically, and synchronizing state between components no longer needs to be managed manually.
TanStack Query is very lightweight — about 13 KB (gzipped) for the React binding — and the core logic lives in the @tanstack/query-core package, which is independent of any framework. The React, Vue, and Svelte adapters are just thin layers on top of the same core.
@tanstack/query-core → caching logic (framework-agnostic)
↓
@tanstack/react-query → hooks for React
@tanstack/vue-query → composables for Vue
@tanstack/solid-query → primitives for SolidThe @tanstack/query-core → @tanstack/react-query diagram illustrates the dependency flow: all adapters use the same core, so the knowledge you gain from React also applies to other frameworks — episode 19 will discuss this.
Before closing this episode, it is important to know that TanStack Query isn't the only solution. There is SWR from Vercel, RTK Query from the Redux ecosystem, Apollo Client for GraphQL, and of course manual fetch as a baseline. Each has a different philosophy: SWR focuses on staleness and being lightweight, RTK Query integrates tightly with Redux Toolkit, and Apollo handles complex GraphQL caching.
An in-depth comparison and a guide on when to choose each will be fully discussed in episode 22. For now, remember: TanStack Query excels at flexibility, finely configurable caching, and a broad ecosystem of adapters.
Tip
Don't rush to compare benchmarks or star counts. What matters more is matching your project's needs with each library's strengths — that decision will be easier once you master TanStack Query more deeply.
Episode 1 laid out the philosophical reason for TanStack Query's existence: server data is a cache, not local state. You now understand the journey from the manual useEffect plus fetch pattern, the birth of react-query in 2019, the rebrand to TanStack Query, and the server state problems it tries to solve.
Key takeaways:
useEffect is repetitive and full of boilerplate.In the next episode, episode 2, we will discuss the core concepts and key architecture of TanStack Query — the query versus mutation model, how query keys work toward the cache, and the main components such as QueryClient and QueryClientProvider. This is the mental foundation you will use in every episode that follows.