The View Transitions API is a browser interface that creates animated transitions between two visual states of a page, or between two pages of the same site, by capturing snapshots of the old and new states and animating between them with CSS. Among Web APIs, it fills a gap that previously required heavy JavaScript animation libraries or complex manual coordination of the DOM.
The API covers two scenarios. Same-document transitions animate DOM updates inside a single page, typical for single-page applications, while cross-document transitions animate ordinary navigations between same-origin pages of a multi-page Web site. In both cases the browser does the heavy lifting of capturing and compositing, and developers control the motion with standard CSS animations.
How the View Transitions API captures and animates states
A same-document transition starts with a call to document.startViewTransition(), which receives a callback that updates the DOM. The browser then follows a fixed sequence: it captures the current state, pauses rendering, runs the update, captures the new state and animates between the two snapshots.
- The browser takes a snapshot of the old state, including every element that carries a
view-transition-name. - Rendering is briefly frozen while the update callback changes the DOM, so users never see an intermediate state.
- The browser captures the new state as live representations of the updated elements.
- It builds a pseudo-element tree on top of the page and runs CSS animations, by default a crossfade.
- When the animations finish, the overlay is removed and the real updated page becomes visible and interactive.
The overlay is described by a tree of pseudo-elements, and each one can be targeted with CSS. Understanding this tree is the key to customizing the animation without any JavaScript animation code.
| Pseudo-element | What it represents | Typical customization |
|---|---|---|
| ::view-transition | Root overlay above the page | Rarely styled directly |
| ::view-transition-group(name) | Container that morphs size and position | Duration and easing of movement |
| ::view-transition-image-pair(name) | Holder for old and new images | Isolation and blending |
| ::view-transition-old(name) | Static snapshot of the old state | Fade-out or slide-out keyframes |
| ::view-transition-new(name) | Live view of the new state | Fade-in or slide-in keyframes |
Shared element transitions with view-transition-name
The CSS property view-transition-name marks an element as a separately animated participant. When an element in the old state and an element in the new state share the same name, the browser treats them as one object and morphs its position and size between the two layouts, which produces the familiar effect of a thumbnail expanding into a hero image.
Each name must be unique on the page at capture time; if two visible elements carry the same name, the transition is skipped. For lists with many items, developers assign names dynamically, use the match-element value in supporting browsers, or group styling with view-transition-class, so that dozens of items can share one animation rule.
Same-document and cross-document transitions compared
The two variants share the same pseudo-element model but differ in how a transition is triggered and which architecture they serve. The following table summarizes the practical differences.
| Aspect | Same-document | Cross-document |
|---|---|---|
| Trigger | document.startViewTransition() in script | Normal navigation between pages |
| Opt-in | Calling the method | CSS rule @view-transition { navigation: auto; } on both pages |
| Typical architecture | Single-page application | Multi-page site or server-rendered pages |
| Origin requirement | Not applicable | Both pages must be same-origin |
| Script hooks | Promises on the ViewTransition object | pageswap and pagereveal events |
| JavaScript required | Yes | No, CSS alone is sufficient |
Cross-document transitions are significant because they give multi-page architectures the smooth feel that was once a main argument for single-page applications, without client-side routing or hydration.
Controlling transitions from JavaScript
The startViewTransition() method returns a ViewTransition object that exposes the lifecycle of the transition. Its promises let code wait for specific moments, and its methods allow a transition to be skipped or classified.
| Member | Resolves or acts when | Common use |
|---|---|---|
| updateCallbackDone | The DOM update callback has finished | Continue logic that depends on new DOM |
| ready | The pseudo-element tree exists | Start custom Web Animations API effects |
| finished | The animation has ended | Clean up names or restore focus |
| skipTransition() | Called by script | Apply the update without animation |
| types | Set at start or during navigation | Choose different animations by direction |
Transition types allow one stylesheet to define several animations, for example a slide to the left for forward navigation and a slide to the right for back navigation, selected with the :active-view-transition-type() pseudo-class.
Browser support, accessibility and common pitfalls
Support arrived in stages: Chromium-based browsers shipped same-document transitions first and later cross-document transitions, Safari followed with both variants in version 18 releases, and Firefox added same-document support in 2025. Because the API is a progressive enhancement, the standard pattern checks for document.startViewTransition and simply applies the update directly when it is missing.
Motion can cause discomfort for some users, so transitions should respect the prefers-reduced-motion media query, either by removing animations or by shortening them to a gentle fade. The table below lists frequent problems and their fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Transition skipped entirely | Duplicate view-transition-name values | Make names unique per capture |
| Page feels unresponsive | Slow update callback freezes rendering | Fetch data before starting the transition |
| Distorted text during morph | Aspect ratio change between snapshots | Adjust object-fit on old and new images |
| Clicks ignored mid-animation | Overlay snapshots are not interactive | Keep durations short, around 200-400 ms |
| Cross-page animation missing | Opt-in rule present on only one page | Add @view-transition to both documents |
A further subtlety is that the old state is a flat image, so content inside it, such as a playing video, freezes during the animation. Elements with view-transition-name also form their own stacking context, which can change how they overlap other content.
Stripped to the essentials
When a page changes, the browser normally swaps the old content for the new content in an instant. The View Transitions API lets the browser take a picture of the page before the change, make the change, and then smoothly blend or slide from the picture to the new view.
Think of a photo album where one picture gently grows into a full-page print instead of the page simply flipping. The developer only describes the motion in CSS, and the browser handles the hard parts. If an older browser does not understand the feature, the page still changes as usual, just without the animation.
Where it is applied
A regional news publisher runs a server-rendered multi-page site with article lists and article pages. To make browsing feel smoother on phones, the frontend team adds the @view-transition rule to every template and assigns view-transition-name to each teaser image and to the matching hero image on the article page, using the article identifier in the name to keep every name unique.
When a reader taps a teaser, the small image expands into the article header over about 300 ms while the rest of the page crossfades. A pagereveal handler sets a transition type when the reader returns with the back button, so the motion reverses direction. Users who enable reduced motion receive a simple 150 ms fade instead.
The change required no client-side router and no new JavaScript framework. Readers on browsers without support see ordinary page loads, so the team ships the feature as a pure enhancement and avoids rebuilding the site as a single-page application.