Question presented to candidate:
"Designers want the photo detail page to slide in from the right when you open it and slide back when you return to the gallery, and no animation for other navigations. Next.js 16.2 added transitionTypes on <Link>. How does that work end to end, and what do you need in the app today?"
What a strong answer should cover:
- The browser View Transitions API snapshots the old and new UI and animates between them; React's
<ViewTransition>component drives it declaratively. - App Router navigations are React Transitions, so
<ViewTransition>animates on navigation automatically. transitionTypes={["nav-forward"]}on<Link>(added in 16.2) passes those strings toReact.addTransitionTypeinside the navigation;<ViewTransition enter={{ "nav-forward": "...", default: "none" }}>maps types to CSS classes.- The CSS lives in
::view-transition-old(.class)/::view-transition-new(.class)rules; respectprefers-reduced-motion. - Version detail:
<ViewTransition>is stable in React 19.3 and imported fromreact; on 16.4.2 the oldexperimental.viewTransitionflag is rejected, and browsers without support simply do not animate.
Clarifying questions expected:
- "Which navigations count as forward and back?" β the type is not automatic; you assign it per link.
- "What about the browser back button?" β it is not a
<Link>click, so it carries no type.
Code / implementation expected: Yes β two pages, the links with types, a shared <ViewTransition> wrapper and the CSS.