## Demo: nested-components ### NestedComponents.svelte ```svelte

mochi:hydrate on the root

One island wraps the whole five-level tree. Mochi serializes the root and its descendants once, ships a single bundle, and Svelte hydrates the entire subtree together.

mochi:defer + mochi:hydrate

The same recursive tree, rendered lazily as a server island. The placeholder ships with the page; the browser fetches the rendered HTML on demand. Because mochi:hydrate is also set, Svelte takes over once the fetched markup lands.

Loading nested tree from server
``` ### Level.svelte ```svelte
Level {depth}{tag} {isBrowser ? 'hydrated' : 'SSR only'}
{#if depth < max} {/if}
``` ### routes.ts ```ts import { Mochi } from 'mochi-framework'; import type { MochiRouteValue } from 'mochi-framework'; export const routes: Record = { '/demos/nested-components': Mochi.page('./src/demos/nested-components/NestedComponents.svelte'), }; ``` ### index.ts ```ts import { Mochi, logger } from 'mochi-framework'; await Mochi.serve({ port: 3333, development: process.env.MODE === 'development', routes: { '/': Mochi.page('./src/Home.svelte'), }, }); logger.info('Server running at http://localhost:3333'); ```