Regions
Lakes
A lake is static HTML inside an island, rendered on the server with no JavaScript even though the island around it is interactive. It also keeps site chrome static on pages Kit hydrates.
Unmarked markup on a csr = false page already costs nothing. The cost appears once that markup sits inside an island: everything a hydrating component renders compiles into the island’s client bundle. That includes long prose, a prerendered chart, a highlighted code block or a gallery that never changes.
A lake takes a subtree back out. You mark its import with wake: 'none' inside the island’s own file. The lake renders on the server like anything else, but its code ships in no bundle. When the island hydrates, ogygia lifts the lake’s HTML out of the way, lets the island hydrate around it, and puts it back.
The page places Dashboard as an island, so Filters hydrates with it. Report is a lake: rendered once on the server and never hydrated.
<script>
import Dashboard from '$lib/Dashboard.svelte' with {
wake: 'load'
};
let { data } = $props();
</script>
<Dashboard rows={data.rows} /><script>
import Filters from '$lib/Filters.svelte';
import Report from '$lib/Report.svelte' with {
wake: 'none'
};
let { rows } = $props();
</script>
<Filters />
<Report {rows} />Use cases
Use one when a subtree inside an island is expensive to ship and never changes on the client: prose, a large server-rendered chart, a code block highlighted on the server, a list of cards.
Outside an island, you don’t need one. Unmarked markup on a csr = false page is already static. A lake at the top of such a page renders as plain HTML, the same as if you hadn’t marked it.
A lake can’t be interactive. Its buttons and inputs do nothing, because none of its code ships. For an interactive part inside a lake, put an island in the lake: an island inside a lake gets its own JavaScript and wakes on its own schedule. See nesting.
In the example, Article is an island, so Reactions hydrates with it. Prose is a lake, so the article text ships no code, and CopyButton inside it is an island of its own again.
<script>
import Prose from '$lib/Prose.svelte' with { wake: 'none' };
import Reactions from '$lib/Reactions.svelte';
let { post } = $props();
</script>
<Prose html={post.html} />
<Reactions id={post.id} /><script>
import CopyButton from '$lib/CopyButton.svelte' with {
wake: 'visible'
};
let { html } = $props();
</script>
<CopyButton text={html} />
<div class="prose">{@html html}</div>Live lakes
A plain lake keeps the HTML it was rendered with. When the island around it hides the lake and shows it again (an {#if}, a tab switch), the lake comes back with that same HTML.
A live lake can refresh. Mark it render: 'live', and wake becomes its revalidation schedule (load, idle, visible or a media query). When the island mounts the lake again, the lake shows the HTML it had at once, then fetches fresh HTML from the signed endpoint on that schedule and swaps it in. On a page served from postrender’s store, a live lake also revalidates when the page first loads, so a stored page’s header can show the visitor’s own data.
In the example, Sidebar is an island the page places with wake: 'load', and Prices is a live lake inside it. Each time the visitor opens the panel again, it shows the last prices at once and fetches new ones when the browser is idle.
Tune a live lake in a preset:
maxAge: how old the remembered HTML may get before it counts as expired. Use a duration string ('10m'). A bare number here means milliseconds, unlike a server island’smaxAge, which is seconds.onExpire: what an expired lake does when it mounts again.'fetch'(the default for a live lake) fetches fresh HTML;'empty'mounts empty. With revalidation off, the default is'empty', and'fetch'fails the build (region_import_invalid).revalidate: the revalidation schedule, used only when the preset sets nowake(awakealways wins). Usefalse, with nowake, to turn revalidation off.
With neither wake nor revalidate, a live lake revalidates on 'load'. With no maxAge, its remembered HTML never expires.
A live lake’s props are serialized for the endpoint, so bind:, an event attribute or a function prop on it fails the build (region_import_invalid). So do children between its tags.
A live lake needs an island around it, because it refreshes when that island mounts it. A live lake at the top of a page has no host, so on normal pages it never revalidates, and dev warns (live_region_no_host). render: 'live' is for .svelte files; a .ts module can’t take it (held_render_live).
A live lake isn’t a live region. For HTML that the server sends again as data changes, a held region over query.live, see live regions instead.
import { sveltekit } from '@sveltejs/kit/vite';
import { ogygia } from 'ogygia/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
ogygia({
presets: {
ticker: { render: 'live', wake: 'idle', maxAge: '10m' }
}
}),
sveltekit()
]
});<script>
import Prices from '$lib/Prices.svelte' with {
preset: 'ticker'
};
let open = $state(true);
</script>
<button onclick={() => (open = !open)}>Prices</button>
{#if open}<Prices />{/if}<script>
import Sidebar from '$lib/Sidebar.svelte' with {
wake: 'load'
};
</script>
<Sidebar />Site chrome on Kit pages
A lake also works at the top of a layout, as site chrome, and it keeps working on pages Kit hydrates. Mark the header’s import with wake: 'none':
- On a
csr = falsepage, the header is plain server HTML. - On a
csr = truepage, Kit hydrates the document but adopts the lake: the server element stays exactly as it was, and the header’s code ships in no bundle, not even Kit’s.
Everything inside the lake stays on ogygia’s runtime on both kinds of page. A server island inside the header (an account menu, a cart count) still fetches, and a wake: 'interaction' search box inside it still wakes on the first click. Kit never hydrates inside a lake.
That gives a site header its usual shape: static markup for the menu, holes for the personal parts, and one small island for search. Anonymous visitors download none of the header’s code, and the same header works on the few pages that need csr = true.
<script>
import Header from '$lib/Header.svelte' with { wake: 'none' };
let { children } = $props();
</script>
<Header />
{@render children()}<script>
import Search from '$lib/Search.svelte' with {
wake: 'interaction'
};
import Account from '$lib/Account.svelte' with {
render: 'deferred'
};
</script>
<header>
<a href="/">Home</a>
<Search />
<Account>
{#snippet ogygiaFallback()}<a href="/login">Sign in</a
>{/snippet}
</Account>
</header>Server HTML
A lake is server HTML, so it needs a server render to adopt. If Kit mounts a lake fresh during a client-side navigation, there’s no HTML for it. ogygia restores it when the document rendered it before; otherwise it stays empty, and dev warns (lake_mounted_without_html).
So keep chrome lakes in a layout that stays across navigations, or serve those routes with csr = false. To refresh a lake’s content after something changes on the server, such as a saved language, render it as a held region instead: see Refresh a site header.
After an SPA navigation with ogygia’s router, a lake inside kept layout chrome settles again, so the islands inside it can wake. See SPA router.
Do and don’t
- Do put the heaviest static content inside an island (prose, charts, code) in a lake.
- Do use
render: 'live', inside an island, when a lake’s HTML has to refresh. - Do mark a header
wake: 'none'in a layout to keep it static oncsr = truepages too. - Don’t put interactive UI in a lake directly. Nest a client island inside it.
- Don’t mark static markup that isn’t inside an island. It ships no code without a mark.