Shared State
You can share reactive $state between separately-hydrated islands. Click either button — the count stays in sync across both.
<script>
import CounterButton from './CounterButton.svelte';
</script>
<div class="row">
<CounterButton mochi:hydrate />
<CounterButton mochi:hydrate />
</div>
Styles
<style>
.row {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
</style>
More demos
Charts with LayerChart How a third-party Svelte component library works in Mochi — LayerChart server-rendered to plain SVG with zero JavaScript, then the same library as mochi:hydrate and mochi:clientOnly islands. isHydratable() How isHydratable() works — detect from any depth whether the current subtree will hydrate, for SSR-only fallbacks without prop forwarding. Lazy Islands How lazy hydration works — islands marked mochi:hydrate:visible hydrate and load their CSS only when scrolled into view.