File Routes
You can serve a file straight from disk with Mochi.file() — pass a static path, or a resolver that picks the file per request from the route params. The file is read fresh on every request, so files written or deleted at runtime are picked up immediately. Missing files (or a resolver that throws error(404)) come back as a plain-text 404.
View source on GitHub<script>
import FileViewer from './FileViewer.svelte';
import { files } from './files.ts';
const sources = await loadSources(files);
</script>
<FileViewer mochi:hydrate />
More demos
Real-time Streams WebSocket and SSE clocks, lazily hydrated via mochi:hydrate:visible. Lazy Server Islands Server islands marked mochi:defer:visible only fetch when the wrapper scrolls into view. Form Redirects redirect(303, …) intercepted as a JSON envelope by {@attach enhance(...)}, or followed natively by the browser.