View Transitions in 2026: Same-Document and Cross-Document Animation

View Transitions: Same-Document and Cross-Document Animation

Native crossfades, position morphs, and route-level transitions with a small amount of CSS — no animation library required. Same-document and cross-document MPA.

For page transitions and shared-element morphs, the View Transitions API can replace much of what teams used Framer Motion, GSAP, or hand-written FLIP techniques for. Two modes exist: same-document via document.startViewTransition(updateDOM) for SPA-style transitions, and cross-document via @view-transition { navigation: auto; } for MPA navigations. Same-document became Baseline Newly available in October 2025 when Firefox 144 shipped it, after being an Interop 2025 focus area; cross-document ships in Chromium and Safari but not yet Firefox, is Limited availability as of October 2026, and is part of the Interop 2026 view transitions focus area. Native crossfades, position morphs, and route-level transitions with a small amount of CSS — no animation library required.

What problem View Transitions solves

Page transitions and shared-element morph effects historically required substantial JavaScript machinery. Framer Motion managed mount and unmount animations against React's reconciliation. GSAP orchestrated arbitrary timeline animations with manual snapshotting. Hand-written FLIP (First, Last, Invert, Play) techniques measured layout positions before and after a state change and computed transforms manually.

Library-based implementations had to coordinate with framework lifecycles, virtualized lists, Suspense boundaries, and route-change machinery themselves, which made animation code a source of subtle UX bugs. For example, a list-to-detail morph that works in a simple component can break once the list virtualizes, and a page transition that works on the first navigation can break on the back button — not because the libraries were poorly written, but because the problem they were solving had to be solved without engine help.

The View Transitions API gives the engine a snapshot of the old DOM, lets you mutate the DOM to the new state, and animates the difference automatically. The framework no longer has to coordinate; the engine handles the snapshot, the swap, and the transition. The result is native crossfades, position morphs, and route-level transitions with a small amount of CSS, with no animation library involved.

The API has two modes that handle different navigation patterns. Same-document is the SPA-style mode where the application changes the DOM while staying on the same page. Cross-document is the MPA-style mode where the user navigates between pages of the same origin. The two share the same transition primitives but enter the engine through different APIs.

Same-document API

Same-document transitions use document.startViewTransition:

js
function navigateToDetail(itemId) {
  if (!document.startViewTransition) {
    updateDOM(itemId);
    return;
  }

  document.startViewTransition(() => {
    updateDOM(itemId);
  });
}

startViewTransition takes a callback that mutates the DOM. The engine snapshots the old state, then invokes the callback. If the callback returns a Promise (for example, an async function), the engine waits for that Promise to fulfill before it snapshots the new state and runs the transition; if the Promise rejects, the transition is skipped.

The default transition is a crossfade between the old and new full-page snapshots. Without any further configuration, the user sees a brief crossfade between the old and new DOM. For many SPA route changes, that is enough.

The return value is a ViewTransition object exposing three Promises and a skipTransition() method:

js
const transition = document.startViewTransition(() => updateDOM(itemId));

await transition.updateCallbackDone;  // resolves when the DOM mutation finishes
await transition.ready;                 // resolves when the transition is ready to start
await transition.finished;              // resolves when the transition has fully completed
transition.skipTransition();            // cancel and snap to the final state

The Promises let you coordinate with framework router lifecycles or with subsequent animations. skipTransition() is useful when a user interrupts mid-transition and you want to snap to the final state rather than waiting out the animation.

Customize per-element transitions with view-transition-name:

css
.product-card {
  view-transition-name: product-card;
}

Any element with a view-transition-name participates as a separately-animated layer. The engine snapshots the named element separately from the rest of the page, animates its position and size between old and new states, and crossfades between its old and new content.

The common use case is a list-to-detail morph. Click a card in a list, the card animates to the position and size of the hero on the detail page, the rest of the page crossfades. The same component (the card) appears in both views with the same view-transition-name; the engine handles the morph automatically.

Cross-document (MPA) view transitions

The cross-document API opts a multi-page app into navigation transitions:

css
@view-transition {
  navigation: auto;
}

This rule, declared on both the old and the new page, opts them into cross-document transitions for same-origin navigations such as link clicks, form submissions, and back/forward; reloads, URL-bar or bookmark navigations, and navigations through cross-origin redirects do not animate. No JavaScript required — the engine handles the snapshot, the navigation, and the transition automatically. A multi-page WordPress, Astro, Rails, or Next.js (with full-page navigation) app that adds the rule to its pages gets crossfade transitions between routes for free in browsers that support cross-document transitions.

Per-navigation customization uses two new events. pageswap fires on the old page just before it is replaced, once the new page is ready; pagereveal fires on the new page right before its first frame is presented. Both let JavaScript add per-navigation logic — for example, setting view-transition-name based on the navigation source so the right elements are tracked across pages:

js
window.addEventListener('pageswap', (event) => {
  if (event.viewTransition && event.activation) {
    // activation.entry is the destination history entry; its url is a string
    const selected = new URL(event.activation.entry.url).searchParams.get('selected');
    const sourceCard = selected && document.querySelector(`#card-${selected}`);
    if (sourceCard) sourceCard.style.viewTransitionName = 'hero';
  }
});

window.addEventListener('pagereveal', (event) => {
  if (event.viewTransition) {
    const targetHero = document.querySelector('.detail-hero');
    if (targetHero) targetHero.style.viewTransitionName = 'hero';
  }
});

The two pages now share a view-transition-name: hero, and the engine animates the morph between them across the navigation boundary. The user sees the source card grow into the destination hero as the navigation completes — a UX pattern that previously required complex coordination between two separate page environments.

As of October 2026, cross-document transitions ship in Chromium (126+) and Safari (18.2+) but not in Firefox, so they are Limited availability, not Baseline (web-features data). Cross-document view transitions are part of the Interop 2026 view transitions focus area. Treat them as an enhancement: Firefox users get a normal navigation, and the activation property is null when a cross-origin URL appears in the redirect chain, so guard for it as the code above does.

view-transition-name and shared element morphing

view-transition-name is the property that turns a regular element into an animated layer.

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

The engine takes a snapshot of the element on the old page or state, takes a snapshot of the element with the same name on the new page or state, and animates between the two snapshots — position, size, and crossfade content. The element appears to morph from its old position and shape into its new one.

Names must be unique within a document at any given moment during a transition. If two rendered elements have view-transition-name: hero at the same time, the browser skips the transition: the ready Promise rejects and the DOM updates without animation. The constraint is on visible elements during the transition; an element that is removed before the transition starts and another with the same name that appears after the transition completes is the normal pattern.

Dynamic naming handles lists where each item should morph to its own destination:

js
function navigateToCard(cardId) {
  document.querySelectorAll('.card').forEach((el) => {
    el.style.viewTransitionName = '';
  });
  document.querySelector(`#card-${cardId}`).style.viewTransitionName = 'hero';

  document.startViewTransition(() => updateDOM(cardId));
}

Set the name only on the source element for this navigation, clear the names on others, and the engine animates the right card. Without the dynamic naming, every card with view-transition-name: hero would conflict with every other.

During the transition the page is shown as captured snapshots layered above everything else, so a fixed or sticky element without its own name is part of the root snapshot and crossfades with the rest of the page. If a fixed header should stay steady, give it its own view-transition-name; when its position is the same in the old and new states, it stays in place. (view-transition-name: none only means the element gets no separate group.)

The ::view-transition pseudo-element tree

The transition's animation surface is exposed through a tree of pseudo-elements that you can target with CSS to customize the animation.

code
::view-transition
  └── ::view-transition-group(name)
        └── ::view-transition-image-pair(name)
              ├── ::view-transition-old(name)
              └── ::view-transition-new(name)

::view-transition is the root of the transition pseudo-tree, layered over the page during the transition. ::view-transition-group(name) wraps the old and new snapshots for a named element. ::view-transition-image-pair(name) contains the old and new image. ::view-transition-old(name) and ::view-transition-new(name) are the two snapshots that get crossfaded.

Customize timing and easing by targeting the pseudo-elements:

css
::view-transition-group(hero) {
  animation-duration: 0.4s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

::view-transition-old(hero) {
  animation: fade-out 0.3s ease-out forwards;
}

::view-transition-new(hero) {
  animation: fade-in 0.4s ease-in 0.1s forwards;
}

@keyframes fade-out {
  to { opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
}

Override the default crossfade entirely — slide-up old, slide-down new, with a brief overlap — by writing custom keyframes targeting the old and new pseudo-elements. The engine still handles the snapshot and the layering; CSS controls the visual behavior.

The pseudo-elements are not part of the DOM tree, so querySelector cannot reach them, and they exist only for the duration of the transition. CSS is the primary way to style them, but JavaScript can animate them through the Web Animations API's pseudoElement option once transition.ready resolves — for example, document.documentElement.animate(keyframes, { pseudoElement: '::view-transition-new(root)' }) (MDN). This is intentional — the transition is a presentation layer, not part of the document tree.

Browser support and progressive enhancement

As of October 2026, the same-document API is Baseline Newly available (since October 2025: Chrome and Edge 111, Safari 18, Firefox 144), so older versions of each browser still lack it (web-features data). The cross-document API is Limited availability (Chromium and Safari, not Firefox) and is part of the Interop 2026 focus area; do not rely on it without a fallback.

Feature detection is direct:

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

The fallback is "no animation, just navigate." This is graceful by design — the engine that does not support the API still updates the DOM correctly; the user simply does not see the transition.

CSS feature detection for view-transition-name gates the styling layer (note that this does not detect cross-document support — Firefox supports view-transition-name but not cross-document transitions; an unsupported @view-transition rule is simply ignored):

css
@supports (view-transition-name: x) {
  .product-image { view-transition-name: product-image; }
}

The @supports block applies the view-transition-name only in engines that recognize it.

Honor reduced-motion preferences; WCAG 2.2 success criterion 2.3.3 Animation from Interactions (Level AAA) asks that motion animation triggered by interaction can be disabled, unless the animation is essential to the functionality or the information being conveyed:

css
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

Users with prefers-reduced-motion: reduce set get the navigation without the animation. The DOM still updates; the transition is suppressed. Because the rule follows the user's system setting, people with vestibular disorders who have set it do not have to opt out per page.

Practical patterns

Five patterns cover many common production use cases.

A list-to-detail morph wraps the route change in startViewTransition with view-transition-name on both the list item and the detail hero:

js
async function openDetail(id) {
  document.querySelector(`#card-${id} .image`).style.viewTransitionName = 'hero';
  await document.startViewTransition(() => router.push(`/items/${id}`)).finished;
  document.querySelector(`#card-${id} .image`)?.style.removeProperty('view-transition-name');
}

Tab switching uses a default crossfade with no view-transition-name:

js
function selectTab(tabId) {
  document.startViewTransition(() => {
    document.querySelectorAll('[role="tabpanel"]').forEach((el) => {
      el.hidden = el.id !== tabId;
    });
  });
}

The default crossfade is enough; no per-element naming required.

Navigation-driven page transitions on an MPA use the cross-document API with optional per-route customization:

css
@view-transition { navigation: auto; }

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

Sorting or reordering a list uses same-document with per-item view-transition-name:

js
function sortBy(field) {
  document.querySelectorAll('.list-item').forEach((el, i) => {
    el.style.viewTransitionName = `item-${el.dataset.id}`;
  });

  document.startViewTransition(() => {
    items.sort((a, b) => a[field].localeCompare(b[field]));
    renderList(); // renderList must keep (or re-apply) each item's view-transition-name
  });
}

As long as the re-rendered items carry the same names, the engine animates positional changes — items slide to their new positions automatically.

A card-to-modal expansion shares a view-transition-name between the card and the modal:

js
function expandCard(id) {
  document.querySelector(`#card-${id}`).style.viewTransitionName = 'expanded';
  document.startViewTransition(() => {
    document.querySelector(`#card-${id}`).style.viewTransitionName = '';
    showModal(id);  // the modal element also has view-transition-name: expanded
  });
}

The card grows into the modal; the rest of the page crossfades.

What still needs JavaScript

The native APIs handle structural transitions, but UI-specific behavior remains application code.

Custom timing curves are not on this list: CSS easing functions such as cubic-bezier() and linear() (which interpolates linearly between as many control points as you list, enough to approximate curves such as a bounce) cover many curves, so easing often does not need JavaScript.

Per-element exit / enter customization that depends on application state uses the ready Promise to set state mid-transition:

js
const transition = document.startViewTransition(() => updateDOM());
transition.ready.then(() => {
  // transition has started; set up any state that depends on the transition running
});

Coordinating with framework router lifecycles wraps the router transition in startViewTransition:

js
async function navigateWithTransition(url) {
  if (!document.startViewTransition) {
    return router.push(url);
  }
  const transition = document.startViewTransition(() => router.push(url));
  await transition.finished;
}

For React, React Router's viewTransition prop and option wrap a navigation in document.startViewTransition() for you, but React Router now marks them deprecated (they still work) in favor of React's <ViewTransition> component, which requires React 19.3 or later (as of October 2026, React Router docs). For other routers, wrapping the navigation yourself, as above, is straightforward.

Skipping transitions on certain interactions calls skipTransition() on the returned ViewTransition object. Useful when the user interrupts mid-transition by clicking a different navigation target.

Deliverables and acceptance criteria for the next planning cycle

  • Pick one same-document route change (list to detail is the easiest first migration) and wrap it in document.startViewTransition; add view-transition-name on the morphing element
  • Add the prefers-reduced-motion rule to suppress the transition for users who request reduced motion
  • Feature-detect with if (document.startViewTransition) and fall back to non-animated DOM update for browser versions that predate support
  • If your site is multi-page, add @view-transition { navigation: auto; } to every page that should transition, as an enhancement only; cross-document transitions are not in Firefox as of October 2026, so do not make load-bearing paths depend on them
  • Replace Framer Motion or GSAP usage for basic crossfades and morph patterns with View Transitions; measure the bundle delta
  • Document the transition naming convention in the design system so future contributors do not collide on view-transition-name values
Project Inquiry