🍡 mochi

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

Mochi 0.9.0

Mochi 0.9.0 is out, with 30 commits since 0.8.0. It’s a smaller release, but with some breaking changes.

Faster builds with rsvelte

rsvelte is a Rust port of the Svelte 5 compiler built on OXC, and Mochi can now route component compilation through it. It’s opt-in — add @mochi-framework/rsvelte and pick the backend:

await Mochi.serve({
  svelteCompiler: 'rsvelte',
  routes,
});

On the demos preset from bun create mochi@latest:

phasesveltersveltedelta
total384ms289ms−25%
ssr-build213ms137ms−36%
client-bundle40ms26ms−35%

Request cache

The request cache memoizes work for the duration of a single HTTP request, so a lookup rendered by ten components runs once. Concurrent callers share one in-flight promise. The cache is reset on every new request.

import { requestCache, requestMemo } from 'mochi-framework';

const user = await requestCache(`user:${id}`, () => db.user(id));

// Or wrap once at module scope — every importer shares the memo.
export const getUser = requestMemo((id: string) => db.user(id));

Relocatable builds

Build output no longer contains a single absolute path, and the same commit built on any machine produces identical island names, bundle filenames and SSR’d HTML.

Mochi.serve({ manifest: '/srv/app/build/manifest.json' });

The public directory

publicDir is no longer copied into the build — the runtime scans it from disk at boot.

Precompiled email templates

mochi-framework build now compiles every template in src/emails/ into the manifest, so sending no longer waits on a cold compile.

await Mochi.email({ to, subject: 'Welcome', component: './src/emails/Welcome.svelte', props });

Other improvements

  • Captcha<MochiCaptcha /> no longer hangs on slow mobile browsers, and its proof-of-work difficulty and solve budget are now configurable.
  • Extensions — pulling a server-only module into a client bundle now fails the build.
  • Svelte Shakeroptimize requires svelte-shaker 0.18.1 or newer, which fixes a bug that stripped mochi: directives so islands never hydrated.

Install or upgrade

New project:

bun create mochi@latest my-app

Existing project — bump the dependency and restart the dev server:

bun add mochi-framework@latest   # or @0.9.0 to pin
bun run dev

The full changelog has everything else. Mochi is still early and in alpha — if something breaks, Discord or a GitHub issue both work.

Stanislav

← All posts