Page transitions in Next.js
Ask Claude for page transitions in a Next.js site and it fixes the exit animation that never plays.
See it work
You give it
My Framer Motion exit animation never runs when I change pages in Next.js App Router. AnimatePresence wraps {children} in app/layout.tsx and each page has a motion.div with exit={{ opacity: 0 }}.
You get back
Your exit never fires because AnimatePresence never sees anything leave.
On navigation in the App Router:
1. `layout.tsx` persists, so AnimatePresence stays mounted. That part is fine.
2. Its child, `{children}`, has no `key` that changes with the route. AnimatePresence runs an exit only when a direct keyed child is removed. With no changing key, it sees the same child with new content, not "old removed, new added".
3. Even with a key, the outgoing page would render the new page's data while it fades, because the router has already switched its context.
Fix A, keeping Framer Motion:
- Put the transition in `app/template.tsx`, which remounts on every navigation, with a pathname-keyed `AnimatePresence mode="wait"` and `key={pathname}` from `usePathname()` on the motion wrapper.
- Wrap the page in a FrozenRouter, which holds the old router context so the old page keeps its own content while it exits.
Fix B, without exit wiring: the browser's View Transitions API, directly or through the next-view-transitions library. The browser snapshots the old page and crossfades, so there's no exit to wire up. Check support in the browsers your users have, and keep a plain fallback.
Which would you like?
First part of a run in Claude (Opus 5.5), Nov 2026
What it does
- Explains why exit animations fail on page change.
- Offers a Framer Motion fix and a built-in browser one.
- Includes a checklist for finding the fault.
What's inside
page-transition-animation/CREDITS.mdpage-transition-animation/LICENSEpage-transition-animation/README.mdpage-transition-animation/SKILL.mdpage-transition-animation/references/full-examples.md
How you use it
- Get the skill: one zip file. It comes with every paid plan.
- Add it to Claude. In Claude, open Customize (Plugins on newer screens), then Skills. Press +, then Create skill, then Upload a skill. In Claude Code, unzip it into ~/.claude/skills/ instead.
- Start a new chat and tell Claude what you need, the way the example above does. The skill takes it from there.
- Then ask for the work. Claude reaches for the skill when it fits, or name it: "use page-transition-animation".
Get this skill with a paid plan
The download comes with every paid plan, along with all 204 Claude skills and the rest of the AI toolkit. “Sites that don't look templated” in this folder is free, so you can try one first.