Loading...
Loading...
Astro web framework patterns for content-driven sites. Covers content collections with Zod schemas and loaders, island architecture with selective hydration directives, view transitions with ClientRouter, server-side and hybrid rendering modes, server islands, Astro DB with astro:db, middleware with onRequest, and framework integrations (React, Svelte, Vue). Use when building content-driven websites, configuring island hydration strategies, setting up view transitions, choosing between static and server rendering, integrating UI framework components, defining content collection schemas, or adding middleware.
npx skill4agent add oakoss/agent-skills astro| Pattern | API / Directive | Key Points |
|---|---|---|
| Content collection | | Zod schemas, glob/file loaders, type-safe queries |
| Query collection | | Returns typed array, supports filter callback |
| Single entry | | Fetch by collection name and entry ID |
| Island (load) | | Hydrate immediately on page load |
| Island (idle) | | Hydrate when browser is idle |
| Island (visible) | | Hydrate when component enters viewport |
| Island (media) | | Hydrate on media query match |
| Island (client-only) | | Skip SSR, render only on client |
| View transitions | | Add to |
| Persist state | | Maintain island state across navigations |
| Programmatic navigate | | Client-side navigation from scripts |
| Static output | | Pre-render all pages at build time (default) |
| Server output | | Server-render all pages on demand |
| Hybrid (opt-in SSR) | | Static by default, opt individual pages into SSR |
| Hybrid (opt-in static) | | SSR by default, opt individual pages into static |
| Server islands | | Defer server rendering for dynamic content in static |
| Middleware | | Runs before every route, chain with |
| Astro DB table | | Type-safe SQL with column definitions |
| Framework component | Import | Auto-detected by file extension |
| Integration | | CLI to add framework adapters and tools |
| Render content | | Compile Markdown/MDX to component |
| Dynamic routes | | Generate pages from collection entries |
| API endpoint | | Server-rendered REST endpoints |
| Shared island state | | Reactive state across framework boundaries |
| Environment variables | | |
| Transition animation | | |
| Prefetch links | | |
| Collection reference | | Type-safe cross-collection relations |
| Script re-execution | | Re-run |
| Redirect | | Redirect from middleware or server pages |
| Mistake | Correct Pattern |
|---|---|
Adding | Only UI framework components (React, Svelte, Vue) accept |
Using | Default to |
Forgetting framework string with | Must specify framework: |
| Mixing framework components in non-Astro files | Only |
Using | Use |
Omitting | Must be in |
Content config not at | File must be named |
Not awaiting | Always |
Importing from | Content APIs are server-only; pass data as props to client components |
Placing middleware outside | Middleware must be at |
| Passing functions as props to islands | Only serializable data crosses the server/client boundary |
Using | Component must appear on both old and new page with same persist value |
| Missing adapter for server/hybrid mode | Install an adapter: |
ExploreTaskcode-reviewerIf theskill is available, delegate styling and Tailwind CSS configuration to it. If thetailwindskill is available, delegate unit testing patterns to it. If thevitestskill is available, delegate end-to-end testing patterns to it. If theplaywrightskill is available, delegate build configuration and Vite plugin setup to it. If theviteskill is available, delegate advanced database query patterns to it. If thedrizzleskill is available, delegate error monitoring and observability setup to it. If thesentryskill is available, delegate server-side logging configuration to it. If thepino-loggingskill is available, delegate client-side data fetching and caching to it.tanstack-query