## Demo: static-dirs ### StaticDirsDemo.svelte ```svelte

The gallery below is the site's images/ folder, mounted at /gallery. Each <img> points straight at the file on disk — a plain path, no query string, no signing, unlike the transformed image pipeline.

{#each photos as n (n)}
Mochi photo {n}
/gallery/mochi-{n}.jpg
{/each}

When to reach for it

staticDirs is one route per mount, so it stays cheap for large or generated trees — a media library, a docs export, another tool's build directory. It serves dotfiles and returns Bun's bare 404 on a miss. For ordinary site assets keep using publicDir, which registers one route per file, skips dotfiles, and falls through to your error page.

``` ### routes.ts ```ts import { Mochi } from 'mochi-framework'; import type { MochiRouteValue } from 'mochi-framework'; export const routes: Record = { '/demos/static-dirs': Mochi.page('./src/demos/static-dirs/StaticDirsDemo.svelte'), }; ``` ### index.ts ```ts import { Mochi, logger } from 'mochi-framework'; import { routes } from './routes'; await Mochi.serve({ port: 3333, development: process.env.MODE === 'development', // Mount a directory tree under a URL prefix — one Bun route, files served straight from disk. staticDirs: { '/gallery': './images' }, routes, }); logger.info('Server running at http://localhost:3333'); ```