סקיל View Transitions
react-view-transitions הוא סקיל לקלוד קוד שמלמד אותו ליצור אנימציות מעבר חלקות וטבעיות באמצעות ה-View Transition API של הדפדפן ושל React. במקום מעברים חדים בין מסכים או בין מצבים, מקבלים תנועה רציפה שמסבירה למשתמש מה קרה: אלמנט שעובר בין עמודים, רשימה שמתארגנת מחדש, או מסך שנכנס בצורה חלקה. הסקיל מלמד מתי להוסיף אנימציה, איך לבנות אותה נכון, ואיך לשמור על נגישות וביצועים. בפרויקטי הפיתוח שאני מוביל, מעברים חלקים הם ההבדל בין אתר שמרגיש זול לבין אתר שמרגיש מוצר. במדריך תקבלו את כל הדפוסים, ארבעה תרחישי שימוש, וצ'קליסט לעבודה נכונה.
פקודת התקנה
npx skills add vercel-labs/agent-skills@vercel-react-view-transitions -g -y
ההתקנה מתבצעת דרך מנהל החבילות הרשמי של הסקילים בפקודה אחת. הסקיל הוא קובץ Markdown פתוח מאוסף הסקילים של Vercel. אפשר להוריד ולבדוק את הקוד דרך הכפתורים שבראש העמוד.
מה הסקיל כולל?
הסקיל מתעד את כל זרימת העבודה של אנימציות מעבר: מתי להשתמש בהן, איך להגדיר מה זז, מתי האנימציה מופעלת, ואיך לעצב אותה דרך מחלקות CSS.
קוד הסקיל המלא
---
name: vercel-react-view-transitions
description: Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.
license: MIT
metadata:
author: vercel
version: "1.0.0"
---
# 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** (layout-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. `ViewTransition` works out of the box. `npm ls react` may show a stable-looking version; this is expected.
- **Without Next.js:** Install `react@canary react-dom@canary` (`ViewTransition` is not in stable React).
- Browser support: Chromium 111+, 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. Copy the CSS recipes from `references/css-recipes.md` into the global stylesheet — do not write your own animation CSS.
---
## Core Concepts
### The `<ViewTransition>` Component
```jsx
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>`. 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**:
```jsx
// 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.
```jsx
<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:
```jsx
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`:
```jsx
<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:
```jsx
<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:
```jsx
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 do **not** trigger view transitions (`popstate` is synchronous, incompatible with `startViewTransition`). Use `router.push()` with an explicit URL instead.
### 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 Transitions
Same `name` on two VTs — one unmounting, one mounting — creates a shared element morph:
```jsx
<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 `name` can 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.
- `share` takes precedence over `enter`/`exit`. Think through each navigation path: when no matching pair forms (e.g., the target page doesn't have the same name), `enter`/`exit` fires instead. Consider whether the element needs a fallback animation for those paths.
- Never use a fade-out exit on pages with shared morphs — use a directional slide instead.
---
## Common Patterns
### Enter/Exit
```jsx
{show && (
<ViewTransition enter="fade-in" exit="fade-out"><Panel /></ViewTransition>
)}
```
### List Reorder
```jsx
{items.map(item => (
<ViewTransition key={item.id}><ItemCard item={item} /></ViewTransition>
))}
```
Trigger inside `startTransition`. Avoid wrapper `<div>`s between list and VT.
### 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:
```jsx
{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`
```jsx
<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:
```jsx
<ViewTransition>
<Suspense fallback={<Skeleton />}><Content /></Suspense>
</ViewTransition>
```
Directional reveal:
```jsx
<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"` Liberally
Without it, every VT fires the browser cross-fade on **every** transition — Suspense resolves, `useDeferredValue` updates, background revalidations. Always use `default="none"` and explicitly enable only desired triggers.
### 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 exits, nested VTs inside it do **not** fire their own enter/exit — only the outermost VT animates. Per-item staggered animations during page navigation are not possible today. See [react#36135](https://github.com/facebook/react/pull/36135) for an experimental opt-in fix.
---
## Next.js Integration
For Next.js setup (`experimental.viewTransition` flag, `transitionTypes` prop on `next/link`, 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, events API, troubleshooting.
- **`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`
מה זה react-view-transitions ולמה הסקיל הזה שונה?
react-view-transitions פותר פער מוכר: ממשקים שעובדים אבל מרגישים קופצניים. כשמסך מתחלף בבת אחת או כשרשימה מתארגנת מחדש בלי תנועה, המשתמש מאבד את ההקשר. אנימציות מעבר נכונות שומרות על הרציפות, אבל לכתוב אותן ידנית זה מסובך ונוטה לשבירה. הסקיל הופך את זה לפשוט ומובנה.
מה שמייחד אותו הוא העיקרון שכל אנימציה חייבת לתקשר משמעות. הסקיל לא מוסיף תנועה לשם היופי, אלא רק כשהיא מסבירה משהו: "זה אותו דבר, נכנסים לעומק", "הנתונים נטענו", או "משהו הופיע". הוא מסתמך על ה-View Transition API המובנה, כך שבדפדפנים שלא תומכים האנימציה פשוט מדלגת בחן בלי לשבור כלום. הוא גם מקפיד על נגישות ומכבד את העדפת המשתמש להפחית תנועה.
ההבדל מורגש בתחושה. ממשק עם מעברים נכונים מרגיש מלוטש ויקר, כמו אפליקציה מקצועית. בשילוב עם סקיל UI/UX Pro Max לעיצוב הכללי, מקבלים גם ממשק יפה וגם תנועה שמחיה אותו, וזה שילוב שמרים את הרמה של כל מוצר דיגיטלי.
מה react-view-transitions נותן לקלוד קוד?
הסקיל מוסיף לקלוד שפת אנימציה מודרנית: היכולת להוסיף תנועה משמעותית לממשק, בצורה נכונה, נגישה ובלי לשבור דפדפנים ישנים.
מעברי אלמנט משותף
קלוד יודע לגרום לאלמנט לעבור בצורה רציפה בין מצבים או עמודים, למשל תמונה שגדלה מתצוגה מקדימה לעמוד מלא. זה משדר למשתמש שמדובר באותו דבר, ושומר על ההקשר בזמן הניווט.
כניסה, יציאה ושינויי מצב
הסקיל מטפל באנימציות של רכיבים שמופיעים ונעלמים ושל רשימות שמתארגנות מחדש. במקום קפיצות חדות, הפריטים זזים בצורה טבעית, וזה הופך כל אינטראקציה לברורה ונעימה יותר.
אנימציה עם משמעות
העיקרון המנחה הוא שכל אנימציה חייבת לתקשר משהו. הסקיל נמנע מתנועה מיותרת שמסיחה את הדעת, ומוסיף רק מעברים שמסבירים מה קרה. כך הממשק נשאר נקי ומקצועי ולא עמוס.
נגישות וביצועים מובנים
הסקיל נשען על ה-API המובנה של הדפדפן, מדלג בחן בדפדפנים לא נתמכים, ומכבד את העדפת המשתמש להפחית תנועה. כך האנימציות לא פוגעות בנגישות ולא מכבידות על הביצועים.
ארבע היכולות הופכות את קלוד למי שיודע להחיות ממשק בצורה נכונה. בעבודות שלי, הוספת מעברים חלקים שדרגה את התחושה של אתרים ואפליקציות מ"בסדר" ל"מלוטש", בלי להעמיס על הביצועים.
למי הסקיל הזה מתאים?
מפתחי פרונטאנד ב-React: זה הקהל המובהק. הסקיל נותן דרך נקייה להוסיף אנימציות מעבר מקצועיות בלי ספריות כבדות ובלי קוד שביר. השילוב עם סקיל web-design-guidelines מבטיח שגם העיצוב וגם התנועה ברמה גבוהה.
יזמים ובוני מוצר: התחושה של אפליקציה משפיעה על איך שהמשתמש תופס את המוצר. מעברים חלקים משדרים איכות ומקצועיות, וזה משפיע על אמון ועל שימור.
מעצבי חוויית משתמש שעובדים עם קוד: הסקיל מתרגם כוונה עיצובית של תנועה למימוש נכון בקוד, כך שהחזון העיצובי לא הולך לאיבוד בשלב הפיתוח.
סוכנויות ופרילנסרים: מעברים מלוטשים הם בידול שמצדיק מחיר גבוה יותר. גם בעבודות קידום אורגני שלי, חוויית משתמש חלקה ומהירה תורמת גם למדדי הליבה של גוגל וגם לשהייה באתר.
מפתחי אפליקציות ווב מתקדמות: לאפליקציות בעלות ניווט מורכב, מעברי אלמנט משותף שומרים על התמצאות המשתמש בין מסכים, וזה משפר משמעותית את חוויית השימוש.
מי שפחות יתאים: אתר תוכן סטטי ופשוט לא חייב אנימציות מעבר, ולעיתים הן אף מיותרות. הסקיל מבריק דווקא בממשקים אינטראקטיביים עם מצבים ומסכים מתחלפים.
איך react-view-transitions עזר לי בפרויקטים אמיתיים
מעבר אלמנט משותף בגלריית מוצרים
בחנות אונליין, לחיצה על מוצר קפצה בחדות לעמוד המוצר. הוספתי מעבר אלמנט משותף, כך שתמונת המוצר גדלה בצורה רציפה מהגלריה לעמוד. המשתמשים הרגישו שהמעבר טבעי, וזה שיפר את תחושת האיכות של החנות.
רשימה שמתארגנת מחדש בצורה ברורה
בלוח משימות, סינון או מיון גרמו לפריטים לקפוץ למקומות חדשים, ומבלבל. עם הסקיל, הפריטים זזו בצורה חלקה למיקומם החדש, והמשתמש יכול היה לעקוב אחרי כל פריט בעין. הבהירות עלתה דרמטית.
מעברי מסלול חלקים ב-Next.js
באתר תדמית, מעבר בין עמודים הרגיש קופצני. שילבתי את הסקיל עם הניתוב של Next.js, וקיבלתי מעברים חלקים בין מסלולים. האתר התחיל להרגיש כמו אפליקציה אחת רציפה, לא כמו אוסף עמודים נפרדים.
אנימציות שלא פגעו בנגישות
לקוח דאג שאנימציות יפריעו למשתמשים רגישים לתנועה. הסקיל כיבד אוטומטית את העדפת הפחתת התנועה של המערכת, כך שמי שביקש פחות תנועה קיבל חוויה רגועה. כך נהנינו מהמעברים בלי להתפשר על נגישות.
ארבעת המקרים מראים שהסקיל לא רק מוסיף יופי, הוא מוסיף בהירות וחוויה. מעברים נכונים שומרים על ההקשר של המשתמש, משדרים איכות, ועושים זאת בלי לפגוע בנגישות או בביצועים.
סיכום
סקיל react-view-transitions הוא כלי מצוין לכל מי שבונה ממשקים ב-React ורוצה שירגישו מלוטשים. הוא מאפשר להוסיף אנימציות מעבר משמעותיות בעזרת ה-API המובנה של הדפדפן, בצורה נקייה, נגישה ובלי לשבור דפדפנים ישנים.
אם אתם מתחילים, בקשו מקלוד להוסיף מעבר אלמנט משותף בין תצוגה מקדימה לעמוד מלא. תראו כמה תנועה אחת נכונה משנה את התחושה של הממשק. משם, כל אינטראקציה יכולה לקבל את הליטוש הזה.
בפוסטים הבאים אמשיך לסקור סקילים שמשדרגים את הפרונטאנד ואת חוויית המשתמש. האתר של דביר נעמן מרכז את כל הכלים, השיטות והליווי שאני מציע לעסקים שרוצים לבנות מוצרים דיגיטליים מנצחים עם בינה מלאכותית.
שיתוף הסקיל
שאלות ותשובות
מה זה בעצם הסקיל react-view-transitions?
זה סקיל לקלוד קוד שמלמד אותו ליצור אנימציות מעבר חלקות באמצעות ה-View Transition API של הדפדפן ושל React. הוא מכסה מעברי אלמנט משותף, כניסה ויציאה של רכיבים, מעברי רשימה ומעברי מסלול. המטרה היא ממשק שמרגיש רציף ומלוטש במקום קופצני.
מה זה View Transition API?
זאת יכולת מובנית בדפדפנים מודרניים שמאפשרת לעבור בין שני מצבים של הממשק עם אנימציה חלקה אוטומטית. במקום לכתוב אנימציות מורכבות ידנית, מצהירים מה זז והדפדפן מבצע את המעבר. הסקיל עוטף את היכולת הזאת בהנחיות מסודרות לשימוש נכון ב-React.
איך מתקינים את הסקיל בקלוד קוד?
בפקודה אחת דרך מנהל החבילות הרשמי של הסקילים, כפי שמופיע בקופסת ההתקנה למעלה. הסקיל הוא קובץ Markdown פתוח מאוסף הסקילים של Vercel. אחרי ההתקנה אפשר לבקש מקלוד להוסיף מעברים, והוא יבחר את הדפוס המתאים ויישם אותו.
האם האנימציות יעבדו בכל הדפדפנים?
הסקיל נשען על ה-API המובנה, ובדפדפנים שתומכים בו האנימציות עובדות מצוין. בדפדפנים שלא תומכים, המעבר פשוט מדלג בחן בלי לשבור את הממשק, מה שנקרא שבירה עדינה. כך אפשר להשתמש בטכנולוגיה מודרנית בלי לדאוג למשתמשים בדפדפנים ישנים.
האם אנימציות לא פוגעות בנגישות?
הסקיל מקפיד על נגישות. הוא מכבד את העדפת המערכת להפחתת תנועה, כך שמשתמשים רגישים מקבלים חוויה רגועה יותר. בנוסף, העיקרון שכל אנימציה חייבת לתקשר משמעות מונע תנועה מיותרת שעלולה להסיח או להפריע.
האם זה עובד גם עם Next.js?
כן. לסקיל יש סעיף ייעודי לאינטגרציה עם Next.js, שמאפשר מעברים חלקים בין מסלולים. כך אתר שבנוי על Next.js יכול להרגיש כמו אפליקציה רציפה אחת במקום אוסף של עמודים נפרדים שמתחלפים בחדות.
מתי כדאי להוסיף אנימציית מעבר ומתי לא?
הכלל של הסקיל ברור: מוסיפים אנימציה רק כשהיא מתקשרת משהו, כמו רציפות, טעינת נתונים או הופעת אלמנט. אם אי אפשר לנסח מה האנימציה מסבירה, עדיף לוותר עליה. כך הממשק נשאר נקי ומקצועי, והתנועה תמיד משרתת מטרה.
האם הסקיל מתאים גם למתחילים ב-React?
כן. הסקיל מספק זרימת עבודה מסודרת ודפוסים מוכנים, כך שגם מפתח שלא מנוסה באנימציות יכול להוסיף מעברים מקצועיים. קלוד מיישם את הדפוס הנכון, והמפתח לומד תוך כדי איך עובדת הטכנולוגיה. זו דרך מצוינת להיכנס לעולם האנימציות בווב.