gsap-react

Automate scoped GSAP animations in React components with useGSAP cleanup.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

React developers often need to animate UI elements without leaking animations or causing SSR issues. This skill provides a safe, scoped approach to GSAP animations in React, with automatic cleanup and clean integration with Next.js or other React frameworks.

Core Features & Use Cases

  • useGSAP: Use GSAP's React integration to set up animations with automatic cleanup on unmount.
  • Scoped targets: Attach a ref as the scope to ensure selectors only affect the component.
  • Context-safe callbacks: Use contextSafe to wrap callbacks created inside event handlers so they clean up properly.
  • SSR-friendly: Guidance to run animations on the client-side to avoid SSR pitfalls; suitable for Next.js or CRA apps.
  • Use Cases: Animate on mount, hover interactions, orchestrate multiple elements with timelines within a component.

Quick Start

Start by creating a container ref and calling useGSAP in your component to animate elements within that container.

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 without causing memory leaks?

To prevent memory leaks, use GSAP animations in React by applying the useGSAP hook or gsap.context within a useEffect to ensure automatic cleanup on component unmount.

What is the best way to scope GSAP selectors to a single React component?

The best way to scope GSAP selectors is to attach a container ref to the component and pass it as the scope, ensuring animations only target elements within that specific component.

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

GSAP works with Next.js if you run animations on the client-side to avoid SSR pitfalls. Client-side execution ensures proper scope, cleanup, and server-side rendering safety.

How do I clean up GSAP animations triggered by React event handlers?

To clean up GSAP animations triggered by React event handlers, wrap the callback functions using contextSafe so they integrate properly with the component's animation cleanup lifecycle.

Why do my GSAP timeline animations break when a React component unmounts?

GSAP timeline animations break on unmount if they are not scoped properly. Using useGSAP automates lifecycle-based effects and provides reliable cleanup to prevent broken or orphaned animations.