secondsky/claude-skills / plugins/auto-animate/skills/auto-animate
auto-animate
VerifiedAutoAnimate (@formkit/auto-animate) zero-config animations for React. Use for list transitions, accordions, toasts, or encountering SSR errors, animation libraries complexity.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.4 KB |
| assets/example-template.txt | markdown | 416 B |
| references/auto-animate-vs-motion.md | markdown | 9.8 KB |
| references/css-conflicts.md | markdown | 13.0 KB |
| references/example-reference.md | markdown | 760 B |
| references/ssr-patterns.md | markdown | 12.4 KB |
| scripts/example-script.shexecutable | script | 302 B |
| scripts/init-auto-animate.shexecutable | script | 8.8 KB |
| templates/accordion.tsx | other | 2.7 KB |
| templates/filter-sort-list.tsx | other | 3.2 KB |
| templates/form-validation.tsx | other | 4.2 KB |
| templates/react-basic.tsx | other | 2.8 KB |
| templates/react-typescript.tsx | other | 4.7 KB |
| templates/toast-notifications.tsx | other | 1.9 KB |
| templates/vite-ssr-safe.tsx | other | 4.2 KB |
templates/vite-ssr-safe.tsx
View on GitHub// AutoAnimate - SSR-Safe Pattern for Cloudflare Workers
// Prevents "useEffect not defined" errors in server environments
import { useState, useEffect } from "react";
import type { AutoAnimateOptions } from "@formkit/auto-animate";
/**
* SSR-Safe AutoAnimate Hook
*
* Problem: AutoAnimate uses DOM APIs that don't exist on the server
* Solution: Only import and use AutoAnimate on the client side
*
* This pattern works for:
* - Cloudflare Workers + Static Assets
* - Next.js (App Router & Pages Router)
* - Remix
* - Any SSR/SSG environment
*/
export function useAutoAnimateSafe<T extends HTMLElement>(
options?: Partial<AutoAnimateOptions>
) {
const [parent, setParent] = useState<T | null>(null);
useEffect(() => {
// Only import on client side
if (typeof window !== "undefined" && parent) {
import("@formkit/auto-animate").then(({ default: autoAnimate }) => {
autoAnimate(parent, options);
});
}
}, [parent, options]);
return [parent, setParent] as const;
}
/**
* Alternative: useAutoAnimate from react package (client-only import)
*/
export function ClientOnlyAutoAnimate({ children }: { children: React.ReactNode }) {
const [isClient, setIsClient] = useState(false);
useEffect(() => {
setIsClient(true);
}, []);
if (!isClient) {
// Server render: return children without animation
return <>{children}</>;
}
// Client render: use AutoAnimate
return <AnimatedList>{children}</AnimatedList>;
}
function AnimatedList({ children }: { children: React.ReactNode }) {
// This import only runs on client
const { useAutoAnimate } = require("@formkit/auto-animate/react");
const [parent] = useAutoAnimate();
return <div ref={parent}>{children}</div>;
}
/**
* Example Usage: Todo List with SSR-Safe Hook
*/
interface Todo {
id: number;
text: string;
}
export function SSRSafeTodoList() {
// Use the SSR-safe hook
const [parent, setParent] = useAutoAnimateSafe<HTMLUListElement>();
const [todos, setTodos] = useState<Todo[]>([
{ id: 1, text: "Server-rendered todo" },
]);
const [newTodo, setNewTodo] = useState("");
const addTodo = () => {
if (!newTodo.trim()) return;
setTodos([...todos, { id: Date.now(), text: newTodo }]);
setNewTodo("");
};
const removeTodo = (id: number) => {
setTodos(todos.filter((t) => t.id !== id));
};
return (
<div className="max-w-md mx-auto p-6 space-y-4">
<div className="flex gap-2">
<input
type="text"
value={newTodo}
onChange={(e) => setNewTodo(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && addTodo()}
placeholder="New todo..."
className="flex-1 px-3 py-2 border rounded"
/>
<button
onClick={addTodo}
className="px-4 py-2 bg-blue-600 text-white rounded"
>
Add
</button>
</div>
{/* Set ref using callback pattern for SSR safety */}
<ul ref={setParent} className="space-y-2">
{todos.map((todo) => (
<li
key={todo.id}
className="flex items-center justify-between p-4 bg-white border rounded"
>
<span>{todo.text}</span>
<button
onClick={() => removeTodo(todo.id)}
className="px-3 py-1 bg-red-500 text-white rounded text-sm"
>
Remove
</button>
</li>
))}
</ul>
</div>
);
}
/**
* Cloudflare Workers Configuration
*
* In vite.config.ts:
* import { defineConfig } from "vite";
* import react from "@vitejs/plugin-react";
* import cloudflare from "@cloudflare/vite-plugin";
*
* export default defineConfig({
* plugins: [react(), cloudflare()],
* build: {
* outDir: "dist",
* },
* ssr: {
* // Exclude AutoAnimate from SSR bundle
* noExternal: [],
* external: ["@formkit/auto-animate"],
* },
* });
*
* This ensures AutoAnimate only runs in the browser (Static Assets),
* not in the Worker runtime.
*/
/**
* Common SSR Errors Prevented:
*
* ❌ "ReferenceError: window is not defined"
* ❌ "Cannot find module '@formkit/auto-animate/react'"
* ❌ "useEffect is not defined"
* ❌ "document is not defined"
*
* ✅ All prevented by client-only import + conditional rendering
*/
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |