gsap-react

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

Updated Sep 1, 2026
One-click install
npx skills add https://github.com/zamansepeti43/c-rak-agent --skill gsap-react-zamansepeti43
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-react
Source: https://github.com/zamansepeti43/c-rak-agent/tree/main/video-engine/.agents/skills/gsap-react
Command: npx skills add https://github.com/zamansepeti43/c-rak-agent --skill gsap-react-zamansepeti43

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 because developers skip cleanup or misuse selectors. This Skill provides the correct patterns for integrating GSAP with React and Next.js so animations are scoped, reverted on unmount, and client-only. ## Core Features & Use Cases - useGSAP Hook Patterns: Set up animations with the @gsap/react useGSAP hook, including scope, dependency arrays, and revertOnUpdate configuration. - Cleanup and Context Safety: Apply gsap.context() with ctx.revert() in useEffect, and wrap event-handler callbacks with contextSafe so late-created animations are reverted. - SSR-Safe Usage: Keep all GSAP and ScrollTrigger code on the client in Next.js apps, avoiding server-render execution errors. - Use Case: When building a Next.js landing page with staggered entrance animations, use this Skill to scope selectors to a container ref, register useGSAP, and ensure all tweens revert cleanly on unmount. ## Quick Start Ask the AI to add a GSAP fade-in animation to a 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 a React component?

Install gsap and @gsap/react, register the useGSAP plugin, then call useGSAP with your animation code and a scope ref. The hook handles cleanup automatically on unmount, replacing manual useEffect setups.

How to clean up GSAP animations on React unmount?

With useGSAP, cleanup runs automatically. If using useEffect, wrap animations in gsap.context() and return ctx.revert() in the cleanup function 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 exclusively on the client.

Why do my GSAP animations target the wrong elements in React?

Selector strings like .box can match elements outside your component across re-renders. Pass a scope (ref or element) to useGSAP or gsap.context so selectors are limited to that component's DOM subtree.

What is contextSafe in the useGSAP hook?

contextSafe wraps callbacks created after useGSAP runs, such as click handlers, so their animations are added to the GSAP context and reverted on unmount. Without it, those animations leak and trigger React warnings.