gsap-nextjs

Implements GSAP page transitions and component animation lifecycles in Next.js App Router applications.

1|Updated Aug 17, 2026
One-click install
npx skills add https://github.com/NalinDalal/skillset --skill gsap-nextjs-nalindalal
Or copy as Structured Prompt for Agentβ–Ό
Please help me install this Agent Skill.
Skill: gsap-nextjs
Source: https://github.com/NalinDalal/skillset/tree/main/skills/ui/gsap-nextjs
Command: npx skills add https://github.com/NalinDalal/skillset --skill gsap-nextjs-nalindalal

SYSTEM DOCUMENTATION & REQUIREMENTS

πŸ’‘ This Skill includes references (resource) components.

What problem does it solve? Animating Next.js App Router pages and components with GSAP is error-prone: routes unmount before outros play, hidden cached routes match global selectors, interrupted navigations strand timelines, and pre-paint hiding breaks SEO and first-load performance. This Skill provides a complete lifecycle contract and recovery rules so animations stay correct under real router behavior. ## Core Features & Use Cases - Five-phase lifecycle: Enforces mount β†’ initial state β†’ intro β†’ settled β†’ outro β†’ end state β†’ unmount for pages and components, with explicit rules for interruption and reduced motion. - App Router navigation integration: Covers transition-aware Links via onNavigate, back/forward intro-only paths, cacheComponents hidden-route behavior, and combining GSAP with React <ViewTransition>. - Initialization and recovery: Provides bounded initialization deadlines, per-owner recovery, no-JavaScript readability, and LCP/indexing guidance for initially hidden content. - Use Case: Add a page transition where the outgoing page plays a GSAP outro before navigation commits, the incoming page reveals behind a cover, and browser back skips the outro β€” all verified against a production build. ## Quick Start Use the gsap-nextjs skill to add GSAP page transitions with proper cleanup and reduced-motion support to this Next.js App Router project.

Frequently Asked Questions about gsap-nextjs

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

FAQPage Schema
How do I add GSAP page transitions in Next.js App Router?β–Ό

Intercept navigation with the Link `onNavigate` prop (Next.js 15.3+), play the outro on the live page, then call `router.push` after the end state. The incoming page runs initial state and intro behind a cover scoped to the route container.

GSAP vs React View Transitions for Next.js navigation?β–Ό

Use React `<ViewTransition>` for shared-element morphs, crossfades, and Suspense swaps; use GSAP for live-DOM outros that gate navigation, interruptible sequences, split text, and scroll-linked motion. Never animate the same element with both engines in one transition.

Does GSAP work with Next.js cacheComponents?β–Ό

Yes, but hidden routes stay in the DOM with `display: none`, so scope every selector through `useGSAP` scope or refs and never query `document`. Treat route hide as unmount and re-show as mount, writing initial state explicitly with `set` or `fromTo`.

Why does my GSAP outro not play before the Next.js route changes?β–Ό

The router unmounts the outgoing page immediately on commit, killing the outro. Cancel the navigation inside `onNavigate` with `e.preventDefault()`, run the outro timeline, and push the destination only after the end-state callback fires.

How do I handle reduced motion with GSAP page transitions?β–Ό

Reduced motion must pass through the same five phases with instant changes, firing every completion callback that commits navigation or unmounts content. Use a shared `prefersReducedMotion()` helper and zero-duration timelines rather than skipping phases.

Why does animated content hurt LCP or indexing in Next.js?β–Ό

Initially hidden primary content can delay Largest Contentful Paint and risks unreadable HTML if JavaScript fails. Keep text in server-rendered HTML, use a scoped pre-paint hiding rule with an early script and recovery deadline, and reveal hero content without waiting for unrelated setup.