All skills
vercel-labs avatar

/react-view-transitions

@516bcc6 official
by Vercel Labsvercel-labs/agent-skills32k stars
2,784

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.

  • 9 files
  • 118.8 KB
  • MIT
  • Updated last month
  • GitHub

Use this Skill: https://skilld.dev/gh/vercel-labs/agent-skills/react-view-transitions

This session only. Nothing lands on disk.

referencestroubleshooting.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Troubleshooting

VT not activating: Ensure <ViewTransition> comes before any DOM node and the state update is inside startTransition. A raw viewTransitionName only isolates an element; it does not activate a React view transition.

"Two ViewTransition components with the same name": Names must be globally unique. Use IDs such as name={hero-${item.id}}. If a reusable component appears in multiple surfaces at once, move the name to the specific consumer or make it conditional.

Unrelated content crossfades: A bare VT uses the browser crossfade for every trigger. Set default="none" and opt in only to the triggers that boundary should handle.

Scrolling hangs while a transition animates: the ::view-transition overlay is position: fixed and its snapshots don't scroll — a browser limitation, not fixable in React (skipping snaps to the end). Keep reveal durations short; for scroll-driven UI use gesture transitions (experimental useSwipeTransition, if available).

Open popover flickers when a background transition settles: it's captured in root. Give it a real view-transition-name + isolation (not none) — see Isolate Elements from Parent Animations.

Popover closes or goes dead when clicked mid-transition: named participants are skipped by hit-testing while a transition runs; clicks land on what's beneath and read as outside-clicks. Portal the popover (see Isolate Elements from Parent Animations); brief dead clicks during the transition remain — that's the price of the name.

Shared morph silently not firing: share resolved to none. Either the VT has default="none" with no explicit share prop, or share is type-keyed and the navigation never adds the type — the link needs transitionTypes (or addTransitionType in the transition).

Shared morph competes with a page fade: A fading page exit dissolves the source while it is morphing. Remove that exit or use motion that preserves the shared element's continuity.

An enter animation runs even though Suspense never showed its fallback: The content-side VT became the topmost entering subtree during navigation. At that call site, add a host DOM element immediately outside Suspense. The host suppresses the nested enter during warm navigation but remains mounted so the VT can enter on a later fallback-to-content reveal. Keep the host outside Suspense, not inside the reusable crossfade; do nothing when a direct host already exists.

Section below a list teleports instead of gliding: it's outside any activated boundary, its VT has default="none" (which disables update), or it isn't an immediate sibling of the changing content. See Layout Displacement Morph.

router.back() and browser back/forward skip the directional slide: traversals carry no transition types, so type-keyed maps resolve to default — untyped shared-element morphs still apply. Use router.push() for typed animations.

flushSync skips animations: Use startTransition instead.

Only updates animate (no enter/exit): Without <Suspense>, React treats swaps as updates. Conditionally render the VT itself, or wrap in <Suspense>.

Suspense reveal does not animate: Suspense resolves in a separate transition without navigation types. Use string enter/exit props rather than a type map.

Layout VT prevents page VTs from animating: Nested VTs skip their own enter/exit when they mount or unmount as one unit with a parent VT. Keep route boundaries in pages, not a layout wrapping {children}. React has experimental upstream parentEnter/parentExit work (PR #36690), but those props are not currently available in the Next.js client runtime; do not recommend them in a Next.js app unless the installed runtime and docs explicitly include them.

Same-route content does not animate with update: Nested VTs can own the mutation before an outer boundary sees it. For a real identity change, use key with a stable name and share instead.

List reorder not animating with useOptimistic: Optimistic values resolve before snapshot. Use committed state for list order.

TS error "Property 'default' is missing": Type-keyed objects require a default key.

Hash fragments cause scroll jumps: Navigate without hash; scroll programmatically after navigation.

Backdrop-blur flickers: Use the Backdrop-Blur Workaround.

border-radius lost during transitions: Apply border-radius directly to the captured element.

Skeleton controls slide away: Give matching controls the same viewTransitionName.

Batching: Multiple updates during animation are batched. A→B→C→D becomes B→D.

Source: SKILL.md on GitHub

No third-party reports yet.

Signed by skilld at 516bcc6. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated last month
metadata
{
  "author": "vercel",
  "version": "1.0.0"
}
  • React
  • view-transitions
  • animations
  • next.js
  • css
  • navigation
  • shared-elements
  • suspense

README badge

README badge for vercel-labs/agent-skills/react-view-transitions

Implements smooth animations between UI states using the browser's native View Transition API, with a `<ViewTransition>` component that declares animation targets and CSS classes that define animation behavior. Targets Next.js and React apps with support for shared element morphs, list reorders, directional navigation, and Suspense reveals, with graceful fallback for unsupported browsers.

Generated from the current SKILL.md.

Does this work in Next.js?
Yes. In Next.js, the App Router already bundles React canary internally, so `ViewTransition` works out of the box without installing `react@canary`. For setup details and App Router patterns, see the `references/nextjs.md` file in the skill.
What browsers support view transitions?
Chromium 111+, Firefox 144+, and Safari 18.2+. Unsupported browsers gracefully skip animations.
Can I use this without React canary outside Next.js?
Only if you install `react@canary react-dom@canary`. `ViewTransition` is not available in stable React.
Does this work with `router.back()` or the browser back button?
No. `popstate` is synchronous and incompatible with `startViewTransition`. Use `router.push()` with an explicit URL instead to trigger view transitions on navigation.
Can I call `document.startViewTransition` directly?
No. Never call `startViewTransition` yourself. The `<ViewTransition>` component wraps it automatically and must be triggered by `startTransition`, `useDeferredValue`, or `Suspense`.

Generated from the current SKILL.md. These answers refresh after source changes.