Overview

In Next.js, Server Components are rendered entirely on the server. This approach supports both SSR (Server-Side Rendering) and SSG (Static Site Generation), offering enhanced performance, improved SEO, and flexible caching compared to client-side fetching.

Core Concepts

Server-Side Only

Rendering Methods

Caching Strategies

Example

The following example demonstrates a Server Component that fetches data before rendering:

// app/dashboard/page.tsx
export default async function Dashboard() {
  // Customize caching as needed.
  const res = await fetch("<https://api.example.com/data>", { cache: "no-cache" });
  const data = await res.json();

  return (
    <section>
      <h1>Data: {data.title}</h1>
    </section>
  );
}

When to Use

Advantages