Mastering Next.js App Router: Architecting Server and Client Boundaries
A deep-dive architectural guide into React Server Components, request memoization, streaming boundaries, and zero-bundle-bloat interactive UI patterns.
- Next.js
- React
- App Router
- RSC
- Performance

Modern full-stack React applications rely on a clear mental model: compute and fetch on the server, hydrate only what needs interactivity on the client. When building component platforms like stash.ui, keeping JavaScript bundle sizes lean while rendering live interactive sandboxes requires strict discipline around the "use client" boundary.
In this guide, we will break down how to structure data-fetching pipelines, isolate client state, and leverage React's built-in memoization primitives in the Next.js App Router.
The Server-First Mental Model
By default, every component inside the app/ directory is a React Server Component (RSC). Server Components execute exclusively on the server during build time or request time—meaning their dependencies, file-system reads, and database queries never ship to the user's browser.
When you drop "use client" at the top of a file, you are not marking a single component as client-rendered; you are creating a network boundary that pulls every module imported inside that file into the client JavaScript bundle.
Pushing "use client" Down to the Leaves
A common mistake in large Next.js codebases is placing "use client" at the top-level page or layout just to handle a single search input, modal toggle, or tab switcher. Instead, keep the page as a Server Component and extract only the interactive leaf into a client island:
// app/components/[category]/[slug]/page.tsx (Server Component)
import fs from "fs/promises";
import path from "path";
import { ComponentViewTabs } from "@/components/docs/component-view-tabs";
export default async function ComponentDetailPage({
params,
}: {
params: Promise<{ slug: string }>;
}) {
const { slug } = await params;
const fullPath = path.join(process.cwd(), `registry/components/${slug}.tsx`);
const sourceCode = await fs.readFile(fullPath, "utf-8");
return (
<main className="mx-auto max-w-5xl py-12">
{/* Passes serialized string props across the boundary */}
<ComponentViewTabs slug="{slug}" sourceCode="{sourceCode}"/>
</main>
);
}