@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.3s;
}

The browser handles the hard part

Under the hood, the browser takes a screenshot of the old state and the new state and animates between them automatically - no manual DOM diffing, no framework-managed transition state required to get a smooth crossfade or slide between pages.

Named transitions for specific elements

.hero-image { view-transition-name: hero; }
/* the same element on the next page, same name, animates between the two positions */

A plain multi-page site, feeling like an app

This has been the most exciting part for us: a traditional, simple, server-rendered multi-page site can now get single-page-app-feeling transitions without adopting a client-side router or a JavaScript framework at all.

Smooth page changes without a client-side router

if (document.startViewTransition) {
  document.startViewTransition(() => updateDOM());
} else {
  updateDOM();
}

Before this API, a smooth cross-fade or shared-element transition between views meant either a full SPA architecture or hand-rolled CSS animation trickery. startViewTransition handles the before/after screenshot and crossfade automatically, working even on traditional multi-page sites via the newer cross-document view transitions.

Named transitions for shared-element effects

Tagging an element with view-transition-name lets the browser animate it individually as it moves between states - a thumbnail growing into a full image on a detail page, the kind of polish that used to require a JavaScript animation library to fake convincingly:

.thumbnail { view-transition-name: product-image; }