01.Mastering the Server/Client Boundary
The single most common mistake engineers make when migrating to the App Router is placing 'use client' at the top of page files. Doing this destroys the benefits of Server Components, forcing the browser to download, parse, and execute heavy JavaScript bundles.
Pages, layouts, and data-heavy containers should ALWAYS remain Server Components. Push client boundaries as far down the component tree as possible (to specific buttons, input fields, or animated widgets).
02.Securing Server Actions in Production
Server Actions allow developers to write asynchronous server-side mutation logic without manually authoring API route handlers. However, under the hood, every exported Server Action generates an HTTP POST endpoint.
If you do not validate inputs or verify user sessions inside the Server Action, malicious actors can invoke your actions directly with arbitrary payloads.
'use server';
import { z } from 'zod';
import { auth } from '@/lib/auth';
import { db } from '@/lib/db';
const UpdateSchema = z.object({
id: z.string().uuid(),
title: z.string().min(3).max(100),
});
export async function updatePost(input: unknown) {
const session = await auth();
if (!session?.user) throw new Error('Unauthorized');
const { id, title } = UpdateSchema.parse(input);
return await db.post.update({ where: { id, userId: session.user.id }, data: { title } });
}03.Partial Prerendering (PPR) for Instant Loads
Partial Prerendering combines the speed of static sites with the flexibility of server-rendered dynamic data. In Next.js 16, you can statically shell the surrounding layout, navigation bar, and marketing banners at build time, while streaming personalized user content (e.g. cart drawer, user profile badge) inside React Suspense boundaries.
Frequently Asked Questions
When should I use a Server Component vs Client Component?
Default to Server Components everywhere. Switch to Client Components only when you need interactivity, browser APIs, or React lifecycle state (hooks).
How does Turbopack benefit production builds?
Turbopack compiles TypeScript and bundles assets in Rust rather than JavaScript, achieving up to 5x faster production build times and sub-100ms Fast Refresh updates in local development.