gsap-react

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

Updated Aug 10, 2026
One-click install
npx skills add https://github.com/KryptaMedina7/quero-s-home --skill gsap-react-kryptamedina7
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/KryptaMedina7/quero-s-home/tree/main/.agents/skills/gsap-react
Command: npx skills add https://github.com/KryptaMedina7/quero-s-home --skill gsap-react-kryptamedina7

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: 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 reverted on unmount instead of leaking. - SSR Safety: Keep all GSAP and ScrollTrigger code client-only in Next.js applications. - Use Case: You are building a Next.js landing page with scroll-driven hero animations. Use this Skill to write useGSAP-based components with scoped refs that clean up correctly on route changes. ## Quick Start Set up a GSAP fade-in 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 components?

Use the useGSAP hook from @gsap/react instead of useEffect. Register it with gsap.registerPlugin(useGSAP), pass a container ref as scope, and write your tweens inside the hook; cleanup runs automatically on unmount.

How to clean up GSAP animations on React unmount?

With useGSAP, cleanup is automatic. If you use gsap.context() inside useEffect, always return a cleanup function that calls ctx.revert() to kill tweens and ScrollTriggers 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 imports inside effects are an option for bundle control.

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 in 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 because 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().