This source did not publish a separate summary. Review SKILL.md before using the skill.
SKILL.md
Astro Web Framework
Overview
Astro is a web framework designed for content-rich websites — blogs, docs, portfolios, marketing sites, and e-commerce. Its core innovation is the Islands Architecture: by default, Astro ships zero JavaScript to the browser. Interactive components are selectively hydrated as isolated "islands." Astro supports React, Vue, Svelte, Solid, and other UI frameworks simultaneously in the same project, letting you pick the right tool per component.
When to Use This Skill
Use when building a blog, documentation site, marketing page, or portfolio
Use when performance and Core Web Vitals are the top priority
Use when the project is content-heavy with Markdown or MDX files
Use when you want SSG (static) output with optional SSR for dynamic routes
Use when the user asks about .astro files, Astro.props, content collections, or client: directives
How It Works
Step 1: Project Setup
npm create astro@latest my-site
cd my-site
npm install
npm run dev
Add integrations as needed:
npx astro add tailwind # Tailwind CSS
npx astro add react # React component support
npx astro add mdx # MDX support
npx astro add sitemap # Auto sitemap.xml
npx astro add vercel # Vercel SSR adapter
By default, UI framework components render to static HTML with no JS. Use client: directives to hydrate:
---
import Counter from '../components/Counter.tsx'; // React component
import VideoPlayer from '../components/VideoPlayer.svelte';
---
<!-- Static HTML — no JavaScript sent to browser -->
<Counter initialCount={0} />
<!-- Hydrate immediately on page load -->
<Counter initialCount={0} client:load />
<!-- Hydrate when the component scrolls into view -->
<VideoPlayer src="/demo.mp4" client:visible />
<!-- Hydrate only when browser is idle -->
<Analytics client:idle />
<!-- Hydrate only on a specific media query -->
<MobileMenu client:media="(max-width: 768px)" />
---
import SearchBox from '../components/SearchBox.tsx';
---
<!-- Hydrated immediately — this island is interactive -->
<SearchBox client:load />
Best Practices
✅ Keep most components as static .astro files — only hydrate what must be interactive
✅ Use content collections for all Markdown/MDX content — you get type safety and auto-validation
✅ Prefer client:visible over client:load for below-the-fold components to reduce initial JS
✅ Use import.meta.env for environment variables — prefix public vars with PUBLIC_
✅ Add <ViewTransitions /> from astro:transitions for smooth page navigation without a full SPA
❌ Don't use client:load on every component — this defeats Astro's performance advantage
❌ Don't put secrets in .astro frontmatter that gets used in client-facing templates
❌ Don't skip getStaticPaths for dynamic routes in static mode — builds will fail
Security & Safety Notes
Frontmatter code in .astro files runs server-side only and is never exposed to the browser.
Use import.meta.env.PUBLIC_* only for non-sensitive values. Private env vars (no PUBLIC_ prefix) are never sent to the client.
When using SSR mode, validate all Astro.request inputs before database queries or API calls.
Sanitize any user-supplied content before rendering with set:html — it bypasses auto-escaping.
Common Pitfalls
Problem: JavaScript from a React/Vue component doesn't run in the browser
Solution: Add a client: directive (client:load, client:visible, etc.) — without it, components render as static HTML only.
Problem:getStaticPaths data is stale after content updates during dev
Solution: Astro's dev server watches content files — restart if changes to content/config.ts are not reflected.
Problem:Astro.props type is any — no autocomplete
Solution: Define a Props interface or type in the frontmatter and Astro will infer it automatically.
Problem: CSS from a .astro component bleeds into other components
Solution: Styles in .astro<style> tags are automatically scoped. Use :global() only when intentionally targeting children.
Related Skills
@sveltekit — When you need a full-stack framework with reactive UI (vs Astro's content focus)
@nextjs-app-router-patterns — When you need a React-first full-stack framework
@tailwind-patterns — Styling Astro sites with Tailwind CSS
@progressive-web-app — Adding PWA capabilities to an Astro site
Limitations
Use this skill only when the task clearly matches the scope described above.
Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.