Course contentsShow
← React
Lesson 1573 of 2,39638. Server Components FundamentalsFree lesson

Client-Side Data Fetching Still Exists

When client components need dynamic data (user interactions, real-time), TanStack Query patterns remain necessary.

Client-Side Data Fetching Still Exists

What you'll learn: Server Components don't eliminate client-side data fetching—they complement it for interactive, real-time scenarios.

The Reality Check

With all the excitement around Server Components fetching data directly, you might think client-side data fetching is obsolete. It's not. Server Components handle initial, static-ish data beautifully, but the moment you need user-driven, dynamic, or real-time updates, you're back to client-side fetching.

When Client-Side Fetching Is Still Necessary

Consider these scenarios:

User interactions: A search box that filters results as you type needs immediate, client-side data fetching. The server component can't respond to every keystroke.

Real-time updates: A chat interface, live notifications, or a stock ticker require continuous client-side connections (WebSockets, polling, or subscriptions).

Authenticated, personalized flows: After a user logs in, you might need to fetch their preferences, shopping cart, or dashboard metrics—data that changes frequently based on their actions.

Infinite scroll or pagination: Loading the next page of results as users scroll is a client-side concern.

The Right Tool for the Job

Server Components fetch initial data efficiently. Client components (with 'use client') handle everything interactive. Tools like TanStack Query remain essential for:

  • Caching user-triggered requests
  • Managing loading/error states in interactive contexts
  • Handling mutations and optimistic updates
  • Synchronizing client-side state across components

The Mental Model

Think of Server Components as your first paint—they deliver the initial HTML with data baked in. Client-side fetching is your reactive layer—responding to what users do after the page loads.

Key Takeaway: Server Components eliminate initial render data fetching, not all data fetching. Client-side patterns (TanStack Query, custom hooks) remain critical for dynamic, interactive experiences.