---
id: frontend-astro-islands-deep
title: Astro Islands β partial hydration architecture
category: Coding
status: draft
source_trust_level: B
verification_status: conceptual
created_at: 2026-05-09
updated_at: 2026-05-09
tags: [frontend, astro, vibe-coding]
tech_stack: { language: "TS", applicable_to: ["Frontend"] }
applied_in: []
aliases: [Astro, islands, partial hydration, MPA, content-driven, HTML-first]
---
# Astro Islands
> "HTML-first, JS-on-demand". **Static HTML + interactive island λ§ hydrate**. Content site / marketing μΉν. Multi-framework.
## π ν΅μ¬ κ°λ
- Default = static HTML.
- `client:*` directive κ° island.
- React / Vue / Svelte / Solid λμ.
- MPA μ navigation.
## π» μ½λ ν¨ν΄
### File-based route
```
src/pages/
βββ index.astro
βββ about.astro
βββ posts/
βββ [slug].astro
```
### Component
```astro
---
// src/pages/index.astro
import Counter from '../components/Counter.tsx';
const data = await fetch('/api/posts').then(r => r.json());
---
Posts ({data.length})
{data.map(p => - {p.title}
)}
```
β Frontmatter (`---`) = server. Body = HTML + island.
### Hydration directive
```astro
// μ¦μ
// requestIdleCallback
// intersection observer
// server render X
```
β Per-island lazy.
### Multi-framework
```astro
---
import ReactCounter from './ReactCounter.tsx';
import VueCounter from './VueCounter.vue';
import SvelteCounter from './SvelteCounter.svelte';
---
```
β κ°μ page κ° μ¬λ¬ framework. Migration μΉν.
### Content collection
```ts
// src/content/config.ts
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
schema: z.object({
title: z.string(),
date: z.date(),
tags: z.array(z.string()),
}),
});
export const collections = { blog };
```
```astro
---
import { getCollection } from 'astro:content';
const posts = await getCollection('blog');
---
{posts.map(p => {p.data.title})}
```
β Markdown / MDX κ° type-safe.
### Server endpoint
```ts
// src/pages/api/users.ts
import type { APIRoute } from 'astro';
export const GET: APIRoute = async () => {
const users = await db.users.findMany();
return new Response(JSON.stringify(users));
};
```
### View Transitions
```astro
---
import { ViewTransitions } from 'astro:transitions';
---
```
β Page navigation κ° smooth.
β [[Web_View_Transitions_Cross_Doc]].
### Static generation (SSG default)
```bash
astro build
# β dist/ (HTML files).
```
### SSR (μ΅μ
)
```ts
// astro.config.mjs
import vercel from '@astrojs/vercel/serverless';
export default {
output: 'server',
adapter: vercel(),
};
```
β Per-route prerender option.
### Hybrid
```astro
---
export const prerender = true; // page-level
---
```
β λ§€ page κ° SSG / SSR μ ν.
### Image optimization
```astro
---
import { Image } from 'astro:assets';
import myImage from '../images/hero.png';
---
```
β μλ resize / format / lazy.
### Performance
```
- 0 JS by default.
- λ§€ island κ° own bundle.
- Streamed HTML.
β Lighthouse 100.
```
### Use case
```
β Marketing site
β Blog / docs
β E-commerce (Shopify Hydrogen alternative)
β Portfolio
β Landing page
β ν° SPA (Next κ° λ μ’μ).
β Dashboard (interactive heavy).
```
### vs Next.js
```
Next.js:
- React-first.
- App Router (RSC).
- Vercel μΉν.
- ν° ecosystem.
Astro:
- Multi-framework.
- HTML-first (less JS).
- μμ bundle.
- Content-driven.
β μ μ / content = Astro.
ν° app = Next.
```
### vs Eleventy
```
Eleventy: SSG only, JS island μμ.
Astro: SSG + island.
β Astro κ° modern.
```
### MDX
```mdx
---
title: My Post
---
import Counter from '../components/Counter';
# My Post
```
β Markdown + JSX.
### Slot (component composition)
```astro
---
// Layout.astro
---
```
```astro
---
import Layout from '../layouts/Layout.astro';
---
Title
Content
```
### Production deploy
```
Vercel, Netlify, Cloudflare Pages.
- SSG: free / cheap.
- SSR: serverless.
β λΉ λ₯Έ, scalable.
```
### Astro DB
```ts
// astro:db
import { db, eq, Comment } from 'astro:db';
const comments = await db.select().from(Comment).where(eq(Comment.postId, postId));
```
β Built-in DB (Astro 5+, Turso κΈ°λ°).
### Real-world
- **Astro docs** (μ체).
- **Lit docs**.
- **Microsoft Bun docs**.
- **Cloudflare docs**.
- **The Guardian** (μΌλΆ).
### LLM μΉν
```
Markdown / MDX κ° native.
- AI κ° μμ±ν content κ° μ¦μ.
- Component κ° μλ type-check.
```
## π€ μμ¬κ²°μ κΈ°μ€
| μν© | μΆμ² |
|---|---|
| Marketing site | Astro |
| Blog / docs | Astro |
| ν° SPA | Next.js |
| E-commerce static | Astro |
| ν° dynamic | Next / Remix |
| Multi-framework migration | Astro |
## β μν°ν¨ν΄
- **λͺ¨λ κ±° client:load**: JS νλ°.
- **Server-only logic κ° client**: leak.
- **No View Transitions**: jarring nav.
- **Big island**: bundle νλ°.
- **Mix framework κ° μλ μμ**: bundle νλ°.
## π€ LLM νμ© ννΈ
- Astro = HTML-first + island.
- Multi-framework + content collection.
- View Transitions native.
- μ μ / content site μ default.
## π κ΄λ ¨ λ¬Έμ
- [[Frontend_Astro_Patterns]]
- [[Frontend_SolidJS_Qwik]]
- [[Web_View_Transitions_Cross_Doc]]