## Demo: image
### ImageDemo.svelte
```svelte
A plain
Add
Caveat: props passed to a hydrated island — like this card's
This uses the default
Fourteen source photos, each resized to a square Component
<Image> renders a single resized <img> with no client JS:With a blur placeholder
placeholder to show a ThumbHash blur until the image loads — it's the <img>'s own background-image, so no client JS is needed.
The placeholder shows first, then the loaded image that paints over it:
Inside a hydrated island
<Image> also works inside a mochi:hydrate island: the server-minted URL and placeholder are serialized into the page (via Svelte's
hydratable) and reused during hydration, so the browser never needs the encryption secret. The button is live client-side state:
src — are serialized in plain text into the page for hydration, so the source URL is visible to the
client here. If your origin must stay secret, keep <Image> in server-rendered markup or a server island, whose props are encrypted.
Programmatic
getResizedImage() returns an encrypted URL you can use anywhere:{directUrl}
fit: 'inside', which preserves aspect ratio and fits within the 400×400 box — so this 3:2 photo becomes 400×267. Pass
fit: 'fill'
to force an exact square (stretching); Bun.Image has no crop/cover mode.
Full-size original
getImage() returns an encrypted URL for the un-resized original — fetched once and shared, so every resized variant above reuses this one cached download:
{originalUrl}
Gallery
<img> on the fly with a placeholder blur-up — all server-rendered, zero client JS: