Rendering is fundamental to web performance and directly impacts how quickly users access and interact with content. Next.js supports several rendering methods:
The App Router introduces React Server Components (RSC) and other paradigms that optimize data fetching and reduce client-side JavaScript overhead.
Server Components run exclusively on the server, sending lightweight JSON or rendered HTML to the client.
Core Characteristics:
Core Characteristics:
async function ProductsPage() {
const products = await db.query('SELECT * FROM products');
return ;
}Limitations:
Optimal Use Cases: Data-heavy components, SEO-critical content, static content.
Client Components enable interactivity and dynamic behavior while still participating in server-side rendering for initial page loads.
'use client';
import { useState } from 'react';
export default function InteractiveForm() {
const [formData, setFormData] = useState({ name: '', email: '' });
// Full access to browser APIs, state management, event handling
}Optimal Use Cases: Interactive UI elements, real-time features, browser API access, third-party client libraries.
Dynamic rendering generates HTML on each request. Use fetch with { cache: 'no-store' } or export const dynamic = 'force-dynamic'.
Benefits: Fresh data, personalization, SEO-friendly.
Trade-offs: Higher server load, slower TTFB than static.
Pages are rendered at build time and served as static HTML files. Default behavior in App Router.
Benefits: Fastest possible TTFB, minimal server load, CDN-cacheable.
Trade-offs: Build time increases with pages, data can become stale.
Combines SSG speed with data freshness using revalidate:
async function ProductPage() {
const product = await fetch('https://api.example.com/product', {
next: { revalidate: 3600 }
});
}Static speed with periodic updates, no full rebuilds.
Renders content entirely in the browser using JavaScript. Use 'use client' directive with data fetching libraries.
Benefits: Rich interactivity, reduced server load.
Trade-offs: Slower initial load, SEO challenges, JavaScript dependency.
The Pages Router uses getServerSideProps for SSR, getStaticProps for SSG, and getStaticPaths for dynamic routes.