Vercel React View Transitions
VercelOfficialCreated by vercel
- Skill
- Tool integration
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to using the React View Transition API to animate UI state changes, route transitions, and shared element morphs. It covers the use of the ViewTransition component, CSS pseudo-elements for styling, and the integration of transition types to manage directional navigation. The guide emphasizes a systematic implementation workflow, starting with an audit of navigation patterns and Suspense boundaries, followed by the application of CSS recipes and persistent element isolation.
What it does
- Provides patterns for page-level, shared element, and list reorder animations.
- Explains how to use addTransitionType for context-aware navigation animations.
- Details the use of CSS pseudo-elements for controlling animation behavior.
- Outlines the implementation order for different animation patterns.
- Offers guidance on integrating transitions within Next.js and React 19.3+ environments.
- Includes accessibility considerations for reduced motion.
When to use it
- When implementing page transitions or route change animations.
- When creating shared element morphs between different UI states.
- When animating the entry or exit of components.
- When managing directional navigation animations like forward and back.
- When coordinating animations with Suspense reveals.
- When animating list reordering without third-party libraries.
Advantages
- Leverages native browser capabilities for UI transitions.
- Provides a clear, step-by-step audit and implementation workflow.
- Supports graceful degradation for unsupported browsers.
- Enables complex animations through CSS class mapping.
- Integrates directly with React and Next.js primitives.
Usage examples
- “How do I animate a page transition in my Next.js app?”
- Wrap your page component in a ViewTransition component and use addTransitionType within a startTransition block to trigger the animation during navigation.
- “How can I make an image morph from a list to a detail view?”
- Assign the same name prop to the ViewTransition component wrapping the image in both the list and the detail view, and ensure the share prop is configured.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/vercel-labs/vercel-react-view-transitions/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip vercel-react-view-transitions.zip -d .agents/skills
Documentation by vercel
React View Transitions
Animate between UI states using the browser's native document.startViewTransition. Declare what with <ViewTransition>, trigger when with startTransition / useDeferredValue / Suspense, control how with CSS classes. Unsupported browsers skip animations gracefully.
When to Animate
Every <ViewTransition> should communicate a spatial relationship or continuity. If you can't articulate what it communicates, don't add it.
Implement all applicable patterns from this list, in this order:
| Priority | Pattern | What it communicates |
|---|---|---|
| 1 | Shared element (name) | "Same thing — going deeper" |
| 2 | Suspense reveal | "Data loaded" |
| 3 | List identity (per-item key) | "Same items, new arrangement" |
| 4 | State change (enter/exit) | "Something appeared/disappeared" |
| 5 | Route change (page-level) | "Going to a new place" |
This is an implementation order, not a "pick one" list. Implement every pattern that fits the app. Only skip a pattern if the app has no use case for it.
Choosing Animation Style
| Context | Animation | Why |
|---|---|---|
| Hierarchical navigation (list → detail) | Type-keyed nav-forward / nav-back | Communicates spatial depth |
| Lateral navigation (tab-to-tab) | Bare <ViewTransition> (fade) or default="none" | No depth to communicate |
| Suspense reveal | enter/exit string props | Content arriving |
| Revalidation / background refresh | default="none" | Silent — no animation needed |
Reserve directional slides for hierarchical navigation (list → detail) and ordered sequences (prev/next photo, carousel, paginated results). For ordered sequences, the direction communicates position: "next" slides from right, "previous" from left. Lateral/unordered navigation (tab-to-tab) should not use directional slides — it falsely implies spatial depth.
Availability
Next.js: Do not install
react@canary— the App Router already bundles React canary internally.ViewTransitionworks out of the box.npm ls reactmay show a stable-looking version; this is expected.Without Next.js: Use stable
reactandreact-dom19.3 or newer (ViewTransitionandaddTransitionTypebecame stable in React 19.3). Earlier stable React versions do not include these APIs.Browser support: Chromium 125+ (React needs the v2 object form of
startViewTransition), Firefox 144+, Safari 18.2+. Graceful degradation on unsupported browsers.
Implementation Workflow
When adding view transitions to an existing app, follow references/implementation.md step by step. Start with the audit — do not skip it. Use references/css-recipes.md for the applicable CSS and adapt it to the app.
Core Concepts
The <ViewTransition> Component
import { ViewTransition } from 'react';
<ViewTransition>
<Component />
</ViewTransition>React auto-assigns a unique view-transition-name and calls document.startViewTransition behind the scenes. Never call startViewTransition yourself.
Animation Triggers
| Trigger | When it fires |
|---|---|
| enter | <ViewTransition> first inserted during a Transition |
| exit | <ViewTransition> first removed during a Transition |
| update | DOM mutations inside a <ViewTransition>, or the boundary itself changing size/position due to an immediate sibling. With nested VTs, mutation applies to the innermost one |
| share | Named VT unmounts and another with same name mounts in the same Transition |
Only startTransition, useDeferredValue, or Suspense activate VTs. Regular setState does not animate.
Critical Placement Rule
<ViewTransition> only activates enter/exit if it appears before any DOM nodes:
// Works
<ViewTransition enter="auto" exit="auto">
<div>Content</div>
</ViewTransition>
// Broken — div wraps the VT, suppressing enter/exit
<div>
<ViewTransition enter="auto" exit="auto">
<div>Content</div>
</ViewTransition>
</div>Styling with View Transition Classes
Props
Values: "auto" (browser cross-fade), "none" (disabled), "class-name" (custom CSS), or { [type]: value } for type-specific animations.
<ViewTransition default="none" enter="slide-in" exit="slide-out" share="morph" />If default is "none", all triggers are off unless explicitly listed.
CSS Pseudo-Elements
::view-transition-old(.class)— outgoing snapshot::view-transition-new(.class)— incoming snapshot::view-transition-group(.class)— container::view-transition-image-pair(.class)— old + new pair
See references/css-recipes.md for ready-to-use animation recipes.
Transition Types
Tag transitions with addTransitionType so VTs can pick different animations based on context. Call it multiple times to stack types — different VTs in the tree react to different types:
startTransition(() => {
addTransitionType('nav-forward');
addTransitionType('select-item');
router.push('/detail/1');
});Pass an object to map types to CSS classes. Works on enter, exit, and share:
<ViewTransition
enter={{ 'nav-forward': 'slide-from-right', 'nav-back': 'slide-from-left', default: 'none' }}
exit={{ 'nav-forward': 'slide-to-left', 'nav-back': 'slide-to-right', default: 'none' }}
share={{ 'nav-forward': 'morph-forward', 'nav-back': 'morph-back', default: 'morph' }}
default="none"
>
<Page />
</ViewTransition>enter and exit don't have to be symmetric. For example, fade in but slide out directionally:
<ViewTransition
enter={{ 'nav-forward': 'fade-in', 'nav-back': 'fade-in', default: 'none' }}
exit={{ 'nav-forward': 'nav-forward', 'nav-back': 'nav-back', default: 'none' }}
default="none"
>TypeScript: ViewTransitionClassPerType requires a default key in the object.
For apps with multiple pages, extract the type-keyed VT into a reusable wrapper:
export function DirectionalTransition({ children }: { children: React.ReactNode }) {
return (
<ViewTransition
enter={{ 'nav-forward': 'nav-forward', 'nav-back': 'nav-back', default: 'none' }}
exit={{ 'nav-forward': 'nav-forward', 'nav-back': 'nav-back', default: 'none' }}
default="none"
>
{children}
</ViewTransition>
);
}router.back() and Browser Back Button
router.back() and the browser's back/forward buttons carry no transition types, so type-keyed animations (directional slides) resolve to their default and don't play — untyped shared-element morphs still apply. For typed animations, use router.push() with an explicit URL.
Types and Suspense
Types are available during navigation but not during subsequent Suspense reveals (separate transitions, no type). Use type maps for page-level enter/exit; use simple string props for Suspense reveals.
Shared Element Readiness
A shared element transition can pair elements only when both the old and new views are rendered in the same Transition. If incoming content suspends, only its fallback exists for that update; the resolved content appears in a later Suspense transition and can be animated separately.
Shared Element Transitions
Same name on two VTs — one unmounting, one mounting — creates a shared element morph:
<ViewTransition name="hero-image">
<img src="/thumb.jpg" onClick={() => startTransition(() => onSelect())} />
</ViewTransition>
// On the other view — same name
<ViewTransition name="hero-image">
<img src="/full.jpg" />
</ViewTransition>Only one VT with a given
namecan be mounted at a time — use unique names (photo-${id}). Watch for reusable components: if a component with a named VT is rendered in both a modal/popover and a page, both mount simultaneously and break the morph. Either make the name conditional (via a prop) or move the named VT out of the shared component into the specific consumer.sharetakes precedence overenter/exit. Think through each navigation path: when no matching pair forms (e.g., the target page doesn't have the same name),enter/exitfires instead. Consider whether the element needs a fallback animation for those paths.Two ways a wired-up morph silently never fires: (1)
default="none"with no explicitshareprop — share resolves to none; (2) type-keyedsharewhere the navigation never adds the type — a plain link click resolves the map'sdefault. Every link that should morph must add the type (transitionTypesonnext/link, oraddTransitionType).Never use a fade-out exit on pages with shared morphs — use a directional slide instead.
Common Patterns
Enter/Exit
{show && (
<ViewTransition enter="fade-in" exit="fade-out"><Panel /></ViewTransition>
)}List Reorder
{items.map(item => (
<ViewTransition key={item.id}><ItemCard item={item} /></ViewTransition>
))}Trigger inside startTransition. Avoid wrapper <div>s between list and VT.
Layout Displacement Morph
Only content inside an activated boundary animates position — everything else teleports to its new layout spot. Wrap the sibling content below a growing/shrinking list in a bare <ViewTransition> so it glides instead of jumping. See Layout Displacement Morph.
Composing Shared Elements with List Identity
Shared elements and list identity are independent concerns — don't confuse one for the other. When a list item contains a shared element (e.g., an image that morphs into a detail view), use two nested <ViewTransition> boundaries:
{items.map(item => (
<ViewTransition key={item.id}> {/* list identity */}
<Link href={`/items/${item.id}`}>
<ViewTransition name={`item-image-${item.id}`} share="morph"> {/* shared element */}
<Image src={item.image} />
</ViewTransition>
<p>{item.name}</p>
</Link>
</ViewTransition>
))}The outer VT handles list reorder/enter animations. The inner VT handles the cross-route shared element morph. Missing either layer means that animation silently doesn't happen.
Force Re-Enter with key
<ViewTransition key={searchParams.toString()} enter="slide-up" default="none">
<ResultsGrid />
</ViewTransition>Caution: If wrapping <Suspense>, changing key remounts the boundary and refetches.
Suspense Fallback to Content
Simple cross-fade:
<ViewTransition>
<Suspense fallback={<Skeleton />}><Content /></Suspense>
</ViewTransition>Directional reveal:
<Suspense fallback={<ViewTransition exit="slide-down"><Skeleton /></ViewTransition>}>
<ViewTransition enter="slide-up" default="none"><Content /></ViewTransition>
</Suspense>For more patterns, see references/patterns.md.
How Multiple VTs Interact
Every VT matching the trigger fires simultaneously in a single document.startViewTransition. VTs in different transitions (navigation vs later Suspense resolve) don't compete.
Use default="none" Deliberately
Without it, every VT fires the browser cross-fade on every transition — Suspense resolves, useDeferredValue updates, background revalidations. Use default="none" on named/shared elements and type-keyed page VTs.
But it also turns off update (layout/reflow morphs) and share (a named pair with no explicit share prop never morphs). Keyed list items and displaced siblings want update — leave them bare or set update="auto".
Two Patterns Coexist
Pattern A — Directional slides: Type-keyed VT on each page, fires during navigation. Pattern B — Suspense reveals: Simple string props, fires when data loads (no type).
They coexist because they fire at different moments. default="none" on both prevents cross-interference. Always pair enter with exit. Place directional VTs in page components, not layouts.
Nested VT Limitation
When a parent VT mounts/unmounts as one unit with nested VTs inside it, the nested ones do not fire their own enter/exit — only the outermost VT animates. (A child VT mounted inside a persistent parent VT fires enter/exit normally.) Per-item staggered animations during page navigation are not currently available in Next.js; see troubleshooting for the upstream experimental status.
Next.js Integration
For Next.js integration (transitionTypes on next/link and useRouter, App Router patterns, Server Components), see references/nextjs.md.
Accessibility
Always add the reduced motion CSS from references/css-recipes.md to your global stylesheet.
Reference Files
references/implementation.md — Step-by-step implementation workflow.
references/patterns.md — Patterns, animation timing, and events API.
references/troubleshooting.md — Symptom-driven debugging and runtime limitations.
references/css-recipes.md — Ready-to-use CSS animation recipes.
references/nextjs.md — Next.js App Router patterns and Server Component details.
Full Compiled Document
For the complete guide with all reference files expanded: AGENTS.md
Files
- AGENTS.md57.7 KiB
- ATTRIBUTION.mdAdded by AutoGineer899 B
- README.md2.2 KiB
- SKILL.md14.2 KiB
- metadata.json852 B
- references/css-recipes.md8.1 KiB
- references/implementation.md9.1 KiB
- references/nextjs.md10.4 KiB
- references/patterns.md11.7 KiB
- references/troubleshooting.md4.8 KiB
references/nextjs.md
View Transitions in Next.js
Setup
<ViewTransition> works in the App Router with no configuration. The bundled React channel includes it, and Next.js navigations run in React Transitions. Do not add the old experimental.viewTransition flag or install react@canary into a Next.js app.
Read the current Next.js View Transitions guide and the matching guide under node_modules/next/dist/docs/ before editing. The installed version is authoritative for flags and API signatures.
Because every link click is a transition, any VT with default="auto" fires on every navigation — use default="none" to prevent competing animations.
For unexpected or broken animation behavior, see troubleshooting.md.
Next.js Implementation Additions
When following implementation.md, apply these additions:
Step 4: Use transitionTypes on <Link> — see The transitionTypes Prop. If the animation depends on dynamic destination content, also see When Content Must Be Ready.
After Step 6: For same-route dynamic segments (e.g., /collection/[slug]), use the key + name + share pattern — see Same-Route Dynamic Segment Transitions.
Layout-Level ViewTransition
Do NOT add a layout-level VT wrapping {children} if pages have their own VTs. A nested VT skips its own enter/exit only when it mounts or unmounts as one unit with a parent VT, which is exactly what a layout VT wrapping {children} causes — page-level enter/exit will silently not work. Remove the layout VT entirely. Nesting is otherwise fine and sometimes required: a child VT inside a persistent parent VT fires enter/exit normally, and two nested boundaries are the intended shape for shared elements inside list items.
A bare <ViewTransition> in layout works only if pages have no VTs of their own.
Layouts persist across navigations — enter/exit only fire on initial mount, not on route changes. Don't use type-keyed maps in layouts. Because layouts persist, chrome hosted in one (nav, sidebar, player) keeps its state across navigations for free — no Activity needed. Reserve Activity for in-page show/hide (see Composing with Activity).
The transitionTypes Prop on next/link
No wrapper component needed, works in Server Components:
<Link href="/products/1" transitionTypes={['transition-to-detail']}>
View Product
</Link>Replaces the manual pattern of onNavigate + startTransition + addTransitionType + router.push(). Reserve manual startTransition for non-link interactions (buttons, forms).
Availability: transitionTypes shipped in Next.js 16.2.0 (it is not gated on the experimental.viewTransition flag). If unavailable, use startTransition + addTransitionType + router.push() (see Programmatic Navigation). To check: grep -r "transitionTypes" node_modules/next/dist/ — if no results, fall back to programmatic navigation.
When Content Must Be Ready
A page transition can animate whatever Next.js renders during navigation, including a loading fallback. A shared content-to-content morph only works when the incoming content is ready as the navigation commits; content that has not rendered yet cannot form the incoming half of the pair.
When an animation depends on dynamic destination content, use Next.js prefetching and caching to make that content available ahead of time. <Link> automatically prefetches in production, but the default behavior for dynamic routes may only prefetch a shell or loading boundary. Set prefetch={true} to prefetch the full route, and cache the data needed to render the shared content.
<Link href={nextHref} prefetch={true} transitionTypes={['nav-forward']}>
Next
</Link>With Cache Components, put reusable route data in a cached scope such as use cache so prefetching can include it. If the destination remains behind an unresolved Suspense boundary, the route transition animates the fallback instead. The content resolves in a separate Suspense transition without the original nav-forward or nav-back type, so give that content its own reveal animation when needed.
Verify directional transitions in a production build with a cold client cache. Development mode does not run automatic <Link> prefetching.
See the Next.js View Transitions guide and Prefetching guide.
Programmatic Navigation
'use client';
import { useRouter } from 'next/navigation';
function DetailButton({ href }: { href: string }) {
const router = useRouter();
return (
<button onClick={() => router.push(href, { transitionTypes: ['nav-forward'] })}>
Open
</button>
);
}The transitionTypes option adds the types inside the router's navigation Transition. Use startTransition + addTransitionType for non-navigation state updates, or as a fallback on Next.js versions without the router option.
Server-Side Filtering with router.replace
For search/sort/filter that re-renders on the server (via URL params), use startTransition + router.replace. VTs activate because the state update is inside startTransition:
'use client';
import { useRouter } from 'next/navigation';
import { startTransition } from 'react';
function SortControl() {
const router = useRouter();
function handleSort(sort: string) {
startTransition(() => {
router.replace(`?sort=${sort}`);
});
}
return <button onClick={() => handleSort('newest')}>Newest</button>;
}List items wrapped in <ViewTransition key={item.id}> will animate reorder. This is the server-component alternative to the client-side Searchable Grid pattern.
For immediate control feedback while the route commits, use useOptimistic for the button state but keep the animated list tied to the committed sort value. See Exclude Elements with useOptimistic.
Routing-Driven Tabs
The generalized sliding indicator (Sliding Indicator) driven by navigation instead of local state: tabs are <Link>s, active comes from the URL (a server prop), and useOptimistic slides the indicator instantly while the route commits. Key the mounted indicator to committed active so the bar lands where navigation actually settles.
'use client';
import Link from 'next/link';
import { useOptimistic, useTransition, ViewTransition } from 'react';
export function Tabs({ tabs, active, indicatorName = 'tab-indicator' }) {
const [optimisticActive, setOptimisticActive] = useOptimistic(active);
const [, startTransition] = useTransition();
return (
<nav>
{tabs.map(t => (
<Link key={t.value} href={t.href} scroll={false}
aria-current={optimisticActive === t.value ? 'page' : undefined}
onNavigate={() => startTransition(() => setOptimisticActive(t.value))}>
<span>{t.label}</span>
{active === t.value && (
<ViewTransition name={indicatorName} share="tab-underline">
<span className="active-underline" aria-hidden />
</ViewTransition>
)}
</Link>
))}
</nav>
);
}Two-Layer Pattern (Directional + Suspense)
Directional slides + Suspense reveals coexist because they fire at different moments. Place the directional VT in the page component (not layout):
<ViewTransition
enter={{ "nav-forward": "slide-from-right", default: "none" }}
exit={{ "nav-forward": "slide-to-left", default: "none" }}
default="none"
>
<div>
<Suspense fallback={<ViewTransition exit="slide-down"><Skeleton /></ViewTransition>}>
<ViewTransition enter="slide-up" default="none"><Content /></ViewTransition>
</Suspense>
</div>
</ViewTransition>loading.tsx as Suspense Boundary
Next.js loading.tsx is an implicit <Suspense> boundary. Wrap the skeleton in <ViewTransition exit="..."> in loading.tsx, and the content in <ViewTransition enter="..." default="none"> in the page:
// loading.tsx
<ViewTransition exit="slide-down"><PhotoGridSkeleton /></ViewTransition>
// page.tsx
<ViewTransition enter="slide-up" default="none"><PhotoGrid photos={photos} /></ViewTransition>Same rules as explicit <Suspense>: use simple string props (not type maps) since Suspense reveals fire without transition types.
Shared Elements Across Routes
// List page
{products.map((product) => (
<Link key={product.id} href={`/products/${product.id}`} transitionTypes={['nav-forward']}>
<ViewTransition name={`product-${product.id}`}>
<Image src={product.image} alt={product.name} width={400} height={300} />
</ViewTransition>
</Link>
))}
// Detail page — same name
<ViewTransition name={`product-${product.id}`}>
<Image src={product.image} alt={product.name} width={800} height={600} />
</ViewTransition>If the pair's share is type-keyed (or classed via CSS that expects a type), every <Link> between the two views must carry the type via transitionTypes — a plain link click resolves the share map's default, and if that's none the morph silently never fires.
Same-Route Dynamic Segment Transitions
When navigating between dynamic segments of the same route (e.g., /collection/[slug]), the router swaps subtrees keyed by the segment value rather than doing a plain unmount/mount — enter/exit don't fire reliably. Use key + name + share:
<Suspense fallback={<Skeleton />}>
<ViewTransition key={slug} name="collection-content" share="auto" default="none">
<Content slug={slug} />
</ViewTransition>
</Suspense>key={slug}forces unmount/remount on changeThe stable
namepairs the outgoing and incoming containers;share="auto"creates the crossfadeVT inside
<Suspense>(without keying Suspense) keeps old content visible during loading
Server Components
<ViewTransition>works in both Server and Client Components<Link transitionTypes>works in Server Components — no'use client'neededrouter.push(..., { transitionTypes }),addTransitionType, andstartTransitionrequire Client Components
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- vercel
- Publisher
- Vercel (Official)
- Source
- vercel-labs/agent-skills · skills/react-view-transitions · commit 1a2c79d
- Licence
- MIT License (redistribution allowed)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by vercel or Vercel.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download vercel-react-view-transitions.zip