🍡 mochi
← All demos

Shared State

Two separately-hydrated islands sharing the same reactive $state. 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>