Course contentsShow
← React
Lesson 644 of 2,39617. Common useEffect MistakesFree lesson

Server Components: Fetch Before Rendering

How async Server Components eliminate waterfalls by fetching data before sending HTML to the client.

Server Components: Fetch Before Rendering

What you'll learn: How async Server Components eliminate waterfalls by fetching data before sending HTML to the client.

The Old Way: Fetch After Rendering

With traditional client-side React, the browser receives a skeleton HTML file, downloads JavaScript, runs your component code, then your useEffect fires to fetch data. This creates a waterfall: render → hydrate → fetch → re-render with data. Every step waits for the previous one.

The Server Component Approach

Server Components can be async functions. They fetch data on the server before React generates any HTML. The server waits for all data to arrive, renders the component with real content, and sends complete HTML to the browser.

// This runs on the SERVER, not the client
async function UserProfile({ userId }) {
  // Fetch completes BEFORE rendering starts
  const user = await fetchUser(userId);
  
  return <h1>{user.name}</h1>;
}

The browser receives fully-rendered HTML with {user.name} already filled in. No spinner. No waterfall. No useEffect needed.

Why This Eliminates Waterfalls

The server can fetch multiple resources in parallel and wait for all of them before sending anything. The client gets a complete page in one shot. With client-side fetching, each step must wait for the previous JavaScript bundle, each useEffect fires sequentially, and nested components create cascading delays.

Key Takeaway: Async Server Components fetch data before rendering, sending complete HTML to the client and eliminating the multi-step waterfalls that plague client-side useEffect data fetching.