gsap-react

Integrate GSAP animations into React and Next.js with useGSAP lifecycle cleanup.

Updated Jun 8, 2026
One-click install
npx skills add https://github.com/ScarletFish/MyAnimeDock --skill gsap-react-scarletfish
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/ScarletFish/MyAnimeDock/tree/main/.agents/skills/gsap-react
Command: npx skills add https://github.com/ScarletFish/MyAnimeDock --skill gsap-react-scarletfish

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gsap, @gsap/react.

What problem does it solve?

This Skill resolves the common friction between GSAP's imperative animation model and React's declarative lifecycle, preventing memory leaks, animation glitches, and SSR-related errors.

Core Features & Use Cases

  • Automatic Cleanup: Utilizes the useGSAP hook to ensure animations and ScrollTriggers are properly reverted when components unmount.
  • Context Management: Provides safe scoping for animations to prevent selectors from leaking outside the component.
  • Use Case: Use this when building complex UI transitions or scroll-based reveals in a Next.js or React application to ensure smooth performance and clean component teardown.

Quick Start

Use the gsap-react skill to implement a fade-in animation for a component using the useGSAP hook and a container ref.

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 use GSAP animations in React without memory leaks, implement the useGSAP hook from @gsap/react to manage component lifecycles. This ensures animations and ScrollTriggers are properly reverted when components unmount, preventing memory leaks and animation glitches.

Why does my GSAP animation break during Next.js server-side rendering?

GSAP animations break during Next.js server-side rendering because GSAP uses an imperative model that conflicts with React's declarative lifecycle. Integrating context management with the useGSAP hook provides safe scoping and proper component teardown to prevent SSR-related errors.

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

To scope GSAP selectors to a specific React component, use the useGSAP hook with a container ref. This provides context management and safe scoping, preventing animation selectors from leaking outside the component and affecting unrelated DOM elements.

Can I use GSAP ScrollTrigger for scroll-based reveals in Next.js applications?

Yes, you can use GSAP ScrollTrigger for scroll-based reveals in Next.js applications. By utilizing the useGSAP hook, you ensure proper context scoping and automatic cleanup of ScrollTriggers during component unmounting for smooth performance.

What's the best way to handle complex UI transitions in a React component architecture?

The best way to handle complex UI transitions in React is integrating GSAP with the @gsap/react package. This resolves the friction between GSAP's imperative animation model and React's declarative lifecycle, ensuring clean component teardown and smooth motion design.

Do I need to install both gsap and @gsap/react to animate components in React?

Yes, you need to install both gsap and @gsap/react to animate components in React. The @gsap/react package provides the useGSAP hook required for proper context scoping and memory management, while the gsap package delivers the core animation library.