Skip to content

khromov/mochi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

106 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mochi

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

Early prototype. Only use in production if you are brave!

Quick start

bun create mochi@latest

(Requires Bun >= 1.3.13, Why Bun?)

Documentation

https://mochi.fast/

Live demos

Example sites built with Mochi:

https://demos.mochi.fast/

Setting up the development environment

curl -fsSL https://bun.com/install | bash # install bun if you don't have it already
bun i
bun dev

Bun must be v1.3.14 or newer (see .bun-version).

Available sites

Goals

  • Partial hydration — non-hydrated components aren't added to bundles
  • Minimal bundle sizes
  • Deploy anywhere Bun / Bun.serve() runs
  • Optional SQLite via bun:sqlite

Non-goals

  • Full SPA router (use View Transition)
  • Streaming (not in 0.x, possibly in 1.0)
  • Running outside of Bun

See PITCH.md for a Mochi-vs-SvelteKit feature comparison.

Repository layout

Path What
packages/mochi The mochi-framework library — full docs live in its README
packages/site Documentation + demo site (mochi.fast)
packages/demos Standalone demos site (HN clone, admin, todo) — deployed separately
packages/minimal Bare-bones hello-world template — also bundled by create-mochi
packages/cli create-mochi scaffolder — published to npm

Running locally

Sites run side-by-side; each has its own default port.

Command Site Default port
bun run dev All workspaces with a dev script, in parallel 3333 + 3334 + 3335
bun run dev:site Just the documentation site (packages/site) 3333
bun run dev:demos Just the demos site (packages/demos) 3334

Override the port with PORT=… if needed (single-site commands only — PORT would collide if applied to both at once). Production equivalents are bun run start, bun run start:demos, and bun run start:all.

Building

Command Builds
bun run build:site Just the main site
bun run build:demos Just the demos site
bun run build Both, in order

Quality checks

Command What
bun run checks lint:fix + format + typecheck + test (run before PR)
bun run typecheck tsc --noEmit across every workspace
bun run test bun test across every workspace
bun run lint eslint . (use lint:fix to autofix)
bun run format prettier --write . (use format:check in CI)
bun run loc Lines-of-code report (.github/scripts/loc-report.ts)
bun run deps Dependency report (packages/mochi/scripts/dep-report.ts)
bun run flamegraph Generate a flamegraph of the site (scripts/flamegraph.ts)

Deployment

The two main sites (docs and demos) build to their own Docker image and deploy to separate CapRover apps via .github/workflows/build.yml (matrix strategy).

Site Dockerfile GHCR image CapRover app Deploy token secret
site Dockerfile ghcr.io/khromov/mochi mochi APP_TOKEN
demos packages/demos/Dockerfile.production ghcr.io/khromov/mochi-demos mochi-demos APP_TOKEN_DEMOS

Install

Scaffold a new app with create-mochi:

bun create mochi@latest my-app

Then follow the Your first Mochi app walkthrough for a four-step tour of routes, islands, and server islands.

Or add the framework to an existing project:

bun add mochi-framework

Documentation

packages/mochi/README.md

Contributing / releases

See CONTRIBUTING.md. Releases are automated via release-please using Conventional Commits.

License

MIT

About

Lightweight full-stack SSR & Islands-framework for Svelte 5 + Bun

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors