Astro
Astro
A content-focused web framework. Zero JS by default. Islands architecture.
Astro
A content-focused web framework. Zero JS by default. Islands architecture.
Astro is an all-in-one web framework for content-focused websites. It was developed by Astro Technology, founded by Fred K. Schott in 2021, and with the motto "Ship Less JavaScript," it sends only the minimum client-side JavaScript. By default it strips all JavaScript at build time and adopts an islands architecture that adds it selectively only where needed.
Astro's core philosophy is "Content First." It is optimized for content-centered sites such as blogs, documentation sites, and marketing pages, and supports Markdown and MDX out of the box. Built-in features such as image optimization, RSS feeds, and sitemap generation let you build content sites quickly.
Astro's most distinctive feature is framework agnosticism. You can mix React, Vue, Svelte, and Solid components in the same project. Components are converted to HTML at build time, and only the parts that need interactivity are hydrated using client:* directives.
In practice, Astro easily achieves a Lighthouse score of 100 and is popular for content sites where SEO matters. As of 2023 it recorded 400,000 weekly npm downloads, and it integrates with all major hosting platforms such as Vercel and Cloudflare Pages.
---
// src/pages/blog/[slug].astro
// Astro μ»΄ν¬λνΈ - νλ‘ νΈλ§€ν°μμ μλ² λ‘μ§ μ€ν
import Layout from '../../layouts/Layout.astro';
import { getCollection } from 'astro:content';
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map(post => ({
params: { slug: post.slug },
props: { post }
}));
}
const { post } = Astro.props;
const { Content } = await post.render();
---
<Layout title={post.data.title}>
<article>
<h1>{post.data.title}</h1>
<time>{post.data.date.toLocaleDateString('ko')}</time>
<!-- Markdown μ½ν
μΈ λ λλ§ -->
<Content />
<!-- React μ»΄ν¬λνΈ - ν΄λ¦ μμλ§ λ‘λ -->
<LikeButton client:visible postId={post.slug} />
</article>
</Layout>
<!-- μΈν°λν°λΈ μμΌλλ μμ -->
<Counter client:load /> <!-- νμ΄μ§ λ‘λ μ μ¦μ νμ΄λλ μ΄μ
-->
<Comments client:visible /> <!-- λ·°ν¬νΈμ λ³΄μΌ λ λ‘λ -->
<Analytics client:idle /> <!-- λΈλΌμ°μ idle μνμΌ λ λ‘λ -->
"I think we should build this docs site with Astro. We can start with 0KB of JavaScript, get a Lighthouse score of 100, and reuse our existing React components as they are. The content collections feature also makes managing MDX easy."
"Astro uses Islands Architecture. Most of the page is rendered as static HTML, and only components that need interactivity are selectively hydrated with directives like client:visible. This can cut the JavaScript bundle size by more than 90%."
"I think we should change this component from client:load to client:visible. It's in an area you only see after scrolling, so hydrating it when it enters the viewport will make the initial load faster."
Take a mock interview on this topic β WIA SOOM AI Interview Β· Start for free
Astro is for content sites. For apps such as SaaS dashboards and real-time collaboration tools, Next.js or SvelteKit is a better fit.
This negates Astro's advantages. Choose an appropriate directive such as client:visible or client:idle.
Build content with Astro components and separate interactivity into React/Vue islands. Also use the View Transitions API to implement smooth page transitions.