Client bundle reduction
What you need to know
Reduce client JavaScript by keeping work that needs no browser interaction on the server and deferring optional interactive features until they are needed.
By the end, you can: locate unnecessary client imports; compare dynamic import choices.
Keep the server page small
import DetailsToggle from './details-toggle';export default function Page(){ return <main><h1>River Books</h1><p>Reading guides for quiet afternoons.</p><DetailsToggle/></main>;}Expected behavior: app/page.tsx stays a Server Component; the optional client control is a separate file.
How it works
A use client boundary makes imported modules part of the client module graph unless a supported composition boundary intervenes. Keep static catalog descriptions and server data preparation in Server Components; move only controls requiring state or browser APIs to a Client Component. Pass a minimal serializable prop rather than importing a server module into the client. A dynamic import can create a separate loading boundary; rendering that component immediately does not necessarily defer it until user intent. In the documented App Router behavior, a Server Component dynamically importing a Client Component does not currently get automatic client code splitting. Place conditional dynamic imports in a Client Component. The ssr:false option is for client-side use and should be reserved for browser-dependent code, not a default optimization. Measure real transferred JS, parsed/executed JS and interaction latency; chunk names and source file lengths are not reliable byte totals.
Defer a details panel
'use client';import dynamic from 'next/dynamic';import {useState} from 'react';const Panel = dynamic(()=>import('./details-panel'),{loading:()=> <p role='status'>Loading details</p>});export default function DetailsToggle(){ const [open,setOpen]=useState(false); return <><button aria-expanded={open} onClick={()=>setOpen(!open)}>{open?'Hide':'Show'} details</button>{open && <Panel/>}</>;}Expected behavior: Save as details-toggle.tsx beside the panel in the fixture. The panel is requested when needed, subject to bundler/browser preloading behavior.
Common mistake
Do not move a whole application behind use client to enable one button. Avoid disabling SSR merely to make a component compile; browser-only APIs can often be isolated.
Practice and verification
Compare an eager panel import and the conditional dynamic version in a reviewed production build. Inspect network and execution traces, verify keyboard access and compare opening latency as well as startup.
Scope: Proposed Next.js 16.x / React 19, App Router with Cache Components disabled unless noted. Framework and browser examples are staged, not executed. Synthetic numbers are not measured performance or actual provider rates.
Further reading: Lazy · Production