The View Transitions API animates between two DOM states. The browser snapshots the old state, you update the DOM, it captures the new state, and then it cross-fades and morphs between them using a tree of pseudo-elements you can style with ordinary CSS animations. Elements with the same view-transition-name in both states get a "shared element" morph (e.g. a thumbnail growing into a hero image). Same-document transitions (document.startViewTransition()) are supported in all major browsers as of late 2025. Cross-document transitions for multi-page apps (@view-transition { navigation: auto; }) work in Chromium and Safari, with Firefox support still pending, so treat them as progressive enhancement.
async function showProduct(id) {
if (!document.startViewTransition) return render(id); // fallback
const vt = document.startViewTransition(() => render(id)); // callback may be async
await vt.finished;
}
.thumb.is-active, .product-hero { view-transition-name: product-image; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 200ms; }
::view-transition-group(product-image) {
animation-duration: 350ms;
animation-timing-function: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-reduced-motion: reduce) {
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
animation: none;
}
}
::view-transition
└─ ::view-transition-group(product-image) ← animates size and position
└─ ::view-transition-image-pair(product-image)
├─ ::view-transition-old(product-image) ← screenshot of the old state
└─ ::view-transition-new(product-image) ← live rendering of the new state
root is the default group for the whole page. Each view-transition-name must be unique in the document at snapshot time; duplicates abort the transition. Newer additions (view-transition-class, match-element auto-naming, and transition types for direction-aware animations) are spreading across browsers; check support before depending on them.
/* On both the old and the new page (same origin only) */
@view-transition { navigation: auto; }
.site-header { view-transition-name: header; }
pageswap and pagereveal events let you customise the transition (set names dynamically, skip it for some routes).view-transition-name: card-42), and only for the elements involved.object-fit on ::view-transition-old/new.prefers-reduced-motion, and manage focus after the DOM update as you would without the animation.flushSync), or use the router's built-in view transition support. React has been adding a <ViewTransition> component, initially in canary and experimental channels.view-transition-name and the uniqueness rule.Spotted a mistake or a rights concern? Report an issue