gsap-react

Integrate GSAP animations in React with scoped contexts and automatic cleanup.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/DanielV-94/rg-medium --skill gsap-react-danielv-94
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/DanielV-94/rg-medium/tree/main/.agents/skills/gsap-react
Command: npx skills add https://github.com/DanielV-94/rg-medium --skill gsap-react-danielv-94

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

React animation in modern apps can be error-prone and SSR-unsafe; this skill provides a safe pattern using GSAP for React to ensure proper cleanup and scoped animations.

Core Features & Use Cases

  • UseGSAP hook to initialize animations within a React component without manual cleanup in every effect.
  • Use gsap.context() to scope selectors to a container, avoiding leaks and SSR issues in Next.js.
  • Automatic cleanup on unmount and safe handling of dynamic content in complex UIs.
  • Use Case: Animate a modal or interactive card carousel with isolated scope and cleanup when closed.

Quick Start

Install GSAP and @gsap/react, then use the useGSAP hook inside a component to create scoped, cleanup-ready animations.

Frequently Asked Questions about gsap-react

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

FAQPage Schema
How do I scope GSAP animations in React to avoid selector leaks?▼

You scope GSAP animations by using gsap.context() within the useGSAP hook, which restricts selectors to a specific container and automatically handles cleanup when the component unmounts.

Why do my GSAP animations break or cause errors on unmount in React?▼

GSAP animations break on unmount due to improper cleanup. Using the @gsap/react package provides the useGSAP hook, which automatically handles context cleanup and prevents memory leaks when components are destroyed.

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

Yes, GSAP works safely with Next.js SSR when using gsap.context() and the useGSAP hook, which provide scoped animations and prevent server-side rendering issues by isolating DOM interactions to the client component lifecycle.

What is the best way to animate interactive modals in React without leaks?▼

The best way to animate modals safely is using the useGSAP hook with gsap.context(), which isolates animation scopes and ensures automatic cleanup when the modal component closes or unmounts.

Do I need @gsap/react to use GSAP animations in a React project?▼

Yes, you need the @gsap/react package to use the useGSAP hook, which provides automatic cleanup and scoped animations without requiring manual effect cleanup in every React component.