Skip to main content
Astro pioneered and popularized the islands architecture pattern. This approach allows you to build fast, content-focused websites while maintaining the ability to add interactive UI components where needed.

What is Islands Architecture?

Islands architecture is a component-based architecture where interactive components (islands) are embedded within otherwise static HTML pages. Think of your page as an ocean of static HTML with scattered islands of interactivity.
Key Concept: Only the interactive components are shipped to the client as JavaScript, while the rest of the page remains static HTML. This dramatically reduces the amount of JavaScript sent to the browser.

How It Works

By default, Astro renders all components to static HTML on the server with zero client-side JavaScript. When you need interactivity, you opt-in using client directives.
In this example:
  • Navigation renders as static HTML (no JavaScript)
  • Counter becomes an interactive island that hydrates on the client

Client Directives

Client directives tell Astro when and how to hydrate your interactive components. These directives are added as attributes to your component tags.

client:load

Hydrates the component immediately on page load.
Use client:load for high-priority UI that needs to be interactive immediately, like a navigation menu or chat widget.

client:idle

Hydrates the component when the browser is idle (uses requestIdleCallback).
This is the recommended directive for most interactive components. It waits until the main thread is free before hydrating.
Ideal for lower-priority UI that doesn’t need to be immediately interactive, like comment sections, social media embeds, or analytics widgets.

client:visible

Hydrates the component when it enters the viewport (uses IntersectionObserver).
Perfect for components below the fold, like image carousels, infinite scroll loaders, or any content that might not be immediately visible.

client:media

Hydrates the component when a CSS media query matches.
Useful for components that only make sense at certain screen sizes, like mobile-specific navigation or desktop-only features.

client:only

Skips server-side rendering and only renders the component on the client.
Use this sparingly! It opts out of Astro’s server-side rendering benefits. Only use for components that have browser-only dependencies or cannot run on the server.
You must specify which framework to use:

Practical Example

Here’s a complete page showing different hydration strategies:

Benefits

Faster Performance

Less JavaScript means faster page loads and better Core Web Vitals scores.

Better SEO

Content is rendered as HTML on the server, making it immediately crawlable by search engines.

Progressive Enhancement

Pages work with JavaScript disabled, then enhance when it loads.

Framework Agnostic

Mix React, Vue, Svelte, and other frameworks on the same page.

Technical Implementation

Astro wraps hydrated components in custom <astro-island> elements. From the source code (src/runtime/server/hydration.ts), the system:
  1. Extracts client directives from component props
  2. Validates the directive is supported
  3. Generates hydration metadata
  4. Wraps the component in an <astro-island> with hydration instructions

Best Practices

1

Start with static

Default to Astro components (.astro files) which render as static HTML.
2

Add interactivity selectively

Only use framework components (React, Vue, etc.) where you need client-side interactivity.
3

Choose the right directive

  • client:load for critical UI
  • client:idle for most interactive components
  • client:visible for below-the-fold content
  • client:media for responsive components
  • client:only as a last resort
4

Measure the impact

Use browser DevTools to see how much JavaScript each directive loads.

Learn More

Components

Learn about Astro’s component model

Routing

Understand Astro’s file-based routing