Server Components vs Client Components in Next.js 15
When to use server vs client components, the use client directive, data fetching patterns, performance implications, and composition strategies in Next.js 15.
The Component Model Shift
Next.js 13 introduced the App Router with React Server Components (RSC). Next.js 15 has refined this model into a mature, production-ready architecture. The fundamental shift: components are server components by default. They run on the server, have zero JavaScript bundle cost on the client, and can directly access databases, file systems, and APIs.
This is the biggest change to React development since hooks. Understanding when to use server components versus client components is now the most important architectural decision in Next.js applications.
Server Components: The Default
Every component in the App Router is a server component unless you explicitly add the "use client" directive. Server components:
What Server Components Cannot Do
Client Components: Opt-In Interactivity
Add "use client" at the top of a file to make it a client component. Client components:
The "use client" Directive
The directive marks a boundary. The file it appears in and everything it imports becomes part of the client bundle. This is why you should push "use client" as deep into the component tree as possible — wrap only the interactive leaf components, not entire page layouts.
Data Fetching Patterns
Server Components: Direct Data Access
In server components, fetch data directly. Call your database, call external APIs, read from the file system. The data is fetched at request time (dynamic rendering) or build time (static rendering) depending on your configuration.
Use the cache() function from React to deduplicate data fetches when multiple server components need the same data during a single render.
Client Components: API Routes or Server Actions
Client components cannot access the database directly. They fetch data through:
Performance Implications
The server/client split has dramatic performance implications:
Composing Server and Client Components
The key rule: server components can import and render client components, but client components cannot import server components. However, client components can accept server components as children via the children prop.
This pattern is called the "donut" pattern: a client component wraps around server components passed as children. The client component provides interactivity (like a collapsible panel), while the server components inside provide the data-heavy content.
Common Composition Patterns
Think of server components as the data backbone and client components as the interactive skin. Keep the skin thin and the backbone heavy. That is the architecture Next.js 15 rewards. Want to build with this architecture? Let us talk.
The Beyond Horizon Team
We are a digital agency based in Ajmer, India, specializing in Next.js web applications, React Native mobile apps, and UI/UX design. 150+ projects delivered.
About Us →Have a project in mind?
We build fast, SEO-ready web and mobile applications.
Get a Free Consultation→