Real-time Chat
An example of building a simple in-memory chat using a hydrated island and the built-in WebSocket support in Bun. The server stores message history and replays it to new connections; ws.publish() broadcasts each message to all clients. Open this page in two tabs to see them sync in real time.
Chat
<script>
import ChatWidget from './ChatWidget.svelte';
import { files } from './files.ts';
const sources = await loadSources(files);
</script>
<ChatWidget mochi:hydrate />
More demos
Cancelling form submissions How cancelling form submissions works — cancel() stops the fetch before it fires; controller.abort() stops one mid-flight. Request Cache How the request cache works — requestMemo and requestCache run an expensive computation once per request no matter how many components call it, then discard it at the request boundary. Hydration Modes How the hydration modes work — mochi:hydrate, mochi:hydrate:visible, rootMargin tuning, and mochi:defer server islands side by side.