page-transition-animation

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

3|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/langgenius/due-date-hq-jwl --skill page-transition-animation-langgenius
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: page-transition-animation
Source: https://github.com/langgenius/due-date-hq-jwl/tree/main/.claude/skills/page-transition-animation
Command: npx skills add https://github.com/langgenius/due-date-hq-jwl --skill page-transition-animation-langgenius

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 AnimatePresence exit animations never fire on navigation because the router unmounts the old route before the exit animation can run. 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 LayoutRouterContext so the outgoing page keeps rendering its own content during the exit animation instead of flashing the new route. - 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 sequencing. - View Transitions API: Implements native cross-page fades and shared-element morphs via document.startViewTransition or the next-view-transitions library, with fallback guards. - Debug checklist: A seven-step ordered checklist for diagnosing why exit animations do not fire, plus a standalone HTML harness for screenshot-verifying transition phases. - Use Case: A developer adds a fade-and-slide transition between routes in a Next.js app, finds the exit animation skipped, and applies the FrozenRouter fix so the old page animates out correctly. ## Quick Start Ask the AI to add an animated page transition between routes in your Next.js App Router project and fix the exit animation that never fires on navigation.

Frequently Asked Questions about page-transition-animation

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

FAQPage Schema
Why does Framer Motion AnimatePresence exit animation not fire in Next.js App Router?

The App Router unmounts the old route and mounts the new one almost immediately, so AnimatePresence loses the exiting element before the animation runs. Fix it with a pathname-keyed AnimatePresence in template.tsx plus a FrozenRouter that snapshots LayoutRouterContext.

How do I add page transitions in Next.js App Router?

Place a client-side AnimatePresence in app/template.tsx, key the motion child with usePathname(), and wrap children in a FrozenRouter component. Alternatively, use the View Transitions API via document.startViewTransition or the next-view-transitions library.

Framer Motion vs View Transitions API for page transitions?

Framer Motion offers orchestrated, interruptible, staggered exit animations with broad browser support but needs the FrozenRouter setup. The View Transitions API is lighter and handles shared-element morphs natively, but browser support is uneven and needs a fallback guard.

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

The App Router swaps the route context before the exit animation finishes, so the outgoing tree renders the new page's data. FrozenRouter fixes this by freezing LayoutRouterContext with a ref so the exiting page keeps rendering its own content.

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

Use template.tsx because it remounts on every navigation, giving each route a fresh instance for per-route enter animations. layout.tsx persists across navigations and will not remount, so enter animations keyed to route changes will not retrigger.

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 CSS media queries to disable animations under prefers-reduced-motion.