🍡 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, then ships the HTML as a single text/html response.

Streaming primitives

  • Mochi.sse(handler) — Server-Sent Events. stream.send(...) pushes events as they happen.
  • Mochi.ws(handlers) — WebSockets over the Bun.serve upgrade. Bidirectional, message by message.

Use these to layer real-time 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 island fetches itself once the browser sees the placeholder.
  • Visible hydration (mochi:hydrate:visible) keeps the initial JavaScript payload small.
  • Shared HTTP cache (Cloudflare, CloudFront, Fastly, Varnish, nginx) in front of the origin makes render time irrelevant for the cacheable case. A server island can stay uncached behind a cached shell — see Cache.
  • compress() streams every encoding it offers (gzip, zstd, deflate) through a CompressionStream, so a compressed response stays chunked.

See it in action

Live demos showing key concepts from this page