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
Client-only Islands How client-only islands work — components marked mochi:clientOnly skip SSR and mount in the browser, with a fallback snippet until then. Realtime Admin Panel Live admin dashboard with WebSocket updates and server-driven state. Using form return data How form action return data works — an action returns success({...}); {@attach enhance(...)} updates the UI in place, plain HTML re-renders.