Skip to content

API

ogygia/server

The SvelteKit server handle.

On this page

This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.

Exports document · handle · ogygiaServerTransport · DocumentOptions · OgygiaHandleOptions

import { … } from 'ogygia/server';

document

function

Render a region into a complete ogygia document and return it as a Response.

import { document } from 'ogygia/server';
import { region } from 'ogygia';

return document(region(Dashboard, { stats }), { title: 'ogygia profiler' });
function document(of: RegionValue | PromiseLike<RegionValue>, options?: DocumentOptions): Promise<Response>;

handle

function

function handle(options?: OgygiaHandleOptions): Handle;

ogygiaServerTransport

const

const ogygiaServerTransport: typeof ogygiaTransport

DocumentOptions

interface

DocumentOptions.title

<title> — used only when no component set one via <svelte:head> (the component wins).

DocumentOptions.head

Raw extra head HTML (meta tags, fonts, …), appended after the rendered head.

DocumentOptions.status

HTTP status (default 200).

DocumentOptions.headers

Extra/override response headers. content-type and cache-control: no-store are the defaults (under an eligible FREEZE request the cache-control default is left to the verdict).

DocumentOptions.lang

<html lang> (default 'en').

DocumentOptions.pageState

Seed for $app/state inside islands (page.data/params/url, route.id, form). The router passes it so islands on a rendered page read $page just like on a Kit-served page. Promises in data/form aren't streamed here — a non-serializable leaf is left out where it sits.

interface DocumentOptions {/*…*/}
title?: string;
head?: string;
status?: number;
headers?: HeadersInit;
lang?: string;
pageState?: {
    url?: {
      href?: string;
    };
    params?: Record<string, string | undefined>;
    route?: {
      id: string | null;
    };
    status?: number;
    data?: unknown;
    form?: unknown;
    error?: unknown;
  };

OgygiaHandleOptions

interface

Options for handle.

OgygiaHandleOptions.endpoint

Path (relative to Kit base) of the islands endpoint: the handle answers on it, and every hole and live region on a page is minted against it. Default /__ogygia__. Must start with /.

It must be a path your deployment forwards to the app (behind a proxy that forwards only known prefixes, pick one under them, e.g. /_server/api/__ogygia__). Not under Kit's appDir (/_app/…): Kit answers those itself, before any handle runs.

OgygiaHandleOptions.secret

The secret that signs region capabilities (hole and live-region URLs). Takes precedence over the OGYGIA_SECRET environment variable, for a host whose server process never sees its runtime env. Pass a build-time private env value:

An empty or blank value counts as not given (OGYGIA_SECRET, then a per-build random key, sign instead). It signs exactly as the same value in OGYGIA_SECRET does, so pages from either verify on the other. In production it needs ≥16 UTF-8 bytes. Every deployment that serves your pages or your islands endpoint needs the same secret.

interface OgygiaHandleOptions {/*…*/}
endpoint?: string;
import { OGYGIA_SECRET } from '$env/static/private';
export const handle = ogygia.handle({ secret: OGYGIA_SECRET });
secret?: string;