Communitygithub.com

React 뷰 트랜지션 (View Transitions)

React의 View Transition API(`<ViewTransition>` 컴포넌트, `addTransitionType`, CSS 뷰 트랜지션 의사 요소)를 사용하여 부드럽고 네이티브 느낌의 애니메이션을 구현하는 가이드입니다.

React 뷰 트랜지션 (View Transitions)란 무엇인가요?

이 스킬은 React 애플리케이션에서 브라우저 네이티브 View Transition API(`document.startViewTransition`)를 활용하여 UI 상태 간 애니메이션을 구현하는 방법을 제공합니다. `<ViewTransition>` 컴포넌트로 *무엇을* 애니메이션할지 선언하고, `startTransition` / `useDeferredValue` / `Suspense`로 *언제* 트리거할지 결정하며, CSS 클래스로 *어떻게* 애니메이션할지 제어합니다. Next.js App Router에서 기본적으로 지원되며, 지원되지 않는 브라우저에서는 자동으로 우아하게 동작을 중단합니다. 공유 요소 전환, 목록 재정렬, 방향 탐색(앞으로/뒤로) 등 다양한 패턴을 우선순위별로 제공하며, `addTransitionType`을 통해 맥락에 따라 다른 애니메이션을 적용할 수 있습니다. 이 스킬은 React 전용이며, 타사 애니메이션 라이브러리 없이 네이티브에 가까운 페이지 전환을 원하는 개발자에게 적합합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/vercel-react-view-transitions

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

미리보기

스킬 README에서

React 뷰 트랜지션 (View Transitions) preview
React 뷰 트랜지션 (View Transitions) preview

문서

React 뷰 트랜지션

브라우저 네이티브 document.startViewTransition을 사용하여 UI 상태 간 애니메이션을 적용합니다. <ViewTransition>으로 무엇을 애니메이션할지 선언하고, startTransition / useDeferredValue / Suspense로 언제 트리거하며, CSS 클래스로 어떻게 제어합니다. 지원되지 않는 브라우저에서는 애니메이션이 우아하게 생략됩니다.

애니메이션 적용 시점

모든 <ViewTransition>은 공간적 관계나 연속성을 전달해야 합니다. 무엇을 전달하는지 설명할 수 없다면 추가하지 마세요.

다음 목록에서 해당되는 모든 패턴을 이 순서대로 구현하세요:

우선순위패턴전달하는 의미
1공유 요소 (name)"같은 것 — 더 깊이 들어감"
2Suspense 공개"데이터 로드 완료"
3목록 식별 (항목별 key)"같은 항목, 새로운 배열"
4상태 변경 (enter/exit)"무언가 나타남/사라짐"
5경로 변경 (페이지 수준)"새로운 장소로 이동"

이는 "하나만 고르라"는 목록이 아닌 구현 순서입니다. 앱에 맞는 모든 패턴을 구현하세요. 앱에 사용 사례가 없는 패턴만 건너뛰세요.

애니메이션 스타일 선택

맥락애니메이션이유
계층적 탐색 (목록 → 상세)타입 키 기반 nav-forward / nav-back공간적 깊이 전달
수평적 탐색 (탭 간)기본 <ViewTransition> (페이드) 또는 default="none"전달할 깊이가 없음
Suspense 공개enter/exit 문자열 props콘텐츠 도착
재검증 / 백그라운드 새로고침default="none"무음 — 애니메이션 불필요

방향성 슬라이드는 계층적 탐색(목록 → 상세)과 순서가 있는 시퀀스(이전/다음 사진, 캐러셀, 페이지네이션 결과)에만 사용하세요. 순서 시퀀스에서 방향은 위치를 전달합니다: "다음"은 오른쪽에서 슬라이드, "이전"은 왼쪽에서 슬라이드합니다. 수평적/순서 없는 탐색(탭 간)은 방향성 슬라이드를 사용하지 마세요 — 공간적 깊이를 잘못 암시합니다.


사용 가능 환경

  • Next.js: react@canary를 설치하지 마세요 — App Router가 이미 내부적으로 React canary를 번들링합니다. ViewTransition이 기본적으로 작동합니다. npm ls react가 안정적인 버전처럼 보일 수 있지만 이는 정상입니다.
  • Next.js 없음: react@canary react-dom@canary를 설치하세요 (ViewTransition은 안정적인 React에 포함되지 않았습니다).
  • 브라우저 지원: Chromium 125+ (React는 startViewTransition의 v2 객체 형태 필요), Firefox 144+, Safari 18.2+. 지원되지 않는 브라우저에서는 우아하게 동작을 중단합니다.

구현 워크플로우

기존 앱에 뷰 트랜지션을 추가할 때는 단계별로 references/implementation.md를 따르세요. 감사(audit)부터 시작하세요 — 건너뛰지 마세요. 해당하는 CSS는 references/css-recipes.md를 사용하고 앱에 맞게 조정하세요.


핵심 개념

<ViewTransition> 컴포넌트

import { ViewTransition } from 'react';

<ViewTransition>
  <Component />
</ViewTransition>

React가 자동으로 고유한 view-transition-name을 할당하고 내부적으로 document.startViewTransition을 호출합니다. 직접 startViewTransition을 호출하지 마세요.

애니메이션 트리거

트리거실행 시점
enter<ViewTransition>이 트랜지션 중 처음 삽입될 때
exit<ViewTransition>이 트랜지션 중 처음 제거될 때
update<ViewTransition> 내부의 DOM 변형, 또는 바로 옆 형제로 인해 경계 자체의 크기/위치가 변경될 때. 중첩 VT의 경우, 변형은 가장 안쪽 VT에 적용됨
share이름이 지정된 VT가 마운트 해제되고 동일한 트랜지션에서 같은 name을 가진 다른 VT가 마운트될 때

startTransition, useDeferredValue, 또는 Suspense만 VT를 활성화합니다. 일반 setState는 애니메이션을 실행하지 않습니다.

중요한 배치 규칙

<ViewTransition>은 DOM 노드보다 먼저 나타나야 enter/exit이 활성화됩니다:

// 작동함
<ViewTransition enter="auto" exit="auto">
  <div>콘텐츠</div>
</ViewTransition>

// 작동하지 않음 — div가 VT를 감싸서 enter/exit을 차단함
<div>
  <ViewTransition enter="auto" exit="auto">
    <div>콘텐츠</div>
  </ViewTransition>
</div>

뷰 트랜지션 클래스로 스타일링

Props

값: "auto" (브라우저 크로스페이드), "none" (비활성화), "class-name" (사용자 정의 CSS), 또는 타입별 애니메이션을 위한 { [type]: value } 객체.

<ViewTransition default="none" enter="slide-in" exit="slide-out" share="morph" />

default가 "none"이면, 명시적으로 나열되지 않은 모든 트리거가 꺼집니다.

CSS 의사 요소

  • ::view-transition-old(.class) — 나가는 스냅샷
  • ::view-transition-new(.class) — 들어오는 스냅샷
  • ::view-transition-group(.class) — 컨테이너
  • ::view-transition-image-pair(.class) — old + new 쌍

바로 사용할 수 있는 애니메이션 레시피는 references/css-recipes.md를 참조하세요.


트랜지션 타입

트랜지션에 addTransitionType으로 태그를 지정하면 VT가 맥락에 따라 다른 애니메이션을 선택할 수 있습니다. 여러 번 호출하여 타입을 쌓을 수 있습니다 — 트리 내의 다른 VT가 다른 타입에 반응합니다:

startTransition(() => {
  addTransitionType('nav-forward');
  addTransitionType('select-item');
  router.push('/detail/1');
});

객체를 전달하여 타입을 CSS 클래스에 매핑합니다. enter, exit, 그리고 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와 exit은 대칭일 필요가 없습니다. 예를 들어, 페이드 인하지만 방향성 슬라이드 아웃:

<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는 객체에 default 키가 필요합니다.

여러 페이지가 있는 앱의 경우, 타입 키 기반 VT를 재사용 가능한 래퍼로 추출하세요:

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() 및 브라우저 뒤로 가기 버튼

router.back()과 브라우저의 뒤로/앞으로 가기 버튼은 트랜지션 타입을 전달하지 않으므로 타입 키 기반 애니메이션(방향성 슬라이드)이 default로 해석되어 실행되지 않습니다 — 타입이 지정되지 않은 공유 요소 모핑은 계속 적용됩니다. 타입 기반 애니메이션을 사용하려면 명시적 URL과 함께 router.push()를 사용하세요.

타입과 Suspense

타입은 탐색 중에는 사용할 수 있지만 이후 Suspense 공개 중에는 사용할 수 없습니다(별도의 트랜지션, 타입 없음). 페이지 수준의 enter/exit에는 타입 맵을 사용하고, Suspense 공개에는 간단한 문자열 props를 사용하세요.

공유 요소 준비 상태

공유 요소 트랜지션은 이전 뷰와 새 뷰가 동일한 트랜지션에서 렌더링될 때만 요소를 쌍으로 연결할 수 있습니다. 들어오는 콘텐츠가 일시 중단되면 해당 업데이트에는 폴백만 존재합니다. 해결된 콘텐츠는 이후 Suspense 트랜지션에서 나타나며 별도로 애니메이션될 수 있습니다.


공유 요소 트랜지션

두 VT에 동일한 name이 있으면 — 하나가 마운트 해제되고 다른 하나가 마운트되면 — 공유 요소 모핑이 생성됩니다:

<ViewTransition name="hero-image">
  <img src="/thumb.jpg" onClick={() => startTransition(() => onSelect())} />
</ViewTransition>

// 다른 뷰에서 — 같은 이름
<ViewTransition name="hero-image">
  <img src="/full.jpg" />
</ViewTransition>
  • 주어진 name을 가진 VT는 한 번에 하나만 마운트될 수 있습니다 — 고유한 이름(photo-${id})을 사용하세요. 재사용 가능한 컴포넌트에 주의하세요: 이름이 지정된 VT가 있는 컴포넌트가 모달/팝오버 와 페이지 모두에서 렌더링되면 둘이 동시에 마운트되어 모핑이 깨집니다. 이름을 조건부로 만들거나(prop을 통해) 이름이 지정된 VT를 공유 컴포넌트에서 특정 소비자로 이동하세요.
  • share는 enter/exit보다 우선합니다. 각 탐색 경로를 생각해보세요: 일치하는 쌍이 형성되지 않으면(예: 대상 페이지에 같은 이름이 없는 경우) enter/exit이 대신 실행됩니다. 해당 경로에 대해 요소에 폴백 애니메이션이 필요한지 고려하세요.
  • 연결된 모핑이 조용히 실행되지 않는 두 가지 경우: (1) default="none"이고 명시적인 share prop이 없음 — share가 none으로 해석됨; (2) 타입 키 기반 share이고 탐색이 해당 타입을 추가하지 않음 — 일반 링크 클릭은 맵의 default를 해석함. 모핑해야 하는 모든 링크는 타입을 추가해야 합니다(next/link의 transitionTypes 또는 addTransitionType).
  • 공유 모핑이 있는 페이지에서 페이드 아웃 종료를 절대 사용하지 마세요 — 대신 방향성 슬라이드를 사용하세요.

일반적인 패턴

Enter/Exit

{show && (
  <ViewTransition enter="fade-in" exit="fade-out"><Panel /></ViewTransition>
)}

목록 재정렬

{items.map(item => (
  <ViewTransition key={item.id}><ItemCard item={item} /></ViewTransition>
))}

startTransition 내에서 트리거하세요. 목록과 VT 사이에 래퍼 <div>를 피하세요.

레이아웃 변위 모핑

활성화된 경계 내부의 콘텐츠만 위치를 애니메이션합니다 — 다른 모든 것은 새 레이아웃 위치로 순간이동합니다. 커지거나 줄어드는 목록 아래의 형제 콘텐츠를 기본 <ViewTransition>으로 감싸서 점프 대신 미끄러지듯 움직이게 하세요. Layout Displacement Morph를 참조하세요.

공유 요소와 목록 식별 결합

공유 요소와 목록 식별은 독립적인 관심사입니다 — 둘을 혼동하지 마세요. 목록 항목에 공유 요소(예: 상세 뷰로 모핑되는 이미지)가 포함된 경우, 두 개의 중첩된 <ViewTransition> 경계를 사용하세요:

{items.map(item => (
  <ViewTransition key={item.id}>                                      {/* 목록 식별 */}
    <Link href={`/items/${item.id}`}>
      <ViewTransition name={`item-image-${item.id}`} share="morph">   {/* 공유 요소 */}
        <Image src={item.image} />
      </ViewTransition>
      <p>{item.name}</p>
    </Link>
  </ViewTransition>
))}

외부 VT는 목록 재정렬/입장 애니메이션을 처리합니다. 내부 VT는 경로 간 공유 요소 모핑을 처리합니다. 두 레이어 중 하나라도 누락되면 해당 애니메이션이 조용히 실행되지 않습니다.

key로 재입장 강제

<ViewTransition key={searchParams.toString()} enter="slide-up" default="none">
  <ResultsGrid />
</ViewTransition>

주의: <Suspense>를 감싸는 경우 key를 변경하면 경계가 다시 마운트되고 데이터를 다시 가져옵니다.

Suspense 폴백에서 콘텐츠로

간단한 크로스페이드:

<ViewTransition>
  <Suspense fallback={<Skeleton />}><Content /></Suspense>
</ViewTransition>

방향성 공개:

<Suspense fallback={<ViewTransition exit="slide-down"><Skeleton /></ViewTransition>}>
  <ViewTransition enter="slide-up" default="none"><Content /></ViewTransition>
</Suspense>

더 많은 패턴은 references/patterns.md를 참조하세요.


여러 VT의 상호 작용

트리거와 일치하는 모든 VT가 단일 document.startViewTransition 내에서 동시에 실행됩니다. 다른 트랜지션(탐색 vs 나중 Suspense 해결)의 VT는 경쟁하지 않습니다.

default="none"을 의도적으로 사용하세요

이것 없이는 모든 VT가 모든 트랜지션에서 브라우저 크로스페이드를 실행합니다 — Suspense 해결, useDeferredValue 업데이트, 백그라운드 재검증. 이름 지정/공유 요소와 타입 키 기반 페이지 VT에는 default="none"을 사용하세요.

하지만 update(레이아웃/리플로우 모핑)와 share(명시적 share prop이 없는 이름 지정 쌍은 절대 모핑되지 않음)도 꺼집니다. 키가 있는 목록 항목과 변위된 형제는 update를 원합니다 — 이것들은 그대로 두거나 update="auto"로 설정하세요.

두 패턴의 공존

패턴 A — 방향성 슬라이드: 각 페이지에 타입 키 기반 VT, 탐색 중 실행. 패턴 B — Suspense 공개: 간단한 문자열 props, 데이터 로드 시 실행(타입 없음).

이들은 다른 시점에 실행되므로 공존할 수 있습니다. 둘 다 default="none"을 사용하면 상호 간섭을 방지합니다. 항상 enter와 exit을 쌍으로 사용하세요. 방향성 VT는 페이지 컴포넌트에 배치하고 레이아웃에는 배치하지 마세요.

중첩 VT 제한 사항

부모 VT가 내부에 중첩된 VT와 함께 하나의 단위로 마운트/마운트 해제될 때, 중첩된 VT는 자체 enter/exit을 실행하지 않습니다 — 가장 바깥쪽 VT만 애니메이션됩니다. (지속적인 부모 VT 내부에 마운트된 자식 VT는 enter/exit을 정상적으로 실행합니다.) 페이지 탐색 중 항목별 지연 애니메이션은 현재 Next.js에서 사용할 수 없습니다. 상류 실험 상태는 troubleshooting을 참조하세요.


Next.js 통합

Next.js 통합(next/link 및 useRouter의 transitionTypes, App Router 패턴, 서버 컴포넌트)에 대해서는 references/nextjs.md를 참조하세요.


접근성

references/css-recipes.md의 축소 동작 CSS를 항상 글로벌 스타일시트에 추가하세요.


참조 파일

전체 문서

모든 참조 파일이 확장된 전체 가이드는: AGENTS.md

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

alfathafp/portofolio-web-design

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

alfathafp/portofolio-web-design

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

alfathafp/portofolio-web-design

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

alfathafp/portofolio-web-design

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

관련 스킬