Astro

A content-first framework that ships zero JavaScript by default and hydrates interactive islands built with any UI library.

Intermediate · about 6 hours · difficulty 2/5

Learn first: CSR, SSR, SSG, ISR and Streaming

Astro is built for content-driven websites: blogs, documentation, marketing sites and portfolios. It renders pages to HTML at build time (or on the server) and ships no JavaScript by default. Interactive parts become islands that hydrate independently.

Core ideas

  • .astro components have a frontmatter script (runs at build or request time) and an HTML-like template. They never ship to the client.
  • Islands: drop in React, Vue, Svelte or Solid components and choose when they hydrate with directives like client:load, client:idle, client:visible or client:only.
  • Content collections: typed Markdown and MDX content with schemas, ideal for blogs and docs.
  • File-based routing with static generation by default and on-demand SSR through adapters.
  • Server islands and actions for dynamic pieces on otherwise static pages.
  • View transitions for smooth page navigation without an SPA.

Why it matters

Because most of the page is static HTML, Astro sites are extremely fast and score well on Core Web Vitals with little effort. Using your existing React components as islands makes it easy to adopt.

When not to use it

Highly interactive apps such as dashboards, editors or chat, where nearly everything is dynamic, fit Next.js, React Router or SvelteKit better.

Good enough to move on

You can build a blog with content collections, a layout, a React island that hydrates only when visible, and deploy it statically with near-zero JavaScript.

Key concepts

  • Astro components and frontmatter
  • Islands and client directives
  • Content collections
  • File-based routing and static output
  • Using React or Vue components inside Astro
  • SSR adapters and server islands
  • View transitions

Other options for this step

  • Next.js: The leading React framework: App Router, layouts, Server Components, data fetching and caching, Server Actions and middleware.
  • React Router Framework Mode (Remix): Web-standards-first full-stack React with loaders, actions and nested routes; the evolution of Remix.
  • Nuxt: The full-stack framework for Vue: file-based routing, SSR and SSG, auto-imports, data fetching and server routes.
  • SvelteKit: The official Svelte application framework with file-based routing, load functions, form actions and flexible rendering.

Mini project

Build your developer portfolio and blog with Astro: content collections for posts, a React island for a project filter that hydrates on visible, RSS and sitemap, deployed as a static site.

Check yourself

What is the difference between client:load and client:visible, and when would you choose each?

Free resources