gsap-react

Implements GSAP animations in React using the useGSAP hook, refs, and context cleanup.

2|Updated Jul 25, 2026
One-click install
npx skills add https://github.com/ankaboot-source/boucle --skill gsap-react-ankaboot-source
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/ankaboot-source/boucle/tree/main/.jcode/skills/gsap-react
Command: npx skills add https://github.com/ankaboot-source/boucle --skill gsap-react-ankaboot-source

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gsap, @gsap/react.

What problem does it solve? Integrating GSAP animations into React or Next.js apps often causes memory leaks, stale animations on unmounted components, selector collisions across components, and SSR crashes. This Skill provides the correct patterns for setup, scoping, and cleanup so animations behave reliably in React's lifecycle. ## Core Features & Use Cases - useGSAP Hook Patterns: Replaces useEffect-based GSAP setup with the useGSAP hook, including scope, dependency arrays, and revertOnUpdate configuration. - Context-Safe Callbacks: Wraps event-handler animations in contextSafe so they are properly reverted on unmount, with correct event listener cleanup. - SSR-Safe Usage: Ensures GSAP and ScrollTrigger code runs only on the client in Next.js and other server-rendered frameworks. - Use Case: You are building a Next.js landing page with staggered entrance animations and scroll effects. Use this Skill to set up useGSAP with a scoped container ref, contextSafe click handlers, and automatic cleanup on unmount. ## 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 React?

Install gsap and @gsap/react, register the useGSAP plugin, and call useGSAP inside your component with a scope ref. The hook handles cleanup automatically on unmount, replacing manual useEffect-based setup.

Should I use useGSAP or useEffect for GSAP in React?

Prefer the useGSAP hook from @gsap/react because it handles cleanup automatically and provides scope and contextSafe. Use useEffect with gsap.context only when @gsap/react is unavailable, and always call ctx.revert() in the cleanup function.

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

GSAP runs only in the browser, so never call gsap or ScrollTrigger during SSR. Keep all GSAP code inside useGSAP or useEffect so it executes exclusively on the client after hydration.

Why do my GSAP animations leak or run on unmounted components?

Leaks happen when animations are created outside the GSAP context, such as in event handlers, or when ctx.revert() is never called. Wrap deferred callbacks in contextSafe and always return a cleanup that reverts the context.

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

Pass a container ref as the scope option in useGSAP or as the second argument to gsap.context. This limits selectors like .box to elements inside that component, preventing matches elsewhere in the DOM.