gsap-react

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

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/abhinaaaavvv/dotfiles --skill gsap-react-abhinaaaavvv
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/abhinaaaavvv/dotfiles/tree/main/.agents/skills/gsap-react
Command: npx skills add https://github.com/abhinaaaavvv/dotfiles --skill gsap-react-abhinaaaavvv

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gsap, @gsap/react.

What problem does it solve? GSAP animations in React often cause memory leaks, stale animations on unmounted components, and SSR errors when developers use plain useEffect without proper cleanup. This Skill provides the correct patterns for integrating GSAP with React and Next.js so animations are scoped, reverted on unmount, and never run during server rendering. ## Core Features & Use Cases - useGSAP Hook Patterns: Set up animations with the @gsap/react useGSAP hook, including scope, dependency arrays, and revertOnUpdate configuration. - gsap.context() Fallback: Use gsap.context() inside useEffect with ctx.revert() cleanup when @gsap/react is unavailable. - Context-Safe Callbacks: Wrap event-handler animations in contextSafe so they are tracked and cleaned up correctly. - SSR Safety: Keep all GSAP and ScrollTrigger code client-only in Next.js and other SSR frameworks. - Use Case: You are building a Next.js landing page and want staggered entrance animations on a card grid. This Skill gives you the useGSAP setup with a scoped container ref so the animation cleans up properly on route changes. ## Quick Start Set up a GSAP entrance animation in my React component using the useGSAP hook with a scoped container ref and proper 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 a React component?▼

Use the useGSAP hook from @gsap/react instead of useEffect. Register it with gsap.registerPlugin(useGSAP), then place your GSAP code inside the hook and pass a container ref as the scope so selectors only match elements within your component.

How to clean up GSAP animations when a React component unmounts?▼

The useGSAP hook reverts animations and ScrollTriggers automatically on unmount. If you use gsap.context() inside a regular useEffect instead, always return a cleanup function that calls ctx.revert() to kill animations and restore inline styles.

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

GSAP runs only in the browser and must not execute during SSR. Place all GSAP and ScrollTrigger code inside useGSAP or useEffect so it runs client-side only, and avoid calling gsap methods at the top level during server render.

Why do my GSAP animations leak or fire on unmounted components in React?▼

Leaks happen when animations are created in event handlers outside the GSAP context or when ctx.revert() is missing from the effect cleanup. Wrap late-created animations in contextSafe from useGSAP and remove event listeners in the cleanup function.

useGSAP hook vs useEffect with gsap.context: which should I use?▼

Prefer useGSAP from @gsap/react because it handles cleanup automatically and provides scope and contextSafe. Use gsap.context() inside useEffect only when @gsap/react is unavailable or you need specific effect dependency behavior, and always call ctx.revert() on cleanup.