page-transition-animation

Implements enter and exit page transitions in Next.js App Router using Framer Motion and the View Transitions API.

52|3|Updated Aug 20, 2026
One-click install
npx skills add https://github.com/Wayn-Git/Amethyst --skill page-transition-animation-wayn-git
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: page-transition-animation
Source: https://github.com/Wayn-Git/Amethyst/tree/main/agents/skills/page-transition-animation
Command: npx skills add https://github.com/Wayn-Git/Amethyst --skill page-transition-animation-wayn-git

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires framer-motion, next-view-transitions, and includes references (resource) components.

What problem does it solve? In the Next.js App Router, Framer Motion's AnimatePresence exit animations never fire on navigation because the router unmounts the old route and mounts the new one almost immediately, leaving no persistent wrapper to run the exit. This Skill explains the structural cause and provides two working solutions: a pathname-keyed AnimatePresence with the FrozenRouter pattern, and the native View Transitions API. ## Core Features & Use Cases - FrozenRouter pattern: Snapshots Next.js's internal LayoutRouterContext so the outgoing page keeps rendering its own content during the exit animation instead of flashing the new route's content. - template.tsx integration: Uses the App Router's per-navigation remounting template to host a keyed AnimatePresence with mode="wait" for clean exit-then-enter transitions. - View Transitions API alternative: Covers native document.startViewTransition, the next-view-transitions library, and shared-element morphs via view-transition-name CSS. - Debug checklist and verification harness: A seven-step AnimatePresence troubleshooting checklist plus a standalone HTML seek harness (?view= / ?phase=) for screenshot-verifying transition phases. - Use Case: A developer adds a crossfade between routes in a Next.js app, but the old page vanishes instantly. This Skill diagnoses the missing key and unmounted wrapper, then supplies the template.tsx, PageTransition, and FrozenRouter code to make exit animations fire. ## Quick Start Ask the AI to add an animated page transition between routes in your Next.js App Router app and fix the Framer Motion exit animation that does not fire on navigation.

Frequently Asked Questions about page-transition-animation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why doesn't Framer Motion AnimatePresence exit animation fire on Next.js navigation?▼

In the App Router, Next.js unmounts the old route and mounts the new one almost immediately, so AnimatePresence has no persistent wrapper or stable keyed child to animate out. The exit is skipped unless the wrapper persists and the child key changes per route.

How do I add page transition animations in Next.js App Router?▼

Use app/template.tsx, which remounts on every navigation, to host an AnimatePresence wrapper keyed on usePathname(). Wrap children in a motion component with initial, animate, and exit props, and add FrozenRouter so the outgoing page renders its own content.

Framer Motion vs View Transitions API for Next.js page transitions?▼

Framer Motion offers orchestrated, interruptible, staggered exit animations with broad browser support but needs the FrozenRouter setup. The View Transitions API is native and simpler via next-view-transitions, ideal for cross-page fades and shared-element morphs, but browser support is uneven.

Why does the exiting page show the new route's content during the animation?▼

The App Router swaps the route context before the exit animation finishes, so the outgoing subtree renders the new page's data. FrozenRouter fixes this by snapshotting LayoutRouterContext so the exiting page keeps rendering its previous content.

Does the View Transitions API work in all browsers?▼

No, browser support for the View Transitions API is still uneven. Always guard calls with if (document.startViewTransition) and fall back to a plain router.push, or use the next-view-transitions library which integrates it with App Router client navigation.

Should I use layout.tsx or template.tsx for per-route enter animations?▼

Use template.tsx, because layout.tsx persists across navigations and will not remount per route. A template remounts on every navigation, giving each route a fresh instance ideal for per-route enter animations.