Data Fetching in RSC
Learn how to efficiently fetch data directly within Server Components to reduce client-side JavaScript bundles.
Why Fetch Data on the Server?
Welcome to data fetching in Next.js Server Components! Traditionally, data fetching often happened on the client-side, leading to heavier JavaScript bundles.
Server Components (RSCs) change this by allowing you to fetch data directly on the server, before any JavaScript is sent to the browser.
How Server Components Fetch Data
In a Server Component, you can use standard JavaScript async/await syntax with the native fetch API to get data.
- No need for client-side hooks like
useEffect. - Data fetching runs entirely on the server.
- The fetched data is rendered into HTML.