Astro Islands Explained: Partial Hydration in Practical Terms, With Examples
10 November 2026 · Updated 28 November 2026 · 12 min read · by Yang Kai
Astro islands explained without the jargon: what partial hydration means, the client directives that control it, and a decision table for when a component should ship JavaScript at all.
Table inside: When-to-Hydrate Decision Table for Astro Islands
Contents
- The directives at a glance
- What does hydration actually mean?
- The client directives, and when each one earns its place
- Server islands: the other kind of island
- Framework components inside islands
- Sharing state between islands
- The when-to-hydrate decision table
- How to audit what a page actually ships
- Common islands mistakes
- How we researched this
- What to do next
- Learn more
Most JavaScript frameworks ship your whole page as an application and let it rebuild itself in the browser. Astro inverts that: the page ships as finished HTML, and JavaScript is something you add to individual components, on purpose, one at a time.
Those opted-in components are islands, and the selective loading behind them is called partial hydration. This article is the working version of the idea: what hydration actually costs, the client directives that control when it happens, the newer server islands, and a decision table for the judgement call behind all of it — whether a component should ship JavaScript at all.
If you have met the one-paragraph version in the introduction to Astro for vibe coders, this is the article it points to. The behaviour described follows the current Astro documentation on component directives and server islands, checked November 2026.
The directives at a glance
| Directive | Hydrates | Reach for it when |
|---|---|---|
| (none) | Never | The component is content. This is the default and should stay the most common row in your project |
client:load |
Immediately on page load | It must work the moment the page appears, above the fold |
client:idle |
When the browser’s main thread is free | It matters soon, but not at first paint |
client:visible |
When it scrolls into view | It sits below the fold and may never be seen |
client:media |
When a media query matches | It only exists on some screen sizes |
client:only |
Immediately, with no server HTML | The component genuinely cannot render on the server |
Everything below is the reasoning behind that table.
What does hydration actually mean?
Hydration is the browser process where a JavaScript framework takes static HTML that the server already rendered and attaches event listeners and state to it, turning it into a living component. The HTML was already readable; hydration makes it reactive.
In a fully hydrated app, every component pays that cost, including the footer. In Astro, components render to HTML and stay inert unless you opt them in with a client directive. Interactivity becomes a per-component purchase, priced in kilobytes and load time, instead of a site-wide tax.
This is why the island metaphor stuck: each interactive component is an island of JavaScript in a sea of static HTML, loading independently of the others. One island can fail, lag, or be removed without draining the sea.
The client directives, and when each one earns its place
Astro’s directives control when an island hydrates. The skill is picking the latest moment that still feels instant to the person using the page.
client:load — the expensive default
Hydrate immediately on page load. Reserve it for components that are interactive above the fold and immediately: a primary search box, the main navigation’s mobile menu trigger.
Everything marked client:load competes with first paint. Two or three small islands are fine; a habit of marking everything client:load recreates a single-page app with extra steps.
client:idle — soon, but not now
Hydrate once the page has loaded and the browser is idle, using requestIdleCallback where available. Good for interactivity the visitor will reach in a few seconds rather than instantly: comment widgets, chat buttons, secondary filters.
The component’s HTML is already on the page, so nothing looks broken while it waits. It simply becomes interactive a beat later.
client:visible — the workhorse
Hydrate when the component scrolls into view, tracked with an IntersectionObserver. This is the right default for long content pages: a pricing table’s toggle, an embedded demo, a related-products carousel near the bottom.
You can fine-tune it with a root margin — client:visible={{ rootMargin: "200px" }} starts loading shortly before the component arrives on screen, so it is ready by the time it is seen. Many visitors never reach the bottom of a page at all, and for them the island’s JavaScript is never downloaded. That is the cheapest performance win in this entire article.
client:media — only where it exists
Hydrate only when a media query matches, such as client:media="(max-width: 768px)" for a mobile menu. Desktop visitors never download the component’s JavaScript, because on their screens the component should not exist at all.
It is the most elegant directive and the most forgotten. Any component whose visibility depends on screen size is a candidate.
client:only — the last resort
Skip server rendering entirely and render only in the browser. You must name the framework — client:only="react" — because Astro cannot infer it without a server render.
Know what you are giving up: the HTML, the SEO value, and the no-JavaScript fallback. The space sits empty until the script runs. Reach for it only when a component genuinely cannot render on the server, such as one that touches browser APIs during its first render, and treat needing it often as a sign the component choice is wrong.
Server islands: the other kind of island
Client islands solve “this part needs JavaScript.” Server islands solve a different problem: “this part needs fresh, per-visitor data, but the rest of the page is static.”
Mark an Astro component with server:defer and it becomes a server island. The page itself is generated and cached as static HTML, with fallback content rendered in the island’s place. After the page loads, the browser requests the island, the server renders it for that specific request — reading cookies, headers, or a database — and the result swaps in.
<CartCount server:defer>
<span slot="fallback">Cart</span>
</CartCount>
The classic uses are personalised fragments on otherwise cacheable pages: a cart count, a signed-in greeting, a recommended-for-you rail. The honest constraint is that server islands need somewhere to run at request time, so the site needs an adapter and on-demand rendering available — the setup covered in running Astro on Cloudflare. A purely static host with no server runtime has no way to answer the island’s request.
Choose between the two island types by asking what the component is waiting for. Waiting for the user means a client island. Waiting for the server means a server island.
Framework components inside islands
An island can be a React, Vue, Svelte, Solid, Preact, or other supported framework component — Astro is deliberately plural here. Plain Astro components are not islands at all; they render to HTML at build time and ship nothing.
In practice, most content sites need very few framework islands. A search experience is the classic one, because fuzzy search over hundreds of entries is a solved problem in several ecosystems, and the entries themselves usually live in a content collection the search index is built from.
Two cautions:
- Each distinct framework on a page brings its runtime with it. Mixing three frameworks for three widgets quietly rebuilds the bundle bloat islands exist to avoid.
- Props must be serialisable. You pass data into an island as values Astro can serialise — plain data, plus built-ins like
Date,Map, andSet. Live objects and functions do not cross the boundary, because the island restarts in the browser from the serialised props.
A middle path exists for small interactions: an Astro component with a plain <script> tag. A copy-to-clipboard button or a “back to top” control needs a few lines of vanilla JavaScript, not a framework runtime, and Astro bundles and processes those scripts for you.
Sharing state between islands
Islands hydrate independently, which raises the obvious question: how do a filter island and a results island talk to each other? The pragmatic answers, in ascending order of machinery:
- The URL. Filters encoded in query parameters are shareable, bookmarkable, and survive a refresh. This is the right default for most content sites.
- Custom browser events. One island dispatches, the other listens. Fine for a page-level conversation between two or three components.
- A tiny shared store. The Astro documentation points to Nano Stores for state shared across islands, including islands built in different frameworks.
What you should not do is reach for a full application framework to solve a two-component conversation. If a page genuinely needs app-level shared state everywhere, that page may be an app wearing a content site’s clothes, and the honest comparison is in Astro versus Next.js for SaaS-style projects.
The when-to-hydrate decision table
| Component | Hydrate? | Directive | Reasoning |
|---|---|---|---|
| Article body, headings, lists | No | — | Static HTML is the finished product |
| Header navigation (desktop) | No | — | Links work without JavaScript |
| Mobile menu | Yes | client:media (small screens) |
Only exists where the hamburger does |
| Site search | Yes | client:load or client:idle |
The reason many visitors came; keep it ready |
| Pricing monthly/yearly toggle | Yes | client:visible |
Interactive, usually below the fold |
| Image carousel | Yes, reluctantly | client:visible |
Often replaceable with a simple grid — try that first |
| Newsletter form | Usually no | — | A plain form posting to a provider needs no framework — see forms on static Astro sites |
| Comment widget | Yes | client:idle |
Valuable, never urgent |
| “Back to top” button | Tiny script, not a framework island | inline <script> |
A few lines of vanilla JS beat a runtime |
| Cart count or account greeting | Server island | server:defer |
Per-visitor data on an otherwise static page |
| Checkout or account dashboard | Reconsider the page’s architecture | — | App-shaped work may belong in an app framework |
Choosing between directives is a performance decision with a user-experience face. The image optimisation guide makes the same point for media: the cheapest asset is the one never sent, and the second cheapest is the one sent late.
How to audit what a page actually ships
Judgement calls improve when you can see their cost. Three checks, cheapest first:
- Read the built HTML. After
npm run build, open a page indist/and search for<script. Every island leaves traces — its markup is wrapped in anastro-islandelement with the component URL and directive recorded as attributes. What you find is the ground truth of what the page hydrates, regardless of what you meant to write. - Watch the network tab on a phone-sized throttle. Load the page in your browser’s device emulation with a mid-tier mobile profile. Islands on
client:visibleshould not appear in the network log until you scroll to them; if they do, the directive is not doing what you think. - Click before hydration. Load the page slowly and try the search box or menu immediately. The gap between “visible” and “interactive” is the real price of
client:idleandclient:visibleon that page — if the gap annoys you in testing, it will annoy visitors in production, and that component earns a promotion toclient:load.
Run the audit after any theme change or new widget, not once at launch. Islands accumulate the way browser tabs do: one reasonable decision at a time.
Common islands mistakes
- Hydrating everything out of habit.
client:loadsprinkled on every component is the most common one, and the easiest to fix — demote before you optimise. - Hydrating a component whose job a link or a form could do. A framework island to submit a newsletter form is machinery without a purpose.
- Forgetting the server-rendered HTML is the real page. Search engines, slow connections, and blocked scripts all meet that HTML first — a point that connects directly to honest SEO practice for Astro sites. An island whose static HTML is an empty shell has failed before JavaScript gets a vote.
- Reaching for
client:onlyto dodge a server-rendering error. The error is information. Fix the component’s server render instead of opting out of it. - Testing only on desktop broadband, where a heavy island feels instant, while most visitors meet it on a mid-range phone over a variable connection.
How we researched this
The directive behaviour, the server:defer model, and the state-sharing options above are described from the official Astro documentation — the directives reference and the server islands guide — checked November 2026. The decision table is editorial judgement built on that documented behaviour, not benchmark data; your pages and your audience get the final say.
Frequently asked questions
Do Astro islands work with React components? Yes — React, Vue, Svelte, Solid, Preact, and other supported frameworks can render as islands in the same project, and can be mixed on one page. The discipline is limiting how many runtimes a single page ships.
What is the difference between client:visible and client:idle?
client:visible waits until the component scrolls into the viewport; client:idle waits until the browser’s main thread is free after load. A component far down a long page suits visible; one near the top that is not urgent suits idle.
Can two islands share state? Yes, via the URL, browser events, or a small shared store such as Nano Stores — but design for independence first. If everything must share state constantly, the page is application-shaped.
What is a server island, in one sentence?
A component marked server:defer that renders on the server at request time and swaps into an otherwise static page, with fallback content shown while it loads.
Does no hydration hurt SEO?
The opposite, generally: server-rendered HTML with no required JavaScript is the easiest content for crawlers to read. Interactivity added as islands does not remove that HTML — except client:only, which is one more reason it is the last resort.
What to do next
Audit one page of your site and list every component that currently ships JavaScript. Run each through the decision table and demote at least one — to a later directive, to a plain form, or to static HTML.
If you are evaluating themes, ask how they hydrate before you buy. The theme-choosing guide treats island discipline as a quality signal, and it is one of the fastest ways to tell a carefully built theme from a heavy one wearing a fast demo.
Learn more
- Astro content collections: schemas, references, and loaders
- Deploying Astro on Cloudflare Pages
- Astro vs Next.js for content sites
- Forms and email for static Astro sites
Category: Astro Themes & Starters · Tags: #astro #themes
Next step: this article is part of Astro guides, which covers the full topic from first setup to advanced use.