@traffical/svelte integrates Traffical with Svelte’s runes and SvelteKit’s data-loading system. It wraps @traffical/js-client, so everything the browser client supports works here too.
Requires Svelte 5 (uses runes).
Installation
Setup
Wrap your app withTrafficalProvider in a root layout:
traffical_sk_..., scopes sdk:read+sdk:write) in browser code — it is browser-safe.
Resolving parameters
UseuseTraffical in any component:
params is reactive via runes — Svelte automatically re-renders when the bundle refreshes or context changes.
Setting context
Pass context through the provider:SvelteKit SSR
Fetch the bundle in a serverload function and pass it through to the client to avoid a second fetch:
localConfig and hydrates without a second fetch. No flash of original content.
See SSR patterns for the full pattern, including per-page pre-resolution.
Anonymous users and identify
The Svelte SDK uses the browser client’s stable-ID handling. When the user logs in:
Next steps
SSR patterns
Avoiding FOOC with SvelteKit and Next.js.
Canonical experiments
Patterns for web UI and SSR tests.