← @mortar-kit/core

hydrateIslandsfunction

import { hydrateIslands } from '@mortar-kit/core'

function hydrateIslands(options: HydrateIslandsOptions): Promise<() => void>

Hydrates every island on the page: each interactive brick the server rendered on a page without JavaScript, on its own. Call it from the client entry on pages that have islands (hasIslands()), instead of hydrating the whole document. With loaders for bricks, it loads the bricks the page's islands use first, then hydrates them all at once. Resolves to a function that disposes them.

Parameters

Returns

Promise<() => void>

Example

// src/entry-client.tsx
if (hasIslands()) {
  hydrateIslands({
    bricks: lazyBricks(import.meta.glob('./bricks/*.tsx')),
    actions: islandActions({ action: brickActions.action, run: runBrickAction }),
  });
} else {
  const { Root } = await import('./Root.tsx');
  hydrate(() => <Root />, document);
}