Webflow lifecycle management

From vallafederico/webflow-dev-setup · View interactive version

Webflow lifecycle management is an AI agent skill from the GitHub repository vallafederico/webflow-dev-setup. Manage module lifecycles, cleanup, and page transitions. Use when handling component initialization, destruction, or animating page entrances and exits.

How to use this skill

Skill file

Webflow Lifecycle Management

This skill covers the usage of lifecycle hooks to ensure proper resource management and smooth page transitions.

Lifecycle Hooks

Import these from @/modules/_:

onDestroy and onPageOut only run when Taxi page transitions are on. They are off in the template, so links are full page loads and the page is simply replaced. Write the cleanup anyway: pnpm check requires it, and it is what makes enabling Taxi safe. See the page transitions skill.

Example Pattern

import { onMount, onDestroy, onEditor, onPageIn, onPageOut } from "@/modules/_";
import gsap from "@lib/gsap";

export default function (element: HTMLElement, dataset: DOMStringMap) {
  let inEditor = false;
  onEditor((isEditor) => {
    inEditor = isEditor;
  });

  onMount(() => {
    // Initialize: add event listeners, start observers
  });

  onPageIn(async () => {
    if (inEditor) return;
    // Animate in
    await gsap.from(element, { opacity: 0, y: 20, duration: 0.8 });
  });

  onPageOut(
    async () => {
      // Animate out
      await gsap.to(element, { opacity: 0, duration: 0.4 });
    },
    { element }
  ); // Pass { element } to only animate if visible

  onDestroy(() => {
    // Cleanup: remove listeners, destroy GSAP instances, stop observers
  });
}

Critical Cleanup Checklist

Always perform these actions in onDestroy:

pnpm check enforces most of this. See House Rules.

Page Transitions

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.