gsap-react

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

Updated May 25, 2026
One-click install
npx skills add https://github.com/SafiNguyen/Personal-Website --skill gsap-react-safinguyen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/SafiNguyen/Personal-Website/tree/main/.agents/skills/gsap-react
Command: npx skills add https://github.com/SafiNguyen/Personal-Website --skill gsap-react-safinguyen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gsap, @gsap/react.

What problem does it solve?

This skill resolves common integration challenges when using GSAP with React, such as memory leaks, improper cleanup on component unmount, and issues with server-side rendering.

Core Features & Use Cases

  • Automatic Cleanup: Leverages the useGSAP hook to ensure animations and ScrollTriggers are reverted automatically when components unmount.
  • SSR Safety: Provides patterns to prevent GSAP from executing during server-side rendering, avoiding hydration errors.
  • Context Management: Offers guidance on using gsap.context and contextSafe to ensure event-driven animations remain scoped and memory-efficient.

Quick Start

Use the gsap-react skill to implement a GSAP animation within a React component using the useGSAP hook 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 prevent GSAP memory leaks in React components?

Prevent GSAP memory leaks in React by using the useGSAP hook from @gsap/react to automatically revert animations and ScrollTriggers when components unmount or re-render.

Why does GSAP cause hydration errors in Next.js server-side rendering?

GSAP causes Next.js hydration errors when it executes during server-side rendering. Implementing SSR safety patterns ensures GSAP animations only run on the client, preventing hydration mismatches.

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

Scope GSAP animations to a specific React component by using gsap.context and contextSafe to ensure event-driven animations remain memory-efficient and properly scoped.

Do I need @gsap/react to use GSAP in Next.js?

Yes, you need @gsap/react to use GSAP in Next.js for managing animation contexts, ensuring automatic cleanup, and preventing memory leaks during component re-renders and unmounting.

What is the best way to set up scroll-triggered animations in React?

The best way to set up scroll-triggered animations in React is using the useGSAP hook, which provides lifecycle-aware cleanup and context management to ensure performant UI transitions.

Why are my GSAP animations breaking on React component re-renders?

GSAP animations break on React component re-renders without proper cleanup. Using useGSAP and gsap.context ensures animations are reverted and re-applied safely during the component lifecycle.