🍡 mochi

SSR framework for Svelte 5 + Bun with islands-based selective hydration

On this page

HTTP streaming

Mochi renders each page as one complete document. Svelte’s render from svelte/server runs to completion, then the HTML ships as a single text/html Response.

Streaming primitives

  • Mochi.sse(handler) — Server-Sent Events. The response body is a ReadableStream and stream.send(...) pushes events as they happen.
  • Mochi.ws(handlers) — WebSockets via Bun.serve upgrade. Bidirectional, message-by-message.

Reach for these to layer realtime UI on top of a rendered base page.

Keeping pages fast

  • Server islands (mochi:defer) load slow or personalized fragments out-of-band after the shell ships. The rest of the page renders immediately; the island fetches itself once the browser sees the placeholder.
  • Visible hydration (mochi:hydrate:visible) keeps the initial JS payload small.
  • Shared HTTP cache (Cloudflare, CloudFront, Fastly, Varnish, nginx) in front of the origin makes render time irrelevant for the cacheable common case. Server islands can stay uncached behind a cached shell — see Cache.

See it in action

Live demos showing key concepts from this page