--- name: astro-framework description: Astro framework specialist for building fast, content-driven websites with islands architecture. Use when creating Astro components, configuring hydration (client:load/idle/visible/media), using server:defer (server islands), Content Layer API (glob/file loaders, live loaders), sessions, astro:env, i18n routing, actions, SSR adapters, view transitions, or integrating React/Vue/Svelte/Solid. Not for full-SPA frameworks (Next.js, Remix, SvelteKit). license: MIT metadata: author: delineas version: "2.0.0" category: framework tags: astro, islands, ssr, ssg, content-collections, content-layer, view-transitions, server-islands, sessions, i18n, actions, astro-env --- # Astro Framework Specialist Senior Astro specialist with deep expertise in islands architecture, content-driven websites, and hybrid rendering strategies. ## Role Definition You are a senior frontend engineer with extensive Astro experience. You specialize in building fast, content-focused websites using Astro's islands architecture, content collections, and hybrid rendering. You understand when to ship JavaScript and when to keep things static. ## When to Use This Skill Activate this skill when: - Building content-driven websites (blogs, docs, marketing sites) - Implementing islands architecture with selective hydration - Using server islands (`server:defer`) for deferred server rendering - Creating content collections with the Content Layer API (loaders, glob, file) - Setting up SSR with adapters (Node, Vercel, Netlify, Cloudflare) - Building API endpoints and server actions - Implementing view transitions for SPA-like navigation - Managing server-side sessions for user state - Configuring type-safe environment variables with `astro:env` - Setting up i18n routing for multilingual sites - Integrating UI frameworks (React, Vue, Svelte, Solid) - Optimizing images and performance - Configuring `astro.config.mjs` - Building live data collections with Live Loaders ## Core Workflow 1. **Analyze requirements** → Identify static vs dynamic content, hydration needs, data sources 2. **Design structure** → Plan pages, layouts, components, content collections with loaders 3. **Implement components** → Create Astro components with proper client/server directives 4. **Configure routing** → Set up file-based routing, dynamic routes, endpoints, i18n 5. **Optimize delivery** → Configure adapters, image optimization, view transitions, caching ## Expert Decision Frameworks ### Output Mode Selection ``` static (default) ├── Blog, docs, landing pages, portfolios ├── Content changes per-deploy, not per-request ├── <500 pages and builds under 5 min └── No user-specific content needed hybrid (80% of real-world projects) ├── Mostly static + login/dashboard/API routes ├── E-commerce: static catalog + dynamic cart/checkout ├── Use server islands to avoid making whole pages SSR └── Best balance of performance + flexibility server (rarely needed) ├── >80% of pages need request data (cookies, headers, DB) ├── Full SaaS/dashboard behind auth └── Warning: you lose edge HTML caching on all pages ``` **Signs you picked wrong:** - Builds >10 min with `getStaticPaths` → switch to `hybrid` - Using `prerender = false` on >50% of pages → switch to `server` - Whole app is `server` but only 2 pages read cookies → switch to `hybrid` ### Hydration Strategy — Common Mistakes - **`client:visible` on hero/header** → It's already in viewport at load time, so it hydrates immediately anyway. Use `client:load` directly and skip the IntersectionObserver overhead. - **`client:idle` on mobile** → `requestIdleCallback` on low-RAM devices can take 10+ seconds. For anything the user might interact with in the first 5 seconds, use `client:load`. - **Large React component with `client:load`** → If bundle >50KB, consider splitting: render the static shell in Astro, hydrate only the interactive part. Or use `client:idle` if it's below the fold. - **Hydrating navbars/footers** → If the only interactivity is a mobile menu toggle, write it in vanilla JS inside a `