Cookies
You can read incoming cookies during SSR and write them back via Set-Cookie through the Mochi cookies API exposed on both server and client.
<script>
import CookieDemo from './CookieDemo.svelte';
import { files } from './files.ts';
const cuteNames = ['mochi_fan', 'bun_bun', 'pixel_panda', 'tiny_tanuki', 'cloud_kitten', 'waffle_fox', 'cocoa_bear', 'starry_otter', 'maple_duck', 'peach_pup'];
const randomCuteName = cuteNames[Math.floor(Math.random() * cuteNames.length)];
const sources = await loadSources(files);
</script>
<CookieDemo defaultUsername={randomCuteName} mochi:hydrate />
More demos
Cookie Vary Test A page that sets Vary: Cookie on its response — useful for testing cookie-partitioned cache keys. Font loading Ship fonts via @fontsource packages or standalone .woff2 files — automatically bundled and linked from the page head. Lazy Server Islands Server islands marked mochi:defer:visible only fetch when the wrapper scrolls into view.