Back Button Skips Your Page Transition? The Pitfalls
October 8, 2026 | 9 min read | CSS
By Syed · Frontend Engineer & Creator of UITweak
Your view transitions are beautiful on link clicks. Then the user hits the back button and the page just snaps. Or worse: the shared-element morph never fires at all, no error, no warning, just a crossfade where the hero image should have flown across the screen. Same-document view transitions are Baseline across browsers now, but the failure modes are sharp and silent. This guide covers the three that bite Next.js and React apps, each with its fix.
30-second version: the back button never triggers startViewTransition because popstate is synchronous; intercept navigations with the Navigation API or push explicitly. Duplicate view-transition-name values silently skip the morph; make names unique per item. And React 19.3 (September 2026) stabilized <ViewTransition>, which changes the integration rules.
Symptom 1: The Back Button Snaps
Forward navigations animate, back navigations do not. The reason is architectural: document.startViewTransition() must wrap an asynchronous DOM update, but popstate fires synchronously as the history entry changes. There is no update callback to wrap, so the browser cannot snapshot the old state. No snapshot, no transition. This is not a bug you can configure away; it is how the APIs compose.
The fix is to stop relying on the browser back button path and route back-navigations through a transition-aware API instead:
// intercept traversals with the Navigation API
navigation.addEventListener("navigate", (event) => {
if (!event.canIntercept || event.hashChange) return;
event.intercept({
async handler() {
const transition = document.startViewTransition(async () => {
await event.transitionWhile; // the navigation's DOM update
});
await transition.finished;
},
});
});In Next.js App Router, the practical version is simpler: drive back navigation through router.push() with an explicit URL instead of router.back(), and in Next.js 16.2+ you can pass typed transitionTypes on next/link so back and forward get different animations. The principle is the same everywhere: transitions need an async update to wrap, so give every navigation one.
Symptom 2: The Morph Silently Never Fires
The transition runs, but the shared element just crossfades instead of morphing. Nine times out of ten, the cause is a duplicate view-transition-name. The names must be unique across the old and new snapshots; when two elements share a name, the browser cannot pair them and skips the morph entirely, with no console warning.
The classic source in React apps: a shared component rendered in a list, where every instance gets the same hardcoded name:
// broken: every card claims the same name
function ProductCard({ product }) {
return (
<div style={{ viewTransitionName: "product-hero" }}>
<img src={product.image} />
</div>
);
}
// fixed: unique per item, only on the card being opened
function ProductCard({ product, isActive }) {
return (
<div
style={isActive ? { viewTransitionName: `product-${product.id}` } : undefined}
>
<img src={product.image} />
</div>
);
}Audit rule: view-transition-name should exist on exactly two elements during a transition, the outgoing one and the incoming one. Conditional names (only on the active item) are the pattern. Also clear names after the transition completes: pages restored from bfcache keep stale names, which then collide with the next navigation's names.
Symptom 3: Wrapped in <ViewTransition>, Nothing Animates
React 19.3 stabilized the <ViewTransition> component in September 2026, and it comes with one rule that trips everyone up: the DOM update must happen inside startTransition (or be triggered by a transition-aware router). If you set state in a plain event handler inside the wrapper, React applies it synchronously and there is nothing for the transition to capture:
import { ViewTransition, startTransition } from "react";
function Gallery() {
const [selected, setSelected] = useState(null);
return (
<ViewTransition>
{/* the update must be a transition, not a sync setState */}
<button onClick={() => startTransition(() => setSelected(id))}>
Open
</button>
</ViewTransition>
);
}What 19.3 changed: before it, the component only existed behind experimental flags and most guides used the manual document.startViewTransition imperative API. Now the declarative path is stable, which means new code should prefer the component and old experimental snippets you find online may use APIs that have since changed. When a tutorial does not mention 19.3, check its date.
Design the motion: once the plumbing works, the enter and exit keyframes are what users actually feel. Sketch them in our free CSS Animation Generator, preview the easing live, then drop the values into your ::view-transition-old() and ::view-transition-new() rules. The @starting-style enter/exit pattern those rules build on is covered in depth in our starting-style guide.
Debugging Checklist
- Back button snaps?
popstatenever triggers transitions. Intercept with the Navigation API or push explicitly with transition types. - Morph never fires? Audit
view-transition-namefor duplicates. Exactly two elements may share a name per transition. - Names collide after back/forward? Clear names post-transition; bfcache restores stale ones.
<ViewTransition>does nothing? The update must run insidestartTransition.- Following an old tutorial? Confirm it targets React 19.3+ stable, not the experimental API.
- Browser support: same-document transitions are Baseline (Chrome/Edge 111+, Safari 18+, Firefox 144+). The React object form needs Chromium 125+.
# Expansion draft: view-transition-pitfalls-nextjs-fix-guide
Cross-Document Transitions: A Different Feature Entirely
Everything in the main guide is about same-document transitions: state changes inside one page. Cross-document transitions, animating between two separate page loads, are a different feature with different rules, and they are what most people actually want for multi-page sites.
In Chromium 126 and later, you opt in with one CSS rule:
@view-transition {
navigation: auto;
}With that rule present, navigations between same-origin pages animate with a crossfade by default, and shared elements with matching view-transition-name values morph across the page boundary. No JavaScript needed. The catch is support: as of this writing, cross-document transitions are Chromium-only. Safari and Firefox handle same-document transitions but not cross-document ones, so your design must treat the animation as an enhancement. The page change has to make sense as an instant cut, because for a large share of visitors that is what they will get.
I am conservative about shipping cross-document transitions as a core part of a site's feel right now. Use them for polish on top of a design that works without them. Revisit when Safari and Firefox ship support. For Next.js App Router apps, which are effectively single-page apps with client-side routing, the same-document path from the main guide is the one that matters anyway.
Styling the Transition: The ::view-transition Pseudo-Elements
The default crossfade is fine, but the real control comes from the pseudo-element tree the browser builds during a transition. You style these like any other CSS:
/* the outgoing snapshot */
::view-transition-old(root) {
animation: slide-out 300ms ease-out both;
}
/* the incoming snapshot */
::view-transition-new(root) {
animation: slide-in 300ms ease-out both;
}
@keyframes slide-out {
to { transform: translateX(-40px); opacity: 0; }
}
@keyframes slide-in {
from { transform: translateX(40px); opacity: 0; }
}The root keyword targets the whole-page snapshot. For shared elements, the browser creates a ::view-transition-group() containing an image pair, and you can style groups by name: ::view-transition-group(product-42) lets you give one morph a different duration or easing than the page fade.
Three practical notes. First, these pseudo-elements only exist during a transition, so you cannot inspect them in DevTools the normal way; write the keyframes, trigger the transition, and watch. Second, keep the animations short. Anything past about 400ms starts feeling sluggish on navigations the user did not explicitly ask to savor. I default to 200-300ms for page transitions and shorter for shared-element morphs. Third, the old and new snapshots are flat images of the rendered page. Anything animated inside them, like a CSS spinner, freezes during the transition. Usually nobody notices. On slow transitions, they might.
Reduced Motion Is Not Optional
View transitions are motion, and some users experience motion as nausea, dizziness, or worse. The operating-system setting exists for a reason, and respecting it is not polish, it is baseline accessibility work. The pattern is short:
@media (prefers-reduced-motion: reduce) {
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
animation-duration: 0.01ms !important;
}
}This effectively disables the animation while still letting the transition complete instantly, which matters because your JavaScript may await transition.finished. Do not skip the transition call itself for reduced-motion users; skip the motion. The DOM update still needs to happen, and code waiting on the transition promise still needs it to resolve.
In React, the same principle applies one level up: the <ViewTransition> wrapper and the startTransition call stay, but the keyframes driving the pseudo-elements get neutered by the media query. I put this block in the global stylesheet next to the transition styles so they travel together. A transition style without its reduced-motion counterpart is unfinished work, and reviewers should flag it the same way they flag a missing focus style.
What View Transitions Cost: A Performance Reality Check
Transitions are not free. Understanding the cost helps you decide where they belong and where they do not.
To animate between two states, the browser captures a snapshot of the old DOM and renders the new DOM, then animates between the two images. On a heavy page, that means a full extra render plus the memory for two page-sized snapshots. On modern hardware this is fine for typical content pages. It gets expensive with huge DOMs (thousands of nodes), giant canvases, or pages with heavy backdrop filters, because every one of those costs render time twice.
The practical consequences: keep transitions away from your heaviest views unless you have measured them there. A product listing page with two hundred cards is a worse candidate than a settings page. If a transition stutters on a mid-range phone, the animation is hurting more than helping, and an instant cut is the better experience. Test on real mid-range hardware, not just your development machine.
One more cost people forget: shared-element morphs snapshot the element at its current size and animate the image. If the element contains text, the text is a raster image during the morph and can look slightly soft mid-flight. It sharpens when the transition completes and the live DOM takes over. Keep morphs short and nobody notices. Drag them out past half a second and the softness becomes visible.
My rule of thumb: transitions for navigations the user initiates deliberately (opening a detail view, going back), instant cuts for everything ambient (polling updates, background refreshes). Motion should confirm an action, not decorate the page.
Prevention Checklist
1. **Name audit before shipping shared elements.** Grep for view-transition-name and confirm every name is unique per transition and conditional on the active item, per Symptom 2 of the main guide. Duplicates are silent.
2. **Reduced-motion block ships with every transition style.** No exceptions, no follow-up tickets. It is part of the transition, not a separate task.
3. **Back-button behavior is tested, not assumed.** Click through forward, then use the browser back button, then forward again. If the design depends on animated back navigation, verify the Navigation API interception actually fires in your supported browsers.
4. **Old tutorials get a date check.** Anything written before React 19.3's stable <ViewTransition> (September 2026) may use the experimental API. If a snippet does not mention 19.3, verify each API it uses against current docs before copying it.
5. **Measure on a mid-range phone.** If the transition stutters there, shorten it or cut it. Your development machine is not your user.
Frequently Asked Questions
Can I animate the back button at all?
Yes, but not through the default back-button path. Intercept the traversal with the Navigation API as shown above, or replace the browser back affordance with an in-app back control that calls router.push(). The transition needs an async update to wrap; give it one.
Why is there no warning for duplicate names?
The spec treats an ambiguous pairing as "no shared element", which falls back to the default crossfade. It is valid behavior, just not what you wanted. This is why the audit habit matters: the browser will not tell you.
Do I still need the manual startViewTransition API?
For vanilla JS and for cases React does not cover, yes. In React 19.3+ apps, prefer <ViewTransition>; reach for the imperative API only when you need control the component does not expose.
Which browsers support same-document view transitions?
Baseline since 2025: Chrome and Edge 111+ (March 2023), Safari 18+, Firefox 144+ (October 2025). The React 19.3 integration path with the v2 object form additionally needs Chromium 125+.