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. Form Errors How form action errors work — a thrown action error shows inline via {@attach enhance(...)}, or as the Mochi error page on a plain submit. HTML Entities in Props How HTML entities in island props work — an entity in a static prop (label="Tom & Jerry") decodes identically on the server and after hydration.