Server Props
You can pass data from the route definition into the root Svelte component for the route via a serverProps resolver. The resolver runs on every request, so each reload produces fresh values.
- Rendered at
2026-06-19T19:50:30.016Z- Random number
6860- Your User-Agent
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Reload the page to see the values change — each request re-runs the resolver.
<script lang="ts">
import { files } from './files.ts';
const sources = await loadSources(files);
let { renderedAt, userAgent, random }: { renderedAt: string; userAgent: string; random: number } = $props();
</script>
<div class="card">
<dl>
<dt>Rendered at</dt>
<dd><code>{renderedAt}</code></dd>
<dt>Random number</dt>
<dd><code>{random}</code></dd>
<dt>Your User-Agent</dt>
<dd><code>{userAgent}</code></dd>
</dl>
<p class="hint">Reload the page to see the values change — each request re-runs the resolver.</p>
</div>
Styles
<style>
.card {
background: var(--surface);
color: var(--text);
border-radius: var(--radius-lg);
border: 1px solid var(--border);
padding: 1.5rem;
max-width: 560px;
margin: 0 auto;
}
dl {
display: grid;
grid-template-columns: max-content 1fr;
column-gap: 1.25rem;
row-gap: 0.75rem;
margin: 0 0 1rem 0;
}
dt {
font-weight: 600;
color: var(--text-muted);
}
dd {
margin: 0;
word-break: break-all;
color: var(--text);
}
code {
font-family: var(--font-mono);
background: var(--code-bg);
color: var(--code-accent);
padding: 0.2rem 0.45rem;
border-radius: var(--radius-sm);
font-size: 0.9em;
}
.hint {
color: var(--text-subtle);
font-size: 0.9rem;
margin: 0;
}
</style>
More demos
Hydratable Compute a value once on the server with hydratable(); the hydrated island reads it from <head> instead of re-running the async work. Data Loading Server-side fetch from PokéAPI cached via MochiCache and rendered at request time. Cookie Vary Test A page that sets Vary: Cookie on its response — useful for testing cookie-partitioned cache keys.