0
Challenge · 11Data & Reads

Async data fetching in Server Components

Dataused in ~100% of apps

This is where most React developers fight Next.js instead of using it. You reach for useEffect + useState to load data — the only pattern your client-side training ever showed you — and you get a flash of empty content, an extra round-trip, and a page Google can't read. In the App Router the component itself can be async: you await your data on the server, before any HTML is sent.

Core idea. A Server Component can be an `async function`. You `await` your database query or `fetch` directly in the component body, and the awaited data is baked into the HTML on the server — no loading spinner, no useEffect, no client round-trip for the initial render. `useEffect` is for data that changes on the client after load (live updates, user-triggered refetches), not for the first paint.
Playground, this isn't a screenshot
current stateIDLE
idle→loading→success→error
what the user sees
No data yet
press Load feed to start a request
request log (top → bottom)
Press Load feed. Then press it again while loading to watch the first request abort.

idle → loading → success or error — every fetch moves through this machine. Re-trigger while loading and the older request is aborted so a stale response can never overwrite a newer one.

↑ play a little first, then dig in