🍡 mochi

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

Architecture

Framework source lives in packages/mochi/src/; the demo site that consumes it lives in packages/site/src/. The files you reach for most often:

  • packages/site/src/index.ts — HTTP server entry point; calls Mochi.serve() and defines the demo site’s route record inline.
  • packages/mochi/src/Mochi.tsMochi.serve(), Mochi.page(), Mochi.api(), Mochi.ws(), Mochi.sse().
  • packages/mochi/src/ComponentRegistry.ts — SSR compilation, hydration preprocessing, client bundling.
  • packages/mochi/src/hooks.ts — middleware system (Handle, sequence()).
  • packages/mochi/src/utils.tsjson(), error(), header helpers.
  • packages/mochi/src/middleware/compress.ts — optional compress() middleware (brotli + gzip negotiation).
  • packages/mochi/src/middleware/noCache.ts — optional noCache middleware that defaults Cache-Control: no-cache.
  • packages/mochi/src/web-components/HydratableIsland.ts — client-side custom element for island hydration.
  • packages/mochi/src/web-components/ServerIsland.ts — client-side custom element for server island fetching.
  • packages/mochi/src/serverIslandCrypto.ts — HMAC signing/verification for server island props.
  • packages/mochi/src/types.ts — shared TypeScript types.