Installation

Install svelte-build-og and register its Vite plugin.

Install svelte-build-og as a development dependency.

deno add --dev npm:svelte-build-og

Add one named input to vite.config.ts and point it at a SvelteKit route.

vite.config.ts
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";
import { include_og_types, og } from "svelte-build-og/vite";

export default defineConfig({
	plugins: [
		sveltekit({
			typescript: { config: include_og_types },
		}),
		og({
			input: {
				home: "/og/home",
			},
		}),
	],
});

The default capture is 1200 × 630 and the default output is PNG. On machines with a writable browser cache, Playwright installs Chromium automatically when the executable is missing. Read-only and serverless builds need an explicit browser provider, described in Configuration.

The include_og_types hook above registers .svelte-kit/svelte-build-og/generated.d.ts through SvelteKit's generated TypeScript configuration, keeping generated declarations beside SvelteKit's other output instead of in application source.

If the application changes SvelteKit's output directory, pass the same path to sveltekit_out_dir.

On this page