gsap-react

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

Updated Aug 9, 2026
One-click install
npx skills add https://github.com/HoussamMrabet/ultimate-TicTacToe --skill gsap-react-houssammrabet
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/HoussamMrabet/ultimate-TicTacToe/tree/main/skills/gsap/gsap-react
Command: npx skills add https://github.com/HoussamMrabet/ultimate-TicTacToe --skill gsap-react-houssammrabet

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gsap, @gsap/react.

What problem does it solve? GSAP animations in React often leak memory, target wrong elements, or break during SSR because developers skip cleanup, misuse selectors, or run GSAP on the server. This Skill provides the correct patterns for integrating GSAP with React and Next.js. ## Core Features & Use Cases - useGSAP Hook Patterns: Set up animations with the official @gsap/react hook, including scope, dependency arrays, and revertOnUpdate configuration. - Cleanup and Context Safety: Prevent leaks with gsap.context() and ctx.revert() in useEffect, and wrap event-handler animations with contextSafe so they revert on unmount. - SSR-Safe Usage: Keep all GSAP and ScrollTrigger code client-only in Next.js and other server-rendered frameworks. - Use Case: A developer building a Next.js landing page needs staggered entrance animations scoped to a component that clean up correctly on navigation; this Skill supplies the exact useGSAP pattern with a ref-based scope. ## Quick Start Ask the AI to add a GSAP fade-in animation to a 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?

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

How do I clean up GSAP animations on React unmount?

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

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

GSAP runs only in the browser, so never call gsap or ScrollTrigger during SSR. Place all GSAP code inside useGSAP or useEffect so it executes client-side only; dynamic import inside useEffect is an option for bundle size concerns.

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

Animations created in event handlers after useGSAP runs are not added to its context, so they never get reverted. Wrap those callbacks with contextSafe from useGSAP and remove event listeners in the cleanup function.

Should I use useGSAP or useEffect with gsap.context?

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