---
name: gsap-astro
description: "Build or review Astro animation: GSAP page transitions, ClientRouter swap hooks, persisted islands, repeated setup, and cleanup. Use for missing or duplicated motion after navigation and choosing transition:animate versus GSAP. Without ClientRouter, use gsap-vanilla. Also covers hidden-content recovery and first-load performance. Not for standalone island frameworks or isolated GSAP API questions."
license: MIT
metadata:
  short-description: GSAP page and component lifecycles in Astro
title: gsap-astro
canonical_url: https://skilld.dev/gh/johnpolacek/animaxxing-skills/gsap-astro
last_updated: 2026-10-29T07:07:06.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [agents/openai.yaml](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/agents/openai.yaml), [references/client-router-navigation.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/client-router-navigation.md), [references/desktop-webviews.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/desktop-webviews.md), [references/devices.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/devices.md), [references/initialization.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/initialization.md), [references/motion-system.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/motion-system.md), [references/scripts-and-islands.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/scripts-and-islands.md), [references/smooth-scroll.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/smooth-scroll.md), [references/transition-archetypes.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/transition-archetypes.md), [references/verification.md](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/verification.md).
>
> If the user asked to install this Skill, run `npx skilld install johnpolacek/animaxxing-skills/gsap-astro`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/gsap-astro`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/johnpolacek/animaxxing-skills/gsap-astro) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/gsap-astro`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/gsap-astro --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/gsap-astro --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# GSAP Astro

**mount → initial state → intro → settled → outro → end state → unmount**

Without `<ClientRouter />`, use `gsap-vanilla` for full document loads. With it, mount and unmount correspond to body swaps; module scripts, global listeners, timelines, and persisted elements can survive. Animation owns the five phases between swaps.

Keep the requested look and existing project conventions. Add GSAP/plugins only as needed; do not replace the chosen animation library unless asked.

This skill decides when motion runs. For what moves, and for a feel such as premium or playful, also load the `animaxxing` skill when it is installed: its recipes and its guide to finding the vibe plug into this lifecycle.

## Start with the project

Read repository instructions, existing animation, layouts, navigation, CSS, accessibility conventions, and checks. Then:

1. Read the installed Astro version. Read `node_modules/astro/dist/transitions/router.js`, `swap-functions.js`, and `node_modules/astro/components/ClientRouter.astro` before trusting memory; the package ships no changelog, so check the release notes for that version. Version gates: `<ClientRouter />` (5.0; `<ViewTransitions />` in 4.x, removed in 6.0), lifecycle events with `loader` and `newDocument` (3.6), form navigation (4.0), `transition:persist-props` and `data-astro-rerun` (4.5), `swapFunctions` (4.15).
2. Find where `<ClientRouter />` is: the shared head, some pages, or nowhere, and its `fallback` prop. Nowhere means `gsap-vanilla`, including CSS `@view-transition`.
3. Find which framework integrations render islands and which `client:*` directives are in use.
4. Check `astro.config` for `prefetch` and `experimental.clientPrerender`.

## Choose the engine

Use `transition:name` / `transition:animate` for snapshot morphs, fades, or slides under ClientRouter. Use GSAP for live-DOM outros that hold the swap, interruptible sequences, split text, or scroll-linked motion. One engine per element; see [combining engines](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/client-router-navigation.md#combining-with-astros-animations).

## Read only what you need

- Invisible entrances, failed initialization, indexing, and first-load performance: [Initialization and recovery](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/initialization.md), plus the [framework integration](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/motion-system.md#initialization-and-recovery).
- The router's event sequence, outro before the swap, cleanup, initial state on the incoming page, direction, back and forward, scroll, focus, prefetch, fallback browsers: [ClientRouter navigation](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/client-router-navigation.md).
- Which scripts run again, listeners that outlive pages, custom elements, islands and `client:*` directives, `transition:persist`: [Scripts and islands](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/scripts-and-islands.md).
- The five phases, GSAP setup, contexts, show and hide, layout stability, scroll, text, plugins: [Lifecycle implementation](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/motion-system.md).
- Lenis, ScrollSmoother, or eased page scrolling across swaps: [Smooth scrolling](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/smooth-scroll.md), plus the [router integration](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/client-router-navigation.md#scroll).
- Curtains, first-visit preloaders, and shared-element morphs: [Transition archetypes](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/transition-archetypes.md), plus the [event mapping](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/client-router-navigation.md#curtains-preloaders-and-shared-elements).
- Touch, viewport changes, and device budgets: [Devices and input](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/devices.md).
- Tauri, Electron, or Wails desktop shells: [Desktop webviews](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/desktop-webviews.md).
- Before calling work done: [Verification](https://skilld.dev/api/skills-raw/johnpolacek/animaxxing-skills/gsap-astro/references/verification.md).

Install the [official GSAP skills](https://github.com/greensock/gsap-skills) alongside this repository. Load `gsap-core` for API details and `gsap-frameworks` for component setup only as needed.

## Rules

- Preserve invisible intros on successful setup; recover the current incoming owner on failure. Follow the initialization contract before adding hiding rules.
- GSAP runs after the DOM it targets exists. Scope selectors with `gsap.context` to the page or component root. Clean up every tween, trigger, split, and listener before the swap that removes its owner.
- A module script runs once per visit, not once per page. Setup runs from `astro:page-load` and is correct when it runs again on a new body or twice on the same one.
- Listeners on `document` and `window` outlive the page. Register router listeners once, in one place, and have each handler find the current page before acting.
- Reserve final geometry with normal CSS and a stable wrapper; overlap outgoing/incoming content without doubling layout space.
- Set initial values before paint, then reveal. On first load that is the inline head script; after a swap it is `astro:before-swap` and `astro:after-swap`. Successful initialization never flashes settled content before the intro, and never a blank page without JavaScript.
- Clear temporary styles at settled. Use `will-change` only while animating; this overrides `gsap-performance`'s static hint.
- Use capability queries for device tiers. Touch states release; controls work without hover.
- The outro plays on live DOM inside `event.loader` in `astro:before-preparation`, and the router waits for it. Never animate in `astro:before-swap`: the user is looking at a snapshot.
- Back and forward get an intro-only path. A traverse fires every event, so skip the outro on `navigationType === "traverse"` on purpose.
- Keep `transition:persist` elements out of page-level cleanup and page-level intros. They cross the swap alive, timelines included.
- Keep native link behavior, the router's history, scroll restoration, and route announcement. Do not add a click interceptor beside the router for motion; the only click listener is the capture-phase guard that holds the lock while a navigation is in flight.
- Cleanup before the swap kills the page context; it does not revert it. A revert writes the intro's start values back onto a body that is still attached.
- Reduced motion reaches the same settled state and still fires every completion callback. The router already disables its own animations under `prefers-reduced-motion`.
- Use timelines for sequences. Decide up front what happens on rapid clicks and interrupted animations: the router lets a second click abort the first navigation while its outro is running, so first-click-wins needs the lock guard.
- Verify in a real browser when practical, including a page visited twice, back, forward, and a click during an outro.
