Nextjs Fundamentals · Data Fetching

Fetching in a Server Component

async Server Component + `fetch`

Fetching in a Server Component

Because a Server Component runs on the server, it can be an async function and await data directly. There is no loading state to wire up and no useEffect: the component simply suspends until its data is ready.

// app/blog/page.tsx
export default async function Page() {
  const data = await fetch('https://api.example.com/blog');
  const posts = await data.json();
  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  );
}

You can also reach a database or ORM directly, since that code never ships to the browser and can use secrets safely.

Two facts shape how this behaves. First, identical fetch requests in one render pass are memoised by React, so the same URL fetched in two components runs once. Second, a fetch is not cached by default: it blocks the page from rendering until it resolves. To cache a result, use the use cache directive; to avoid blocking, wrap the fetching component in <Suspense> so the rest of the page streams immediately.

The rule of thumb: fetch in the component that needs the data, close to the server-side source, and let the framework handle memoisation.

You are about to answer a short quiz on async Server Component + fetch.

  1. A Server Component can be an async function and await data directly.
  2. In Next.js 16, fetch requests are cached by default.
  3. Identical fetch requests in one render pass are ___ by React, so they run once.
  4. An uncached fetch blocks the page from rendering until the request completes.
  5. To cache a fetch result explicitly, add the ___ directive to the function.