StackPractices
advanced By Mathias Paulenko

Complete Guide to React Server Components: RSC Architecture

A deep dive into React Server Components: the RSC payload, server-client boundaries, data loading, streaming, Next.js caching, and server actions.

Introduction

If you’ve shipped a React single-page app, you know the drill. The browser downloads a bundle, React mounts, useEffect fires, and only then does data start loading, often as a waterfall of requests where each step waits on the previous one. A page that’s 90% static text still pays the full JavaScript tax, and anything sensitive has to hide behind an API route you build, secure, and maintain as a separate surface.

React Server Components (RSC) flip that model. Components render on the server, fetch their own data, and ship a serialized description of the finished UI instead of the code that produced it. Interactive pieces stay client-side, but they become the exception rather than the rule. In the Next.js App Router, where RSC is the default rendering model, a page can read from your database during render and still stream interactive islands to the browser.

This guide assumes you know React hooks and have touched the App Router. It covers what RSC actually is (it’s not SSR, and the difference matters more than most tutorials admit), where the server-client boundary lives, how data loading and caching behave in Next.js 15 and later, and how server actions replace most of what you’d otherwise build as API routes. For the wider React 19 feature set (use(), the React Compiler, document metadata), see the complete guide to React 19 features.

What React Server Components Actually Are

Server Components are a new component type that renders ahead of bundling, in an environment separate from the browser. React’s own docs describe them as rendering “ahead of time, before bundling, in an environment separate from your client app” (React docs: Server Components). They stabilized in React 19, and in Next.js App Router every component is a Server Component unless you opt out with "use client".

Here’s the part that trips people up: a Server Component doesn’t send HTML to the browser. It sends the RSC payload: a serialized description of the rendered tree produced by React’s Flight protocol. That payload contains the rendered output, references to Client Components by module ID, and placeholders for async work still in flight. Next.js then combines it with prerendered HTML so the page paints fast, and the client uses the flight data to hydrate only the interactive parts. So when someone says “RSC sends HTML instead of JavaScript,” they’re describing the effect, not the mechanism.

That distinction explains the second big rule: Server Components can be async and await directly in render. There’s no useEffect dance, no loading state, no setState-after-fetch. The component suspends while its promise resolves and React picks up rendering where it left off. If you’ve ever chained useEffect → setLoading → setData → setLoading(false), this is what replaces it.

It also explains why hooks don’t exist on the server side. useState, useEffect, and useContext all assume a live component instance that persists between renders, attached to a DOM. A Server Component renders once, its output gets serialized, and it’s done. There’s no instance to hold state and no browser to synchronize effects with. Calling useState in a Server Component isn’t a runtime error you can catch; it’s a bundler-level impossibility.

Version requirements are worth stating plainly because the docs are scattered across several releases. You need React 19 or later and a framework that supports the RSC bundler contract; in practice, that’s the Next.js App Router (14.2+ recommended, current releases fully supported). The newer hooks this guide uses (useActionState, useOptimistic, and React’s cache()) are React 19 APIs; they don’t exist in React 18. Outside Next.js, RSC support is still experimental: the React team publishes react-server-dom-* bundler plugins, and React Router’s framework mode ships RSC primitives, but production usage overwhelmingly means Next.js.

Compare the request lifecycle of a client-rendered React app against a React Server Components page, showing where rendering, data fetching, and hydration happen on each path.

Look at the two paths side by side. In the CSR path, the user stares at a blank page until the bundle arrives, mounts, and finishes its fetch waterfall. In the RSC path, data fetching happens during render on the server, and the browser receives content that already has data in it. The server-side rendering recipe covers the older SSR model; RSC is what App Router does on top of it.

Server Components vs Client Components

Every component in an App Router app is one or the other, and the difference is architectural, not stylistic:

Server ComponentClient Component
Where it runsServer, during renderBrowser, after hydration
Default?Yes, no directive neededOnly with "use client"
Data accessDB, filesystem, env vars, internal APIsfetch() to endpoints you expose
HooksNone (useState, useEffect unavailable)All React hooks
Event handlersNot supportedonClick, onChange, etc.
Browser APIsNot availablewindow, localStorage, etc.
Props receivedAny server-side valueMust be serializable
Bundle costZero, never shippedShips JS + hydrates

The "use client" directive is a bundler instruction, not a runtime API. When a module starts with it, the bundler treats everything that module exports as client-side code and registers it in the client manifest. React’s docs on the use client directive are explicit that the boundary is per-module: one directive at the top of a file makes every export in that file a Client Component.

The boundary rules follow from serialization. A Server Component can import a Client Component and render it, passing props down. A Client Component can’t import a Server Component; the import would pull server-only code into the browser bundle. The workaround is composition: the server component passes JSX as children or another prop, and the client component renders it without ever importing the server module.

Decision flow for placing a component on the server or the client: interactivity needs push it client-side, data and secret access keep it server-side, and only serializable props may cross the boundary.

What “serializable” means deserves precision, because it’s the most common source of runtime errors. React’s Flight serializer handles primitives, plain objects, arrays, Date, Map, Set, BigInt, and promises. It does not handle class instances (a Prisma Decimal or a Moment object loses its prototype and arrives broken), and it can’t send functions at all, with one exception: functions marked "use server" cross the boundary as references the client can call. That’s the mechanism behind Server Actions.

The practical consequence shows up in the most basic example. A Prisma product row contains Decimal prices and Date timestamps; passing the row straight into a Client Component will fail on the Decimal. Map to a plain object first:

// app/products/page.tsx — Server Component (default, no directive needed)
import { db } from "@/lib/db";
import { ProductCard } from "./ProductCard";

type ProductCardData = {
  id: string;
  name: string;
  price: number;
  image: string;
};

export default async function ProductsPage() {
  const products = await db.product.findMany({
    where: { published: true },
    orderBy: { createdAt: "desc" },
    take: 20,
  });

  if (products.length === 0) {
    return <p className="text-gray-500">No products published yet.</p>;
  }

  return (
    <div className="grid grid-cols-1 gap-6 sm:grid-cols-3">
      {products.map((product) => {
        // Strip non-serializable fields before crossing the boundary.
        const cardData: ProductCardData = {
          id: product.id,
          name: product.name,
          price: Number(product.price), // Decimal -> number
          image: product.imageUrl,
        };
        return <ProductCard key={product.id} product={cardData} />;
      })}
    </div>
  );
}
// app/products/ProductCard.tsx — Client Component
"use client";

import { useState } from "react";
import { addToCart } from "./actions";

interface ProductCardProps {
  product: {
    id: string;
    name: string;
    price: number;
    image: string;
  };
}

export function ProductCard({ product }: ProductCardProps) {
  const [isAdding, setIsAdding] = useState(false);
  const [quantity, setQuantity] = useState(1);

  async function handleAddToCart() {
    setIsAdding(true);
    try {
      await addToCart(product.id, quantity);
    } finally {
      setIsAdding(false);
    }
  }

  return (
    <div className="rounded-lg border p-4">
      {/* eslint-disable-next-line @next/next/no-img-element */}
      <img
        src={product.image}
        alt={product.name}
        className="h-48 w-full rounded object-cover"
      />
      <h3 className="mt-2 font-semibold">{product.name}</h3>
      <p className="text-gray-600">${product.price}</p>
      <div className="mt-4 flex items-center gap-2">
        <button
          onClick={() => setQuantity((q) => Math.max(1, q - 1))}
          className="rounded border px-3 py-1"
          aria-label="Decrease quantity"
        >
          -
        </button>
        <span aria-live="polite">{quantity}</span>
        <button
          onClick={() => setQuantity((q) => q + 1)}
          className="rounded border px-3 py-1"
          aria-label="Increase quantity"
        >
          +
        </button>
        <button
          onClick={handleAddToCart}
          disabled={isAdding}
          className="ml-auto rounded bg-blue-600 px-4 py-2 text-white disabled:opacity-50"
        >
          {isAdding ? "Adding..." : "Add to Cart"}
        </button>
      </div>
    </div>
  );
}

Notice what the client component received: plain data, nothing else. It doesn’t know a database exists, and it doesn’t need to: addToCart is a Server Action reference, which is the one kind of function allowed to cross the boundary.

When to Use RSC (and When It Costs You)

RSC earns its complexity on content-heavy and data-heavy surfaces: marketing pages, docs, product listings, dashboards that read more than they write. Anywhere you’d otherwise build a useEffect + fetch + loading-spinner pipeline, a Server Component does the same work during render and ships zero JavaScript for it. The React performance optimization guide goes deeper on what that bundle reduction buys you.

There are real cases where RSC is the wrong tool:

  • Highly interactive apps. Editors, canvases, drag-and-drop builders, and real-time collab tools are client-first by nature. Wrapping them in server components adds indirection without removing the JavaScript they need.
  • WebSockets and live data. A Server Component renders once per request; it can’t hold a socket open. Real-time features live in Client Components regardless, so the question is whether the surrounding page benefits enough from server rendering to justify the split.
  • Browser-API-dependent libraries. Charting libs, map SDKs, and anything touching window at module scope must live behind "use client". If your app is mostly such libraries, you’re maintaining two mental models for little gain.
  • Tiny interactive widgets. A single counter embedded in an otherwise static page doesn’t need a server/client architecture, but it also doesn’t hurt. The cost shows up at scale: every client boundary adds bundle weight and hydration work, so a page sliced into fifty small client islands hydrates worse than one medium island.
  • Teams without boundary discipline. The failure mode isn’t technical, it’s organizational. If every developer reaches for "use client" at the top of the file “just in case,” you’ve rebuilt a SPA with extra steps and worse debugging.

Outside Next.js, temper your expectations. React Router’s framework mode exposes RSC primitives and the React team maintains bundler plugins for Vite and webpack, but the ecosystem (error handling conventions, caching semantics, deployment story) is built around Next.js. If you’re on plain Vite + React, RSC is an experiment, not a migration target.

Data Loading Patterns

Server Components change data loading from a client concern into a render concern, which means the patterns look different. There are three worth knowing: parallel, sequential, and cached/revalidated. The islands architecture pattern is the non-React cousin of the same idea (static shell, hydrated islands), worth reading if you’re comparing frameworks.

Parallel fetching

When sibling components each need data, let them fetch independently. React doesn’t wait for one async component to finish before starting the next: siblings under the same parent render concurrently, and <Suspense> decides how the fallbacks behave:

// app/dashboard/page.tsx — Parallel data loading
import { Suspense } from "react";
import { db } from "@/lib/db";

async function UserStats() {
  const stats = await db.user.aggregate({ _count: true, where: { active: true } });
  return <div>Active users: {stats._count}</div>;
}

async function RevenueChart() {
  const revenue = await db.order.aggregate({
    _sum: { total: true },
    where: { status: "completed" },
  });
  return <div>Total revenue: ${revenue._sum.total}</div>;
}

async function RecentOrders() {
  const orders = await db.order.findMany({
    take: 10,
    orderBy: { createdAt: "desc" },
  });
  return (
    <ul>
      {orders.map((order) => (
        <li key={order.id}>
          {order.id} — ${order.total}
        </li>
      ))}
    </ul>
  );
}

export default function DashboardPage() {
  return (
    <div className="space-y-6">
      <h1>Dashboard</h1>
      {/* Each boundary resolves independently — slow queries don't block fast ones. */}
      <Suspense fallback={<div>Loading stats...</div>}>
        <UserStats />
      </Suspense>
      <Suspense fallback={<div>Loading revenue...</div>}>
        <RevenueChart />
      </Suspense>
      <Suspense fallback={<div>Loading orders...</div>}>
        <RecentOrders />
      </Suspense>
    </div>
  );
}

Three separate <Suspense> boundaries matter here. With one boundary around everything, the whole section waits for the slowest query. With three, each widget paints as soon as its own data arrives. If the queries are independent, this is almost always what you want.

Sequential fetches and waterfalls

Sometimes data genuinely depends on earlier data: you need the post before you can fetch its author. The mistake isn’t sequential fetching; it’s unnecessary sequential fetching. Once the first query resolves, everything that depends only on it should run together:

// app/blog/[slug]/page.tsx — Dependent fetches, deduplicated per request
import { notFound } from "next/navigation";
import { cache } from "react";
import { db } from "@/lib/db";

// React 19's cache() dedupes calls within a single render pass.
// If two components both call getPost(slug), the DB is hit once.
const getPost = cache(async (slug: string) => {
  const post = await db.post.findUnique({ where: { slug } });
  if (!post) notFound();
  return post;
});

type BlogPostPageProps = {
  // Next.js 15+: params is a Promise — always await it.
  params: Promise<{ slug: string }>;
};

export default async function BlogPostPage({ params }: BlogPostPageProps) {
  const { slug } = await params;
  const post = await getPost(slug); // First fetch — everything else needs this.

  // author and comments both depend on `post` but not on each other.
  // Awaiting them one after another would serialize two round trips
  // that could run in parallel.
  const [author, comments] = await Promise.all([
    db.user.findUnique({ where: { id: post.authorId } }),
    db.comment.findMany({
      where: { postId: post.id },
      include: { author: true },
      orderBy: { createdAt: "desc" },
    }),
  ]);

  return (
    <article>
      <h1>{post.title}</h1>
      <p>By {author?.name ?? "Unknown author"}</p>
      <div>{post.content}</div>
      <section>
        <h2>Comments ({comments.length})</h2>
        {comments.map((comment) => (
          <div key={comment.id}>
            <strong>{comment.author?.name ?? "Unknown"}</strong>
            <p>{comment.text}</p>
          </div>
        ))}
      </section>
    </article>
  );
}

Two things to notice. First, params is a Promise in Next.js 15+; the old synchronous { params: { slug } } signature silently breaks on current versions. Second, cache() from React is per-request memoization during render, which is a different mechanism from Next.js’s fetch cache. Don’t confuse the two, because they answer different questions (“did we already fetch this during this render?” vs “should this be cached across requests?”).

Caching and revalidation

This is where Next.js 15 changed the ground under everyone’s feet. Before 15, fetch() requests were cached indefinitely by default inside Server Components. Since Next.js 15, fetch isn’t cached by default; every request hits the network unless you opt in. The Next.js caching docs describe the current model, including the newer 'use cache' directive and cacheComponents config that inverts the default again for teams that want explicit opt-in caching.

For the classic model, you’ve got three levers:

  • export const revalidate = <seconds>: regenerate the route at most once per interval (ISR).
  • next: { revalidate } or cache: "force-cache" on an individual fetch: opt that request back into caching.
  • export const dynamic = "force-dynamic": guarantee nothing is cached or prerendered.

Time-based revalidation for a mostly-static catalog:

// app/products/page.tsx — ISR: regenerate at most once per hour
export const revalidate = 3600;

type Product = { id: string; name: string; price: number };

async function getProducts(): Promise<Product[]> {
  const res = await fetch("https://api.example.com/products", {
    // Opt back into caching — Next.js 15+ doesn't cache fetch() by default.
    next: { revalidate: 3600 },
  });
  if (!res.ok) throw new Error("Failed to fetch products");
  return res.json();
}

export default async function ProductsPage() {
  const products = await getProducts();
  return (
    <ul>
      {products.map((p) => (
        <li key={p.id}>
          {p.name} — ${p.price}
        </li>
      ))}
    </ul>
  );
}

Dynamic rendering for data that must be fresh on every request, in a different file and a different route segment (never both exports in the same module):

// app/live/page.tsx — Dynamic: nothing cached, nothing prerendered
export const dynamic = "force-dynamic";

async function getLiveData() {
  const res = await fetch("https://api.example.com/live", {
    cache: "no-store",
  });
  if (!res.ok) throw new Error("Live feed unavailable");
  return res.json();
}

export default async function LivePage() {
  const data = await getLiveData();
  return <pre>{JSON.stringify(data, null, 2)}</pre>;
}

If you’re on a recent Next.js version and prefer the explicit model, the 'use cache' directive marks a function or component as cacheable, with cacheLife() controlling its lifetime. It requires the cacheComponents flag in next.config; check the caching guide for which model your version defaults to before mixing the two.

// app/products/data.ts — Cache Components model: opt-in caching with "use cache"
import { cacheLife } from "next/cache";
import { db } from "@/lib/db";

async function getProducts() {
  "use cache";
  cacheLife("hours");
  return db.product.findMany({ where: { published: true } });
}

Streaming with Suspense

Streaming is what makes RSC feel fast rather than merely fast on paper. Next.js sends the prerendered shell (layout, static content, loading fallbacks) immediately, then streams each Suspense boundary’s resolved content as it becomes ready. The user sees the page structure in milliseconds and watches sections fill in, instead of waiting for the slowest query on the page.

The Next.js fetching data guide walks through the HTTP mechanics. The practical rules:

  • loading.tsx in a route segment wraps the whole page in one Suspense boundary: good for instant navigation feedback, too coarse for mixed-speed content.
  • <Suspense> around individual async components gives you per-section streaming; this is usually what you want.
  • Put the boundary as close to the slow data as possible. A boundary around a fast component buys nothing; a boundary around the entire page forfeits streaming.
// app/dashboard/page.tsx — Streaming with Suspense boundaries
import { Suspense } from "react";
import { db } from "@/lib/db";

// Slow component — simulates a heavy analytics query
async function SlowChart() {
  await new Promise((resolve) => setTimeout(resolve, 2000));
  const data = await fetch("https://api.example.com/chart-data").then((r) => r.json());
  return <Chart data={data} />;
}

async function QuickStats() {
  const data = await db.stats.findFirst();
  return (
    <div>
      Users: {data?.users ?? 0} | Orders: {data?.orders ?? 0}
    </div>
  );
}

export default function DashboardPage() {
  return (
    <div>
      <h1>Dashboard</h1>
      {/* Fast content streams in first */}
      <Suspense fallback={<div>Loading stats...</div>}>
        <QuickStats />
      </Suspense>

      {/* Slow content streams in ~2s later, without blocking the page */}
      <Suspense
        fallback={<div className="h-64 animate-pulse rounded bg-gray-200" />}
      >
        <SlowChart />
      </Suspense>
    </div>
  );
}

The perceived-performance win is real, but be honest about the trade-off: streaming sends more HTTP chunks and holds the connection open longer. For pages where every section is equally slow, a single boundary is simpler. Streaming pays off when latency is uneven, which describes most real dashboards.

Server Actions

Server Actions are async functions marked "use server" that run on the server but can be invoked from Client Components (event handlers, form action props, or useActionState). They exist to replace the API-route-plus-fetch pattern for mutations, and they do it well: arguments serialize automatically, the function lives next to the page that uses it, there’s no endpoint to secure separately, and forms work with progressive enhancement before the JavaScript bundle even loads.

The Next.js mutating data guide covers the mechanics. Two rules matter more than anything else: always authenticate inside the action (it’s a public endpoint whether you meant it or not) and validate every input (FormData is untyped user input, full stop).

// app/products/actions.ts — Server Actions
"use server";

import { revalidatePath } from "next/cache";
import { z } from "zod";
import { db } from "@/lib/db";
import { auth } from "@/lib/auth";

export type ProductFormState = {
  success: boolean;
  error?: string;
} | null;

const CreateProductSchema = z.object({
  name: z.string().min(1).max(100),
  price: z.number().positive(),
  description: z.string().min(10).max(500),
  image: z.string().url(),
});

// Signature matches useActionState: (previousState, payload) => newState
export async function createProduct(
  _prevState: ProductFormState,
  formData: FormData
): Promise<ProductFormState> {
  const session = await auth();
  if (!session?.user?.isAdmin) {
    return { success: false, error: "Unauthorized" };
  }

  const parsed = CreateProductSchema.safeParse({
    name: formData.get("name"),
    price: Number(formData.get("price")),
    description: formData.get("description"),
    image: formData.get("image"),
  });

  if (!parsed.success) {
    return {
      success: false,
      error: parsed.error.issues[0]?.message ?? "Invalid input",
    };
  }

  try {
    await db.product.create({ data: parsed.data });
  } catch {
    return { success: false, error: "Could not create product" };
  }

  // Invalidate the cached products page so the new item shows up.
  revalidatePath("/products");
  return { success: true };
}

export async function deleteProduct(productId: string) {
  const session = await auth();
  if (!session?.user?.isAdmin) {
    throw new Error("Unauthorized");
  }

  await db.product.delete({ where: { id: productId } });
  revalidatePath("/products");
}

export async function toggleLike(productId: string) {
  const session = await auth();
  if (!session) throw new Error("Login required");

  const existing = await db.like.findFirst({
    where: { productId, userId: session.user.id },
  });

  if (existing) {
    await db.like.delete({ where: { id: existing.id } });
  } else {
    await db.like.create({
      data: { productId, userId: session.user.id },
    });
  }

  revalidatePath(`/products/${productId}`);
}

On the client, React 19’s useActionState gives you pending state and a result channel in one hook. This is the pending-state pattern, not optimistic updates (that’s useOptimistic, below). Note the typed state instead of any, and the server action returning error states rather than throwing for expected failures:

// app/products/CreateProductForm.tsx — Form wired to a Server Action
"use client";

import { useActionState } from "react";
import { createProduct } from "./actions";

export function CreateProductForm() {
  const [state, formAction, isPending] = useActionState(createProduct, null);

  return (
    <form action={formAction} className="space-y-4">
      <input name="name" type="text" placeholder="Product name" required />
      <input name="price" type="number" placeholder="Price" required />
      <textarea
        name="description"
        placeholder="Description"
        required
      />
      <input name="image" type="url" placeholder="Image URL" required />

      <button
        type="submit"
        disabled={isPending}
        className="rounded bg-blue-600 px-4 py-2 text-white disabled:opacity-50"
      >
        {isPending ? "Creating..." : "Create Product"}
      </button>

      {state?.success && (
        <p className="text-green-600">Product created!</p>
      )}
      {state && !state.success && state.error && (
        <p className="text-red-600">{state.error}</p>
      )}
    </form>
  );
}

For interactions where waiting for the server feels laggy (likes, toggles, reordering), useOptimistic (also React 19, see the useOptimistic docs) lets you render the expected result immediately and roll back if the action fails:

// app/products/LikeButton.tsx — Optimistic UI with useOptimistic
"use client";

import { useOptimistic, useTransition } from "react";
import { toggleLike } from "./actions";

export function LikeButton({
  productId,
  initialLikes,
  initiallyLiked,
}: {
  productId: string;
  initialLikes: number;
  initiallyLiked: boolean;
}) {
  const [likes, addOptimisticDelta] = useOptimistic(
    initialLikes,
    (current: number, delta: number) => current + delta
  );
  const [isPending, startTransition] = useTransition();

  function handleClick() {
    const delta = initiallyLiked ? -1 : 1;
    startTransition(async () => {
      addOptimisticDelta(delta); // UI updates instantly
      await toggleLike(productId); // rolls back automatically on error
    });
  }

  return (
    <button onClick={handleClick} disabled={isPending}>
      {likes} {likes === 1 ? "like" : "likes"}
    </button>
  );
}

The useActionState docs are worth a read before reaching for it: the hook queues multiple dispatches, integrates with progressive enhancement via an optional permalink argument, and treats the action as a Transition, which is why isPending behaves the way it does.

Error Handling

Server Components fail differently than client code, and the error surface reflects that. When a Server Component throws during render, the error propagates to the nearest error.tsx boundary for that route segment, the same mental model as client error boundaries, but the failure happened on the server. In production, Next.js sanitizes the error: the client receives a generic message plus an error.digest, a hashed identifier you use to correlate the failure with server logs. The original message stays server-side so internals don’t leak to the browser.

That has a practical consequence: don’t build UX around error.message in production. Show a friendly fallback and log the digest. During development you do get real messages, which is where you’ll actually debug.

// app/products/[id]/error.tsx — Error boundary for the segment
"use client";

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  return (
    <div className="rounded border border-red-300 bg-red-50 p-4">
      <h2 className="font-semibold text-red-800">Something went wrong</h2>
      {/* In production, error.message is generic — log error.digest server-side. */}
      <p className="text-sm text-red-600">{error.message}</p>
      <button
        onClick={reset}
        className="mt-2 rounded bg-red-600 px-4 py-2 text-white"
      >
        Try again
      </button>
    </div>
  );
}

error.tsx must be a Client Component because it needs onClick for reset. loading.tsx is the automatic Suspense fallback for the segment, and not-found.tsx renders when you call notFound() (as getPost does above). Boundaries nest per segment, so an error in /products/[id] doesn’t take down the whole app, so scope them deliberately rather than relying on one root boundary.

Server Actions have their own error channel. An action that throws propagates to the nearest error boundary on the client, which can be jarring mid-form. For expected failures (validation errors, duplicates), return an error state through useActionState like createProduct does above, and reserve throws for genuinely exceptional cases.

Best Practices

  • Default to Server Components and push "use client" to the leaves; every client boundary is bundle weight and hydration work.
  • Fetch data in the component that needs it; identical fetch calls in the same render are deduplicated automatically.
  • Wrap each slow section in its own <Suspense> boundary: one boundary per speed class, not one per page.
  • Map ORM rows to plain objects before passing them to Client Components: strip Decimal, class instances, and anything non-serializable.
  • Authenticate and validate inside every Server Action; treat FormData as hostile input.
  • Call revalidatePath or revalidateTag after mutations so cached pages don’t serve stale data.
  • Keep Client Components small and focused; a 400-line client component defeats the purpose of the architecture.
  • Read error.digest in your logs when production errors surface; the client-side message is sanitized by design.

Common Mistakes

  • "use client" at the top of everything. If the whole tree is client components, you’ve built a SPA with extra indirection. Audit which components actually use state, effects, or handlers.
  • Passing non-serializable props. Plain objects, Date, Map, and Set serialize fine, but ORMs return class-backed types, so map rows to plain objects first. Functions never cross except Server Actions.
  • Importing a Server Component into a Client Component. The import breaks the boundary. Pass server-rendered JSX as children instead.
  • One giant Suspense boundary. Wrapping the whole page means the slowest query gates everything. Split boundaries by data speed.
  • Assuming fetch is still cached. Next.js 15+ doesn’t cache fetch by default; stale-data bugs usually trace back to forgetting revalidate or 'use cache', not to caching itself.
  • Throwing expected errors from Server Actions. Validation failures should return state via useActionState; throws are for the error boundary.
  • Sync params in Next.js 15+. params and searchParams are Promises now, so await them or your page breaks at runtime.
  • Skipping auth in actions. A "use server" function is a public POST endpoint. No session check means anyone can call it.

See Also

Frequently Asked Questions

What are React Server Components?

Components that render on the server (during build or per request) and send a serialized RSC payload to the browser instead of JavaScript. They can query databases and read secrets directly because their code never ships to the client. In Next.js App Router they're the default; "use client" marks the exceptions.

Is RSC the same as SSR?

No, and the confusion causes real bugs. SSR renders components to HTML on the server, then the client downloads the same component code and hydrates it. RSC renders on the server and sends a serialized payload; the server component's code never reaches the browser at all. SSR can hydrate the full tree; RSC hydrates only the client islands.

What version of React do I need for RSC?

React 19 or later, inside a framework that supports the RSC bundler contract, practically the Next.js App Router. useActionState, useOptimistic, and React's cache() are React 19 APIs and don't exist in React 18.

When should I use "use client"?

When a component needs useState, useEffect, event handlers, browser APIs like localStorage, or a library that requires client-side React. If none of those apply, leave it a Server Component — it's free performance.

Can I use React Server Components without Next.js?

Technically yes: React ships react-server-dom-webpack and Vite bundler plugins, and React Router's framework mode has experimental RSC support. In practice the tooling, caching semantics, and deployment story are built around Next.js, so most production RSC code lives there.