Install with the CLI
SvelteKit
1
Environment variable
.env:2
Init module
src/lib/lucent.ts:3
Call initLucent in the root layout
src/routes/+layout.svelte:Plain Svelte
1
Environment variable
.env:2
Init module
src/lib/lucent.ts:3
Call initLucent in your root component
src/App.svelte:Notes
- SvelteKit uses
$env/static/publicfor publicly‑accessible env vars that need thePUBLIC_prefix. Plain Svelte uses the ViteVITE_prefix. onMountensures the tracker only initializes in the browser — the init module is safe to import during SSR, but callinginitLucent()at the module top level would crash on the server.