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';
import { files } from './files.ts';
const sources = await loadSources(files);
</script>
<div class="row">
<CounterButton mochi:hydrate />
<CounterButton mochi:hydrate />
</div>
Styles
<style>
.row {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
</style>
More demos
File Routes How file routes work — serve a file from disk with Mochi.file(), as a static path or a per-request resolver. 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. File Uploads via form actions How file uploads through form actions work — multipart/form-data validated with fail() and success(), shown enhanced and plain.