gsap-react

Implements GSAP animations in React using the useGSAP hook with scoped selectors and automatic cleanup.

1|Updated Aug 6, 2026
One-click install
npx skills add https://github.com/luce12/agent-dev-workflow --skill gsap-react-luce12
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/luce12/agent-dev-workflow/tree/main/toolkits/gsap-react
Command: npx skills add https://github.com/luce12/agent-dev-workflow --skill gsap-react-luce12

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gsap, @gsap/react.

What problem does it solve? GSAP animations in React often leak memory, target wrong elements across re-renders, or break during server-side rendering. This Skill provides the correct patterns for integrating GSAP with React and Next.js so animations are scoped, cleaned up on unmount, and run only on the client. ## Core Features & Use Cases - useGSAP Hook Patterns: Replaces useEffect with the useGSAP hook from @gsap/react, including scope, dependency arrays, and revertOnUpdate configuration. - gsap.context() Fallback: Shows how to use gsap.context() inside useEffect with ctx.revert() cleanup when @gsap/react is unavailable. - Context-Safe Callbacks: Wraps event-handler animations in contextSafe so they are properly reverted on unmount. - SSR Safety: Ensures GSAP and ScrollTrigger code never executes during server rendering in Next.js. - Use Case: When building a Next.js landing page with scroll-triggered animations, apply this Skill to scope selectors to component refs, clean up ScrollTriggers on unmount, and avoid React warnings from updates on detached nodes. ## Quick Start Set up a GSAP fade-in animation in my React component using the useGSAP hook with proper scoping and cleanup.

Frequently Asked Questions about gsap-react

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

FAQPage Schema
How do I use GSAP animations in React components?▼

Use the useGSAP hook from @gsap/react instead of useEffect for GSAP setup. Register it with gsap.registerPlugin(useGSAP), pass a ref as scope so selectors stay inside the component, and cleanup runs automatically on unmount.

useGSAP vs useEffect for GSAP in React?▼

useGSAP is preferred because it handles cleanup automatically and provides scope and contextSafe for callbacks. Use gsap.context() inside useEffect only when @gsap/react is unavailable, and always return ctx.revert() in the cleanup function.

Does GSAP work with Next.js server-side rendering?▼

GSAP runs only in the browser and must not execute during SSR. Keep all gsap and ScrollTrigger calls inside useGSAP or useEffect so they run client-side only; dynamic import inside useEffect is an option for bundle size concerns.

Why do GSAP animations leak or update unmounted components in React?▼

Leaks happen when animations are created in event handlers outside the GSAP context or when cleanup is skipped. Wrap late-created animations in contextSafe from useGSAP, remove event listeners in cleanup, and always call ctx.revert() when using gsap.context().

How do I scope GSAP selectors to a single React component?▼

Pass a ref or element as the scope option in useGSAP or as the second argument to gsap.context(). This limits selector strings like .box to that root so they never match elements outside the component across re-renders.