- All Courses
- Next.js for Production
- Data Fetching and Caching
- Fetching data in Server Components
Fetching data in Server Components
A Server Component can be an async function, so fetching is just awaiting inside the component that needs the data.
Overview
The component is the data layer
A Server Component can be an async function, so fetching is just awaiting inside the component that needs the data. There is no separate loader, no client-side effect, and no serialisation step you have to write yourself.
Because the code never reaches the browser, the component can hold a database connection or an API token directly. That is the single biggest structural advantage over fetching in a client effect.
The trap is sequencing. Awaiting one request and then another inside the same component creates a waterfall even when the two are unrelated. Start both promises first and await them together when neither depends on the other.
In this lesson you will:
- Fetch directly in an async Server Component
- Keep credentials off the client
- Avoid the request waterfall
Resources
Notes are not saved yet — they clear when you leave this page.
Route groups and parallel routes
11m
Request memoization and the data cache
6m