nextjs-framer-motion-animations — Claude Code skill: Motion in Next.js
nextjs-framer-motion-animations — a skill that walks an agent through adding or fixing Motion for React in a Next.js app: gestures, exits, layout shifts, shared elements, scroll effects, route changes.
MIT 183 installs ★ 4 updated 2026-09-14
npx skills add tristanmanchester/agent-skills --skill nextjs-framer-motion-animations -a claude-codeWhat nextjs-framer-motion-animations does
The agent opens the component, checks whether the app uses the App or Pages router, reads the lockfile and the build config, then picks a mechanism: a motion element for a small tween, variants with stagger across children, AnimatePresence for something leaving the tree, layout or layoutId when boxes move, useScroll for values driven by the scroll position. A plain colour or hover fade gets sent to CSS, and a route change to the view transitions Next.js already supports.
New code goes through motion/react. Inside a Server Component, motion/react-client hands you motion elements, yet hooks and callbacks still belong in the smallest Client Component, and props crossing that line have to satisfy React's serialisation rules. Import rewriting and project scaffolding are not part of this skill: an old framer-motion codebase needs a migration done on purpose, with the package, imports, lockfile and tests updated in one go.
Verification runs on the project's own typecheck, lint and build, then in a browser with fast clicks, back and forward navigation, slow data and reduced motion on. An animation is not a transaction boundary — a payment or a delete must not hinge on whether a transition finished.
What it helps with
- animate a card out before it leaves the list
- reorder tiles with layout animation and no jumping
- tie a progress bar to the page scroll
- handle
prefers-reduced-motionin custom effects - move a project from
framer-motionto themotionpackage
Example prompts for the agent
- Add a Motion fade-in for the cards in
app/page.tsxand keep the markup semantic. - Use nextjs-framer-motion-animations to work out why AnimatePresence never plays the exit when the route changes in the App Router.
- Switch this grid to
layoutIdand confirm it still reads fine with reduced motion on.
How to install nextjs-framer-motion-animations
1Skills CLI (Vercel)
npx skills add tristanmanchester/agent-skills --skill nextjs-framer-motion-animations -a claude-code2Manually: put the files in place
~/.claude/skills/nextjs-framer-motion-animations/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/nextjs-framer-motion-animations/
1Skills CLI (Vercel)
npx skills add tristanmanchester/agent-skills --skill nextjs-framer-motion-animations -a codex2Manually: put the files in place
.agents/skills/nextjs-framer-motion-animations/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add tristanmanchester/agent-skills --skill nextjs-framer-motion-animations -a cursor2Manually: put the files in place
.cursor/skills/nextjs-framer-motion-animations/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install tristanmanchester/agent-skills nextjs-framer-motion-animations2Manually: put the files in place
.github/skills/nextjs-framer-motion-animations/SKILL.md1Skills CLI (Vercel)
npx skills add tristanmanchester/agent-skills --skill nextjs-framer-motion-animations -a gemini-cli2Platform CLI
gemini skills install https://github.com/tristanmanchester/agent-skills --path nextjs-framer-motion-animationsManually: put the files in place
.devin/skills/nextjs-framer-motion-animations/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add tristanmanchester/agent-skills --skill nextjs-framer-motion-animations -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about nextjs-framer-motion-animations
How do I install nextjs-framer-motion-animations in Claude Code?
Run npx skills add tristanmanchester/agent-skills --skill nextjs-framer-motion-animations -a claude-code. The skill then sits at ~/.claude/skills/nextjs-framer-motion-animations/SKILL.md.
What does nextjs-framer-motion-animations do?
It helps an agent match an animation technique to the job in a Next.js app and carry the change through: from a local tween or an element leaving the tree to layout moves, shared elements and scroll-linked values.
Which Motion and Next.js versions does it need?
The current motion package plus the React, Next.js and runtime versions your app already supports. The agent inspects the lockfile and the router type before touching anything.
Source text
SKILL.md · MIT
--- name: nextjs-framer-motion-animations description: >- Implement and debug Motion for React in Next.js: local interaction, presence, layout, shared elements, scroll, reduced motion, and router integration. Use for explicit Motion/Framer Motion work or interactions that need it; prefer CSS for simple effects and framework-native view transitions for supported route cases. license: MIT. See LICENSE.txt compatibility: Use the current motion package and the app's supported React/Next.js/runtime versions. Inspect locked versions and router type. No legacy import-rewriting wrapper or automatic project scaffolding is provided. metadata: version: "5.0.0" reviewed: "2026-09-13" --- # Purposeful Motion in Next.js Choose motion to explain state or improve interaction, not to add a mandatory layer to every page. Keep existing design tokens and semantic controls. For a small colour/focus/hover transition, CSS may avoid unnecessary client JavaScript. ## Inspect before choosing the boundary Read the actual component, router (App or Pages), package/lockfiles, installed Motion API, and build configuration. Identify who owns mounting, state, focus, scroll, and navigation. Distinguish a local reveal from a route transition. A filename/token scanner cannot prove these relationships or build compatibility. For modernised/new Motion code, use `motion/react`. In a Server Component, the supported `motion/react-client` entry point exposes motion elements; it does not turn hooks or arbitrary callbacks into server-safe code. Put interactive/hooks in the smallest Client Component, keeping fetching and secrets server-side. Server-rendered children can pass through a client wrapper without moving their implementation into the client bundle. Props across that boundary must meet React's actual serialisation contract. For an existing framer-motion project, inspect its installed version and decide whether migration is in scope. A deliberate migration updates package, imports, lockfile, tests, and any changed APIs together. Do not mix runtimes or mechanically rewrite namespace imports from motion/react-m into a different module. This skill ships no compatibility branch or automatic import rewriting. ## Choose the mechanism | Need | Start with | Essential condition | | --- | --- | --- | | Small local tween/gesture | motion element | Preserve semantic element and disabled/focus behaviour | | Several coordinated children | variants and stagger | Stable identity and a bounded delay budget | | Local removal | AnimatePresence | It survives and observes the removed keyed child | | Layout change | layout / layout="position" | Correct measurement and retained identity | | Shared element within a live tree | layoutId / LayoutGroup | Unique, intentionally scoped IDs | | Visibility reveal | whileInView | Correct scroll root and progressive visibility | | Scroll-linked value | useScroll plus motion values | Correct target/container and reduced-motion policy | | Imperative sequence | useAnimate | Scoped targets and cancellation/cleanup | | Bundle-sensitive region | LazyMotion with m | Feature set covers the used layout/drag APIs | | Route/shared-view transition | Framework-supported ViewTransition | Actual Next/React/browser contract, not a pathname wrapper | Read [component patterns](references/COMPONENTS.md) for implementation decisions and [router integration](references/ROUTING.md) for route changes. Do not assume one package-wide provider or one animation duration fits every interaction. ## Presence and application state A persistent AnimatePresence is necessary for its own exits but is not sufficient to control a router-owned subtree. Keying a wrapper by pathname does not establish that outgoing route content is retained unchanged. Do not freeze private router context, intercept every click, or delay all navigation to make an exit demo work. Use the supported framework route mechanism or an honest enter-only enhancement. An animation callback is not a transaction boundary. Do not make a payment, delete, navigation confirmation, or other application outcome depend on whether an animation happened to finish. Cancellation, interruption, remount, and reduced motion must preserve the same logical outcome. ## Accessibility and rendering Use MotionConfig reducedMotion="user" where it fits the existing tree, plus local useReducedMotion decisions for scroll, autoplay, and bespoke effects. Opacity-only animations and independent CSS/view-transition paths need their own policy; one Motion provider is not a universal motion switch. Use real buttons/links/dialogs. Preserve keyboard paths, visible focus, logical reading order, and an equivalent to drag-only interaction. Exiting invisible controls must not remain focusable or intercept input. A visual modal shell is not focus management, Escape behaviour, a label, or background inertness. Do not server-render critical text permanently invisible and depend on successful hydration/intersection observation to reveal it. Keep layout boxes stable and handle font/image loading, viewport changes, and no-JavaScript/failure behaviour where required. Use transform/opacity where suitable, but measure actual paint, layout, compositing, and bundle costs before claiming a speed improvement. ## Validate the actual change Run the project's existing typecheck/lint/build as authorised; do not assume its scripts are named npm run lint/build. Test in the browser with rapid interactions, back/forward navigation, slow data, interruptions, reduced motion, keyboard use, and multiple copies of shared-layout components. Check console/hydration errors, scroll restoration, focus, and usable nonanimated fallback. Unit mocks are not a browser performance or router-lifetime test. Deliver the patch, chosen boundary/mechanism, actual verification, and remaining browser checks. The old generic scanners, generated plans, all-assets scaffolder, and their golden-output pack are removed; real integration evidence is the goal, not reproducing a heuristic's preferred output. ## Sources and maintenance Reviewed 2026-09-13: [Motion installation](https://motion.dev/docs/react-installation), [AnimatePresence](https://motion.dev/docs/react-animate-presence), [Next templates](https://nextjs.org/docs/app/api-reference/file-conventions/template), and [Next view transitions](https://nextjs.org/docs/app/guides/view-transitions). [Evaluation cases](evals/scenarios.json) describe required checks, not tests run.
© tristanmanchester · MIT · tristanmanchester/agent-skills