Start
Packages
The ogygia package is the region system, and content, images, flags, the server router, postrender, federation, devtools and the build helpers are separate packages. Install the ones you use and list each plugin once beside ogygia() in your Vite config.
The ogygia package is the region system: islands, server islands, lakes, held regions, the SPA router, macros and the server handle. Every other feature is a separate package. You install only what you use, so an app that never reads a flag carries none of the flag code.
All of them except @ogygia/tsdown-plugin-svelte release together under one version number. Keep each of those @ogygia/* packages on the same version as ogygia.
Turning one on takes an install and one line in your Vite config, as here for flags:
import { sveltekit } from '@sveltejs/kit/vite';
import { ogygia } from 'ogygia/vite';
import { flags } from '@ogygia/flags/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [ogygia(), flags(), sveltekit()]
});Feature packages
Each of these adds something your pages can do. Each has its own section in these docs.
| Package | Plugin, from <package>/vite | What it is for |
|---|---|---|
@ogygia/content | content({ markdown, presets }) | Typed collections from markdown, JSON or a CMS; blocks; docs sites with nav and search. |
@ogygia/image | image({ presets, … }) | Responsive images made on request: AVIF and WebP, a srcset, a blur placeholder, share cards. |
@ogygia/router | router() | The server router: pages, layouts, loads, actions and endpoints as one typed table. |
@ogygia/postrender | postrender({ ttl, default }) | Pages stored whole on their first request and served as bytes. Needs dataShake() listed too. |
@ogygia/flags | flags() | Kill switches, rollouts and A/B tests, decided on the server. |
@ogygia/federation | federation() | Another team’s app rendered into your pages, as signed regions. |
@ogygia/devtools | devtools({ dock, profiler }) | The in-page dock and the SSR profiler. |
@ogygia/testing | testing(), in the app you test | The devtools’ measurements as Playwright checks: hydration, interactions, server time, page weight. |
@ogygia/rewrite | rewrite() | Your own pass over the HTML, such as a web-component server render, that islands survive. |
Build helpers
These change how your app is built rather than what a page can do. Most apps need none of them. Each has its own section in these docs. Note where each factory is imported from: not all of them use /vite.
| Package | Plugin | What it is for |
|---|---|---|
@ogygia/data-shake | dataShake() from @ogygia/data-shake/vite | A page ships only the page.data keys its islands read. Required by postrender. |
@ogygia/bake | bake() from @ogygia/bake | import.meta.og.bake(fn): run a function at build time and inline its result. |
@ogygia/barrels | barrels() from @ogygia/barrels | Barrel imports (import { Button } from '$lib/components') rewritten to the files they name. |
@ogygia/jumpstart | jumpstart() from @ogygia/jumpstart | The server build in a few files, for a fast cold start on serverless hosts. |
Tools
These have no plugin.
| Package | What it is for |
|---|---|
@ogygia/cli | The ogygia command: init, site init, the AI skill and MCP server, perf budgets, federation keys. |
@ogygia/insights | The analysis engine behind the dock, the profiler’s report and @ogygia/testing, for your own tooling. |
@ogygia/core | The shared core that ogygia re-exports and every plugin builds on. You install it only to write a plugin. |
@ogygia/tsdown-plugin-svelte | Ships a library’s Svelte components from a tsdown build, as svelte-package does. Has its own version number. |
ogygia depends on @ogygia/core and @ogygia/compiler (the region transform and the Vite plugin); core brings in @ogygia/machine (the state machines its runtime is built on). You don’t import the compiler or the machine in an app.
Plugin setup
Install the package, then list its plugin once in the plugins array of your Vite config, beside ogygia(). ogygia() comes first, the feature plugins follow, and sveltekit() goes last. Each plugin is a Vite plugin of its own, and ogygia() finds it in that list.
ogygia.handle() in hooks.server.ts already runs the server half of every listed plugin, and the page runtime starts every browser half. What the Vite config can’t hold is anything live or specific to your app: a flag vendor’s client, your federation keys, your route table, a store client. So most packages also ask for a line in hooks.server.ts, and each package’s overview says which.
npm i @ogygia/flags @ogygia/postrender @ogygia/data-shakepnpm add @ogygia/flags @ogygia/postrender @ogygia/data-shakeimport { sveltekit } from '@sveltejs/kit/vite';
import { ogygia } from 'ogygia/vite';
import { flags } from '@ogygia/flags/vite';
import { postrender } from '@ogygia/postrender/vite';
import { dataShake } from '@ogygia/data-shake/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
ogygia(),
flags(),
dataShake(),
postrender({ ttl: 600 }),
sveltekit()
]
});Plugin rules
The build checks each of these and fails with a message that names the fix:
- Call the factory. Write
flags(), notflags(plugin_factory_not_called). - List each plugin once (
plugin_listed_twice). - List it beside
ogygia(). A plugin listed withoutogygia()fails the build (plugin_without_ogygia), and so does one that needs another plugin you didn’t list (plugin_needs_plugin). - List it before
sveltekit()(plugin_after_sveltekit).
Options are plain JSON too, since they reach the plugin’s server half at run time. That one is only half checked: a value JSON.stringify throws on, such as a cycle or a BigInt, fails the build (plugin_options_not_json), but a function or class instance is dropped with nothing said (#2314, item 10). Live objects go in hooks.server.ts, through the package’s own API.
The plugins list is ordinary code, so you can list a plugin only where you want it, such as the devtools outside production.
import { sveltekit } from '@sveltejs/kit/vite';
import { ogygia } from 'ogygia/vite';
import { devtools } from '@ogygia/devtools/vite';
import { defineConfig } from 'vite';
export default defineConfig(({ mode }) => ({
plugins: [
ogygia(),
...(mode !== 'production' ? [devtools()] : []),
sveltekit()
]
}));Combining packages
When several packages need a handle, order them in the sequence() like this: postrender first, then any rewrite() handles, then ogygia.handle(), then the server router. A stored page is served before anything renders. A rewrite handle has to run before ogygia.handle(), and listing it after fails with rewrite_after_ogygia. The route table answers inside the request ogygia has already set up. In the example, components is a rewrite() handle.
The packages also read from each other with no wiring from you. A flag read marks the render as per-visitor, so postrender never stores one variant of a test. A route table sets postrender’s setting per page. A federated fragment is a region, so a publish on another team clears the stored pages that included it. Each package’s overview has a “with other packages” part that shows these.
To write a package of your own on the same API, see Plugins.
import { sequence } from '@sveltejs/kit/hooks';
import * as ogygia from 'ogygia/server';
import { postrender } from '@ogygia/postrender';
import { components } from '$lib/server/components';
import { router } from '$lib/router';
export const handle = sequence(
postrender.handle(),
components,
ogygia.handle(),
router.handle
);