next.js
29c0ed0e - docs: lead with use(browser()) for browser-only rendering (#102401)

Commit
13 hours ago
docs: lead with use(browser()) for browser-only rendering (#102401) ## What Updates "Rendering components only in the browser" in the Single-Page Applications guide, plus a pointer from the Lazy Loading guide. - Leads with `use(browser())` inside a Suspense boundary as the way to render a component only in the browser. - Keeps `next/dynamic` with `ssr: false` for large components that are not needed when the page loads, where the code splitting is the point. - Adds guidance on Largest Contentful Paint and on sizing the fallback. - Links the React Suspense caveats for the reveal timing. - Drops the `useEffect` suggestion. ## Why The section presented `next/dynamic` with `ssr: false` as the default. That option also code splits, so the component's bundle is requested after hydration, and `React.lazy` suspends on its first client render. The content then arrives as a retried Suspense boundary, which React reveals [at most once every 300ms](https://react.dev/reference/react/Suspense#caveats). With `use(browser())` and a static import nothing suspends in the browser, so the component renders in the same pass that hydrates the page. Measured on a production build of a small repro (Next.js 16.4.6, React 19.3.0, headless Chrome, medians): | | content committed | LCP | |---|---|---| | `next/dynamic` with `ssr: false` | 303ms | 324ms | | `use(browser())` in `<Suspense>` | 33ms | 44ms | On a soft navigation, the `next/dynamic` version showed its fallback for about 300ms with the chunk already cached. The `use(browser())` version rendered the content directly. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Parents
Loading