React 19.3
Stable ViewTransition and Fragment refs, browser(), Trusted Types, Server Components rendering client Context, and independent transitions. · 4 lessons · click a card to expand
Part of the React 16 → 19.3 evolution reference. Expand a card, then use chapter links in the sidebar.
These APIs are stable in 19.3. Older blog posts (2025 Labs) called View Transitions experimental — do not copy that label if you are on 19.3. cacheSignal remains RSC (19.2). The Compiler is still a separate plugin.
Why 19.3 mattered
1 item0119.3 makes animation and fragment DOM access first-classReact 19.3
ViewTransition), refs that target a fragment’s DOM children as a group, and a few platform/security/RSC polish items.| Feature | Status in 19.3 |
|---|---|
<ViewTransition> / addTransitionType | Stable |
Fragment refs (<Fragment ref> / <> cannot take ref — use Fragment) | Stable |
browser() from react-dom | Stable (client-only helper) |
| Trusted Types | Stable integration |
| Server Components render imported client Context | Stable RSC |
| Independent transitions | Behavior change (slow transition no longer blocks unrelated ones) |
setState.ViewTransition and add/remove it inside startTransition.ViewTransition
1 item02ViewTransition animates enter, exit, move, and shareReact 19.3
<ViewTransition> uses the browser View Transition API to animate elements that enter, leave, update, or share (morph from one place to another).import { ViewTransition, startTransition, useState } from "react";
function Gallery({ items }) {
const [selected, setSelected] = useState(null);
return (
<ul>
{items.map((item) => (
<ViewTransition key={item.id}>
<li>
<button
onClick={() => startTransition(() => setSelected(item.id))}
>
{item.title}
</button>
</li>
</ViewTransition>
))}
</ul>
);
}React picks an animation based on how the tree changed:
- enter — boundary added
- exit — boundary removed
- update — children changed
- share — a named transition moved from one place to another
Urgent setState (typing) does not start a View Transition. That is intentional: typing should not cross-fade.
Why it was introduced?
CSS animations on mount/unmount are painful with React’s render model (the node is gone before CSS can run). The View Transition API captures old/new snapshots. React coordinates startViewTransition with its own commit, fonts, and images.
Before 19.3
- CSS
transitiononly when the node stays mounted react-transition-group/ FLIP libraries- Experimental
<ViewTransition>in canary (API could still change)
With 19.3
Stable import from react. Pair with startTransition / useDeferredValue / Suspense.
How it works (practical)
React calls document.startViewTransition. Inside the update callback it mutates the DOM, waits (fonts, images, navigation), measures, then lets the browser animate. You can customize with CSS ::view-transition-old/new and named transitions.
Real-world examples
1. E-commerce: product thumbnail → PDP hero (shared element) — named ViewTransition so the image appears to fly.
2. Tab content in a dashboard — cross-fade panels when the tab switch is a transition.
3. Todo complete: row exits — wrap the row; removing it inside startTransition plays an exit.
When should I use it?
Route-level or list-level animation already modeled as a Transition. List reordering. Shared element navigation.
When should I NOT?
- Every keystroke
- Replacing all CSS hover animations
- Unsupported browsers without a fallback plan (feature-detect; allow reduced motion)
prefers-reduced-motion: respect it (disable or shorten).
Common mistakes
- Forgetting
startTransition(nothing animates) - Animating urgent updates
- Fighting a second library that also calls
startViewTransition(let React coordinate)
Related APIs
useTransition, Activity (19.2), Suspense, addTransitionType
Interview notes
- Stable in 19.3, not 19.0.
- Only non-urgent / Suspense / deferred updates trigger it.
- Browser View Transition API underneath.
ViewTransition.startTransition; only one animates.Fragment refs
1 item03Fragment refs expose a FragmentInstance over a group of DOM nodesReact 19.3
ref on <Fragment> (the long form) yields a FragmentInstance with group operations: focus, observers, scrollIntoView, getClientRects, event listeners on the children as a group — without adding a wrapper div.<> cannot take a ref (no props). Use:import { Fragment, useRef, useLayoutEffect } from "react";
function TableRowGroup({ cells }) {
const ref = useRef(null);
useLayoutEffect(() => {
ref.current?.focus();
}, []);
return (
<Fragment ref={ref}>
{cells.map((c) => (
<td key={c.id}>{c.text}</td>
))}
</Fragment>
);
}FragmentInstance operates on the children’s DOM as a group (focus first focusable, observe bounds, etc.) without changing HTML structure — critical for tables and CSS grids.
Why it was introduced?
forwardRef to a single node fails when a component must return multiple nodes. Wrapping in div breaks <tr> / flex. findDOMNode is deprecated.
Before 19.3
- Extra
div(breaks tables) querySelectorAllinuseLayoutEffect(fragile)findDOMNode(gone)
Real-world examples
1. Table row that is a component returning several `<td>`s — focus the row group after insert.
2. Design-system `ButtonPair` — two buttons as flex children of the parent; observe visibility as a unit.
3. Form field + error + hint — scroll the group into view on validation error without a wrapper that breaks grid.
When should I use it?
Composite components that must not emit a DOM wrapper, but parents still need imperative access.
When should I NOT?
Single-element components — pass ref to the DOM node (19 ref as prop). You do not need a fragment.
Common mistakes
refon<>(invalid)- Assuming
ref.currentis anHTMLElement(it is a FragmentInstance)
Related APIs
Fragments (16.2), useImperativeHandle, 19 ref-as-prop
Interview notes
- Stable 19.3.
- Group DOM APIs without a wrapper node.
- Short fragment syntax cannot take ref.
FragmentInstance type from React 19.3 types.scrollIntoView on a fragment wrapping dt+dd inside a <dl>.browser(), Trusted Types, RSC Context
1 item04Client-only browser(), Trusted Types, and Context from the serverReact 19.3
browser() (react-dom)
A helper that suspends on the server (and during SSR) until you are in the real browser, so client-only APIs (useQuery without initialData, window, matchMedia) do not run during SSR/hydration unsafely.
import { browser } from "react-dom";
import { use } from "react";
function ClientOnlyChart({ fallbackData }) {
if (fallbackData === undefined) {
use(browser());
}
return <Chart />;
}Pattern from the 19.3 blog: skip browser() when the server already provided initialData. This is not Next.js dynamic(..., { ssr: false }) [framework], but it solves a similar problem at the React layer.
Trusted Types
With CSP require-trusted-types-for 'script', the browser rejects raw strings at XSS sinks. React used to coerce values with '' + value, stripping Trusted Type objects. 19.3 passes them through so sanitizer policies work.
If you do not use Trusted Types, you can ignore this. If you do, upgrade before enforcing the CSP.
Context in Server Components
Server Components still cannot create Context, but in 19.3 they can render a Context imported from a 'use client' module:
// user-context.js
"use client";
import { createContext } from "react";
export const UserContext = createContext(null);
// layout — Server Component
import { UserContext } from "./user-context";
export async function Layout({ children }) {
const currentUser = await getCurrentUser();
return <UserContext value={currentUser}>{children}</UserContext>;
}Before 19.3 you needed a client UserProvider wrapper that only forwarded props.
Independent transitions
19.3 renders transitions independently so a slow transition does not stall an unrelated one (they used to be entangled). UX: typing in a search box should not wait on a slow tab transition elsewhere.
Real-world examples
1. `useQuery` in a Client Component — use(browser()) when no initialData from RSC.
2. Bank/admin CSP — Trusted Types + React 19.3 so innerHTML policies hold.
3. App Router layout — pass currentUser into UserContext directly from a Server Component.
When should I use browser()?
Client-only libraries without a server snapshot. Prefer passing initialData from a Server Component when you can — faster HTML.
When should I NOT?
Everything — it delays HTML for that subtree (suspends). Overuse = empty holes.
Interview notes
- ViewTransition + Fragment refs stable 19.3.
browser()= client-only suspend helper.- RSC can render client Context in 19.3.
- Transitions are independent.
browser() as React DOM 19.3, not as Next.js ssr: false.initialData from the server vs use(browser()) — one is in the HTML, the other waits for the client.