Hello Developers 👋,

You add a tiny widget that reads from localStorage. It works in the browser. Then you refresh a server-rendered page and the server reminds you: it doesn't have localStorage.

React 19.3 has an API for this exact kind of UI.

What is browser()?

browser() is a React DOM API you pass to React's use API. Together, use(browser()) tells React that this part of the UI needs the browser to render.

On the server, the closest <Suspense> boundary renders its fallback. In the browser, the component can render normally.

Check out the official documentation 🚀

How to use it?

import { use } from 'react'; import { browser } from 'react-dom'; function BrowserOnlyWidget() { use(browser()); return <p>Width: {window.innerWidth}px</p>; } 

Put that call inside a Client Component, before accessing browser-only APIs. Wrap that component with <Suspense>. Calling browser() on its own doesn't change how anything renders.

When to use it?

Use it when a small widget can't show meaningful UI without something like browser storage. Don't use it to skip server rendering for an entire page when most of that page can render fine on the server.

Example: Show the last workspace from this browser

'use client'; import { Suspense, use } from 'react'; import { browser } from 'react-dom'; function LastWorkspace() { use(browser()); const workspace = localStorage.getItem('last-workspace'); return ( <p> {workspace ? `Last workspace: ${workspace}` : 'No saved workspace yet.'} </p> ); } export default function WorkspacePanel() { return ( <section> <h2>Your workspaces</h2> <Suspense fallback={<p>Loading last workspace…</p>}> <LastWorkspace /> </Suspense> </section> ); } 

To try it in a server-rendered app, open the browser console and run:

localStorage.setItem('last-workspace', 'Side Projects'); 

Reload. The initial server HTML can include the heading and the fallback. Once React hydrates in the browser, the widget can show Last workspace: Side Projects. The fallback might go by too fast to see, so check View Page Source if you want to see what the server sent.

That's it 😅

The whole panel doesn't need to wait for the browser. Just the part that actually needs it.

Happy coding!