0Pricing
React Academy · Lesson

Islands Architecture: Selective Hydration

Learn how islands isolate interactive components so only they ship JavaScript while the rest stays static HTML.

Islands Architecture: Selective Hydration is a free React Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the React Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Islands Concept

Islands Architecture, coined by Jason Miller in 2020, treats a web page as mostly static HTML with isolated "islands" of interactivity embedded in it. The static ocean of HTML is sent to the browser as-is. Only the interactive islands download and execute JavaScript, making the JavaScript payload proportional to actual interactivity.

How Islands Work

Each island is an independently hydrated component. The server renders the island's initial HTML along with the rest of the page. When the island's JavaScript loads, it hydrates only that component subtree. The HTML surrounding the islands is never touched by JavaScript — it is truly static.

The JavaScript Payload Difference

On a blog post page with Islands Architecture, the JavaScript payload might be 5kb for a single like-button island. The same page built as a React SPA might ship 200kb+ of JavaScript to hydrate the entire page. The islands approach makes the payload proportional to interactivity, not page size.

Multi-Framework Islands

Astro, the leading Islands Architecture framework, supports islands built with different frameworks on the same page. You can have a React island next to a Vue island next to a vanilla JavaScript island. Each island is independently bundled, so users only download the framework code used by visible islands.

client:load — Immediate Hydration

The client:load directive hydrates the island immediately when the page loads. Use this for islands that are immediately visible and interactive, such as a navigation menu or a hero section with a search input. This is the highest-priority hydration strategy.

client:idle — Deferred Hydration

The client:idle directive waits until the browser's main thread is idle (after the critical content has loaded) before hydrating the island. This is ideal for widgets below the fold or secondary interactions that are not needed immediately, such as a social share bar.

client:visible — Lazy Hydration

The client:visible directive uses an Intersection Observer to hydrate the island only when it scrolls into the viewport. This is ideal for islands deep in the page — a comment section, a related products carousel — that most users may never reach. JavaScript is not even loaded until needed.

client:only — Skip SSR

The client:only directive skips server-side rendering entirely and only renders the island in the browser. This is necessary for components that use browser-only APIs (window, document) or that depend on client-side state at mount time. The trade-off is no server-rendered HTML for that island.

Solving the Hydration Problem

Islands Architecture solves the full hydration problem by ensuring JavaScript is loaded and executed only for genuinely interactive components. A blog post with a like button only hydrates the like button island — the 1200-word article text, the header, and the footer generate zero JavaScript execution on the client.

State Isolation Between Islands

Each island has its own isolated state. Islands cannot share React state directly because they are separate React trees. This is by design: if two components need to share state, they should be merged into a single island. Cross-island communication uses URL params, DOM events, or lightweight state libraries.

Real-World Results

Sites migrated from React SPA to Islands Architecture (like the Astro documentation site) report dramatic improvements: JavaScript payloads drop by 70-90%, TTI improves by 2-4 seconds on mobile, and Lighthouse performance scores jump from 60s to 90s+. The gains are most pronounced on content-heavy pages.

Island Hydration Strategies

Which Astro hydration directive hydrates a component only when it scrolls into the viewport?

Lesson Recap

Islands Architecture keeps most of the page as static HTML and hydrates only isolated interactive components. Astro provides hydration directives: client:load (immediate), client:idle (after idle), client:visible (on scroll), and client:only (client-only render). Each island is independently hydrated, making JavaScript proportional to interactivity rather than page size.

Frequently asked questions

Is the “Islands Architecture: Selective Hydration” lesson free?

Yes — the full text of “Islands Architecture: Selective Hydration” is free to read here on the web, and the React Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the React Academy course, upgrade to CoddyKit PRO.

What will I learn in “Islands Architecture: Selective Hydration”?

Learn how islands isolate interactive components so only they ship JavaScript while the rest stays static HTML. You practise React Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start React Academy?

No prior experience is required. React Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Islands Architecture: Selective Hydration” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this React Academy lesson?

Yes. Every React Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. The Full Hydration Problem
  2. Islands Architecture: Selective Hydration
  3. Astro and React Islands Setup
  4. Measuring Performance: Lighthouse and Core Web Vitals
← Back to React Academy