How to add GSAP
Widely compatibleRendering:Prerendered: WorksOn-demand: WorksAstro>=4.0.0
Works across all listed Astro environments.
You can easily add GSAP to your Astro project!
-
Start by installing the
gsappackage using your favorite package manager: -
You can now import it into your project inside a
scriptin any.astrofile:src/components/Foo.astro <script>import { gsap } from "gsap";const box = document.getElementById("box");const myTimeline = gsap.timeline();myTimeline.from(box, {opacity: 0,}).to(box, {opacity: 1,duration: 0.25,});</script><div id="box"></div> -
That’s it, you’re all set up to use GSAP in your project!
To learn more about GSAP, check their official site or their docs:
Compatibility
| Environment | Support | Version |
|---|---|---|
| Framework | ||
| Astro | Works | >=4.0.0 |
| RenderingAstro docs | ||
| Prerendered | Works | Any version |
| On-demand | Works | Any version |
Compatibility legend:Recommended — Best practiceWorks — SupportedDoesn't work — Unsupported