Fully automated for both SvelteKit and plain Svelte.
Install with the CLI
Pick Svelte / SvelteKit when prompted, then choose your setup.
SvelteKit
Call initLucent in the root layout
src/routes/+layout.svelte:
Plain Svelte
Call initLucent in your root component
Notes
- SvelteKit uses
$env/static/public for publicly‑accessible env vars that
need the PUBLIC_ prefix. Plain Svelte uses the Vite VITE_ prefix.
onMount ensures the tracker only initializes in the browser — the init
module is safe to import during SSR, but calling initLucent() at the
module top level would crash on the server.