Overview

A Server Component renders ahead of time in a server environment, can await databases and read files directly, and adds none of its code to the browser bundle. In the Next.js App Router every component is a Server Component by default. Add "use client" only for state, effects, event handlers, or browser APIs.

Rules

  • "use client" marks a boundary in the module graph: that file and everything it imports join the client bundle. Put it on small interactive leaves, not on layouts.
  • A Client Component cannot import a Server Component, but it can receive one as children or another prop, already rendered on the server.
  • Props that cross the boundary must be serializable. Keep secrets in server-only modules (import "server-only").
  • Server Components cannot use state, effects, or context. React 19 Server Components are stable, but the bundler APIs beneath them are not semver-stable, so use them through a framework.
// app/products/page.tsx: a Server Component, no "use client"
export default async function ProductsPage() {
  const products = await db.query("SELECT * FROM products LIMIT 50")
  return <ProductList products={products} />
}