Skip to content

Islands & Client Interactivity

From static HTML to just enough interactivity

Section titled “From static HTML to just enough interactivity”

The Foundations module made the case: Astro ships zero JavaScript by default. That’s great for content, but real sites still need a search box, a cart, a theme toggle, a like button. This module is about adding exactly that much interactivity — and no more.

The unit of interactivity in Astro is the island. An island is a framework component (React, Vue, Svelte, Solid, Preact) that you deliberately hydrate on the client with a client directive. Everything around it stays static HTML. You don’t opt the page into being an app; you opt one component into being interactive.

flowchart TB
  page["Page: static HTML, no JS"]
  page --> header["header — static"]
  page --> search["SearchBox — island (client:load)"]
  page --> article["article — static"]
  page --> cart["Cart — island (client:visible)"]
  page --> footer["footer — static"]
A static page with a few hydrated islands
LessonWhat you’ll learn
Client directivesThe five client:* directives and when each hydrates
Framework integrationsUsing React/Vue/Svelte/Solid/Preact components as islands
Sharing stateIslands are isolated — how to share data across them with nanostores and slots
Server islandsserver:defer — defer a slow or personalized component without slowing the page

Two questions decide everything in this module:

  1. Does this component need to be interactive at all? If not, it’s a plain .astro component and ships no JS. Most of the page.
  2. If yes, when does it need to become interactive? Immediately? When it scrolls into view? At a certain screen size? That “when” is exactly what a client directive expresses — and it’s the difference between a fast page and a slow one.

Keep asking those two questions and islands stop being a bag of directives and become a budget: every island is JavaScript you chose to ship, on purpose.

What is an island in Astro?
By default, how much of a page with one island is interactive JavaScript?
What does a client directive primarily control?