## Demo: props-id ### PropsId.svelte ```svelte

Static component (no hydration)

$props.id() works with zero JavaScript shipped — the id is minted during SSR, no hydration required.

Two hydrated islands, two ids

Each instance gets its own id, so the label/for pairs never collide. Hydration reuses the server-generated value — the id you see was minted during SSR.

Server island

Deferred islands render in a separate request; Mochi namespaces their ids with the island's own id (via render's idPrefix) so they cannot collide with ids already on the page.

Server island that also hydrates

With mochi:defer mochi:hydrate the namespaced id is read back from the SSR markers when the fragment hydrates — click the button and the id stays exactly the same, proving the value survived from the deferred render into the hydrated client.

Two client-only islands, two ids

Client-only islands are never server-rendered, so each $props.id() is minted in the browser at mount. Svelte draws these from a global counter — unique even across separate mount() calls — so two independently-mounted islands still get distinct ids (e.g. c1 and c2) without any SSR pass to keep them apart.

``` ### Field.svelte ```svelte
{@render children?.(uid)}

$props.id(): {uid}

``` ### LabeledField.svelte ```svelte {#snippet children(uid)} {/snippet} ``` ### ServerStamp.svelte ```svelte

Rendered on demand in a separate request 🏝️

``` ### ServerHydratedStamp.svelte ```svelte

Rendered on the server, then hydrated 🏝️⚡

``` ### ClientStamp.svelte ```svelte

Never server-rendered — the id is minted in the browser at mount 🏝️🖥️

``` ### routes.ts ```ts import { Mochi } from 'mochi-framework'; import type { MochiRouteValue } from 'mochi-framework'; export const routes: Record = { '/demos/props-id': Mochi.page('./src/demos/props-id/PropsId.svelte'), }; ``` ### index.ts ```ts import { Mochi, logger } from 'mochi-framework'; import { routes } from './routes'; await Mochi.serve({ port: 3333, development: process.env.MODE === 'development', routes, }); logger.info('Server running at http://localhost:3333'); ```