Skip to content

[lts-active] docs: lead with use(browser()) for browser-only rendering - #102461

Merged
icyJoseph merged 1 commit into
releases/lts/activefrom
backport-102401-to-releases/lts/active
Nov 26, 2026
Merged

icyJoseph merged 1 commit into
releases/lts/activefrom
backport-102401-to-releases/lts/active

Conversation

@icyJoseph

Copy link
Copy Markdown
Member

Backports docs: lead with use(browser()) for browser-only rendering (#102401) to releases/lts/active.

Cherry-picked from 29c0ed0 with git cherry-pick -x; it applied cleanly with no conflicts.

## 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)

(cherry picked from commit 29c0ed0)
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: b43f3e7
View workflow run

@github-actions github-actions Bot added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. labels Nov 26, 2026
@icyJoseph
icyJoseph marked this pull request as ready for review November 26, 2026 16:06
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Code review ?

Vercel Agent Verified Review approved this pull request.
b43f3e7 • Ran Thu, 26 Nov 2026 16:07:56 GMT • 38.1s • Read the full report ↗

Summary

Docs-only backport to the LTS branch. It rewrites the 'Rendering components only in the browser' guide to lead with use(browser()) inside a Suspense boundary, moves next/dynamic with ssr:false into a follow-up section on module-level browser code and lazy loading, and adds a cross-link from the lazy-loading guide. I checked the technical claims against the head's source. No code changed and there were no tests to run.

Checked (3)

     Check Location
Holds The docs' claim that next/dynamic with ssr:false shows the loading component as a placeholder and otherwise renders nothing matches Loadable.
I read Loadable: with ssr:false it wraps the component in Suspense, and the fallback is the loading element or null.
loadable.tsx:47
Holds The docs' claim that ssr:false keeps the module from being imported on the server matches the SWC dynamic transform.
I read should_skip_ssr_compile, which skips the server import when ssr:false is set.
dynamic.rs:290
Holds The new cross-link's anchor exists in the target page.
I grepped for the 'Rendering components only in the browser' heading in single-page-applications.mdx. Other docs on this branch already link to the same anchor.
lazy-loading.mdx:74
Review steps

     Step Time
Sandbox set up 14.7s
Agent review: 1 command run 21.6s
Repros run on the head and the base (0), findings graded (0) 1.8s

@icyJoseph
icyJoseph merged commit 3babb1d into releases/lts/active Nov 26, 2026
60 checks passed
@icyJoseph
icyJoseph deleted the backport-102401-to-releases/lts/active branch November 26, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants