Sierra guide / Building
Islands
A prerendered page ships HTML and CSS and no script, so on its own it never responds to anything. An island is a component you mark with a client:* directive so the page loads just that piece's script.
<script>
import Counter from '../islands/Counter.mesa'
</script>
<main>
<h1>prerendered, ships no JS</h1>
<Counter client:load start={7} />
</main>
What else it can do
client:loadmounts at once andclient:idlewaits for the browser to be idleclient:visiblewaits until the island scrolls into viewclient:media="(min-width: 600px)"mounts when the query matchesclient:staticnever mounts, and its chunk is never fetched- Each island is its own chunk, fetched when its directive fires
- A click on an island before it mounts fetches it at once and lands on the live element after
- A key reaches an island before it mounts only through an element that names it in
aria-keyshortcuts="Control+K /": the key presses that element once the island is live. A key that presses no element, like a game's arrows, is lost until the island mounts - A page with no island gets no script tag
- Props are serialized into the page, so they must survive JSON
- An island's CSS ships once, in the prerendered page
islands: falsein the config turns the pass offhydratable: truein the config adopts the whole page instead of mounting islands: the server's HTML is kept,client:*says when a piece attaches its handlers, and pieces share$context, stores and the route'sload()data (STATIC_RENDERING.md § Status)
In depth: README § Islands