Astro islands are interactive components placed inside an otherwise static HTML page. Astro renders the whole page to HTML on the server or at build time, then loads JavaScript only for the components you mark with a client:* directive, and each of those islands hydrates on its own. Everything else stays as plain HTML with no JavaScript attached.
This guide explains how the islands architecture works in Astro 7, what actually ships to the browser, how server islands extend the idea, and the mistakes that cost you the performance benefit.
Key Takeaways
- By default, every component (including React, Vue or Svelte) renders to HTML with zero JavaScript.
- Adding
client:load,client:idle,client:visible,client:mediaorclient:onlyturns a component into a client island.- Each island loads its own JavaScript and hydrates independently, so one slow widget doesn’t block the rest.
- Props passed to an island must be serializable; functions don’t survive the trip.
server:defercreates a server island: HTML rendered on demand after the page loads, which needs an adapter.
What the islands architecture means
The term describes a page as a sea of static HTML with small islands of interactivity. A product page might be 95% static content (header, description, reviews, footer) with three interactive parts: an image carousel, an add-to-cart button and a search box.
Traditional single-page app frameworks treat the entire page as one JavaScript application. Even the static parts are rendered on the server, then rendered again in the browser during hydration, so the browser downloads and runs code for content that never changes.
Astro flips the default. The page is HTML first, and you opt individual components into JavaScript. The browser downloads code for the carousel, the button and the search box, and nothing for the rest. That’s why Astro sites tend to ship far less JavaScript than the same design built as a single-page app.
Astro islands in code
Here’s a page with one static component and one interactive island:
---
// src/pages/product.astro
import BaseLayout from '../layouts/BaseLayout.astro';
import ProductGallery from '../components/ProductGallery.astro';
import AddToCart from '../components/AddToCart.jsx';
---
<BaseLayout title="Desk lamp">
<ProductGallery />
<h1>Desk lamp</h1>
<p>Aluminium body, warm LED, 3 brightness levels.</p>
<AddToCart client:load productId="lamp-01" />
</BaseLayout>
ProductGallery is an Astro component, so it’s HTML only. AddToCart is a React component with client:load, so Astro renders its initial HTML on the server, then loads React and the component’s code in the browser and hydrates it.
Remove client:load and AddToCart still renders, but as static HTML. Its buttons appear and do nothing, because no JavaScript is sent. That’s the most common surprise for people coming from React: a framework component is static unless you add a directive.
What ships to the browser
For each client island, Astro writes an <astro-island> custom element into the HTML. Simplified, it looks like this:
<!-- dist/product/index.html (simplified) -->
<astro-island
component-url="/_astro/AddToCart.B3x9.js"
renderer-url="/_astro/client.Dq1f.js"
props='{"productId":[0,"lamp-01"]}'
client="load">
<button>Add to cart</button>
</astro-island>
The element carries the URL of the component’s bundle, the framework renderer, the serialized props and the hydration strategy. A small inline script defines <astro-island>; when its condition is met, it imports the component and the renderer and hydrates in place. The server-rendered <button> is visible from the first paint, before any JavaScript runs.
Two consequences follow:
- Islands are independent. Each has its own bundle and its own trigger. A heavy chart below the fold never delays a header menu.
- Shared code is shared. If three islands use React, the React runtime is bundled once and cached, not shipped three times.
The five client directives
The directive decides when an island hydrates:
| Directive | Hydrates | Good for |
|---|---|---|
client:load |
Immediately on page load | Above-the-fold controls needed right away |
client:idle |
When the browser is idle (requestIdleCallback) |
Lower-priority widgets |
client:visible |
When the island scrolls into view (IntersectionObserver) |
Carousels, comments, charts further down |
client:media="(query)" |
When a CSS media query matches | Mobile-only menus, desktop-only sidebars |
client:only="react" |
On load, with no server render | Components that need window to render at all |
client:idle accepts a timeout and client:visible accepts a root margin:
---
// src/pages/index.astro
import Newsletter from '../components/Newsletter.svelte';
import Comments from '../components/Comments.vue';
---
<Newsletter client:idle={{ timeout: 500 }} />
<Comments client:visible={{ rootMargin: '200px' }} />
The timeout makes the island hydrate after 500 ms even if the browser never goes idle. The root margin starts hydrating 200 px before the island enters the viewport, so it’s ready when the reader gets there. Our full comparison of client:load, client:idle and client:visible has examples for each, and Which client directive should I use? is a quick decision guide.
Islands and props
Astro serializes island props into the HTML so the browser can rebuild them. Strings, numbers, booleans, arrays, plain objects, Date, Map, Set, URL, RegExp, BigInt and typed arrays all work. Functions don’t: they’re dropped during serialization.
---
// src/pages/index.astro
import Counter from '../components/Counter.jsx';
---
<!-- Works: plain data -->
<Counter client:load start={5} label="Votes" />
<!-- Doesn't work: onChange is dropped before it reaches the browser -->
<Counter client:load onChange={(n) => console.log(n)} />
If two islands need to talk, share state through a small store library like nanostores, a custom DOM event, or the URL. Islands can’t pass callbacks to each other through Astro.
Children work, with limits. Static content passed to an island renders on the server and is passed in as HTML. You can’t pass a framework component as a child and expect it to stay interactive unless it’s an island itself.
Server islands: the other kind of island
Client islands answer “which parts need JavaScript”. Server islands answer a different question: “which parts need fresh, per-request HTML”. Add server:defer to any Astro component:
---
// src/pages/index.astro
import UserGreeting from '../components/UserGreeting.astro';
---
<h1>Welcome to the shop</h1>
<UserGreeting server:defer>
<p slot="fallback">Loading your account…</p>
</UserGreeting>
The page itself can still be prerendered and cached on a CDN. In the browser, a tiny script requests the deferred component from the server, which renders it with access to cookies and the request, and swaps the HTML in. The fallback slot shows until it arrives.
Server islands need an on-demand runtime, so the project must have an adapter (Node, Cloudflare, Netlify, Vercel). On a static-only build, the build fails with “Cannot use server islands without an adapter”. The fix for that error shows the config.
| Client island | Server island | |
|---|---|---|
| Marked with | client:* |
server:defer |
| Component types | Framework components (React, Vue, Svelte, Solid, Preact) | Astro components |
| Runs in | The browser | The server, per request |
| Ships JavaScript | Yes, the component and its framework | Only a small loader script |
| Needs an adapter | No | Yes |
You can combine them: a server island can contain a client island, for example a personalized cart that also has an interactive quantity picker.
When an island is the wrong tool
Not every bit of interactivity needs a framework island. A plain <script> tag in an Astro component is bundled, deduplicated and loaded as a module, with no framework runtime at all. For a menu toggle, a copy-to-clipboard button or a dark-mode switch, that’s usually smaller and simpler.
---
// src/components/MenuToggle.astro
---
<button id="menu-toggle" aria-expanded="false">Menu</button>
<script>
const button = document.querySelector('#menu-toggle');
button?.addEventListener('click', () => {
const open = button.getAttribute('aria-expanded') === 'true';
button.setAttribute('aria-expanded', String(!open));
document.body.classList.toggle('menu-open', !open);
});
</script>
Reach for a framework island when the component has real state, renders lists that change, or already exists as a React or Vue component you want to reuse. Our article on island or script walks through that choice with examples.
The other wrong-tool case is a page that’s almost entirely interactive, like a dashboard or editor. If 90% of the page is islands, you pay for the boundaries without getting much benefit, and a single-page app framework may fit better.
Common islands mistakes
- Forgetting the directive. A React component without
client:*renders but never responds to clicks. client:loadeverywhere. It’s the easiest choice and the most expensive one. Default toclient:visibleorclient:idlefor anything below the fold.- One giant island. Wrapping the whole page body in one React component recreates a single-page app. Keep islands small and leave layout and content to Astro.
- Passing functions as props. They’re silently dropped. Pass data and handle events inside the island.
- Using
client:onlywithout a framework hint.client:onlyneeds the renderer name, such asclient:only="react", because Astro can’t infer it without rendering on the server.
Islands in practice
All Komal themes are built on this model: pages and sections are Astro components with no client JavaScript, and interactive pieces such as menus and forms use small scripts or opt-in islands, so the defaults already follow the advice above. You can browse Astro themes and run one locally to inspect the output. For background on the whole framework, start with What is Astro, and for the official reference, see the Astro islands docs.
FAQ
What are islands in Astro?
Islands are components that Astro hydrates individually in an otherwise static HTML page. Client islands are framework components with a client:* directive that load JavaScript in the browser. Server islands are Astro components with server:defer that render on the server after the page loads.
Does Astro hydrate React components by default?
No. React, Vue, Svelte and other framework components render to static HTML unless you add a client directive such as client:load or client:visible. Without one, no JavaScript for that component reaches the browser.
Can Astro islands share state?
Not through props, because Astro serializes props and drops functions. Islands can share state with a framework-agnostic store like nanostores, with custom DOM events, or through the URL and localStorage.
What is the difference between islands architecture and partial hydration?
Partial hydration is the technique of hydrating only some components on a page. Islands architecture is the page model built on it: static HTML by default, with independent interactive regions that each load and hydrate on their own schedule.
Do server islands work on a static Astro site?
The page can be static, but the island needs a server to render it. Install an adapter such as @astrojs/node, @astrojs/cloudflare, @astrojs/netlify or @astrojs/vercel; prerendered pages stay static and only the deferred components render on demand.