Open the console

Embedding an onboarding checklist in a Svelte app

The widget is a plain script tag, which makes SvelteKit's lifecycle the only thing to get right. Here is where to mount it and what breaks otherwise.

Embedding an onboarding checklist in a Svelte app

The onboarding checklist widget is a plain script that mounts a custom element and manages its own lifecycle — it does not need a Svelte-specific SDK, and does not have one. The integration work in a SvelteKit app is entirely about where and when that script runs, because SvelteKit renders on the server first and the widget, like any DOM-dependent script, cannot run there.

Loading the script client-side only

In SvelteKit, a component that touches window or injects a script tag has to do so inside onMount, which only runs in the browser — calling it at the top level of a component runs during server-side rendering too, where there is no DOM to mount into and the call throws.

<script>
  import { onMount } from 'svelte';

  onMount(() => {
    const s = document.createElement('script');
    s.src = 'https://gettingstarted.marthaia.com/embed.js';
    s.defer = true;
    document.body.appendChild(s);
  });
</script>

<gs-checklist project="your-project-id" user-id={userId}></gs-checklist>

The custom element and SvelteKit's hydration

The <gs-checklist> tag itself can sit directly in the markup; Svelte does not try to manage a custom element's internals the way it manages its own components, so there is no conflict with reactivity or hydration there. The only timing issue is the attribute values — user-id has to be a real value by the time the script initializes the element, so if the user id comes from an async call (a session check, a store that populates after mount), guard the element behind that data being ready rather than rendering it with an empty attribute and hoping the widget re-reads it later.

Server load functions and the checklist's own data

Nothing about the checklist's state needs to go through a SvelteKit load function — the widget fetches its own config and state client-side once mounted. Routing the state call through your server load function would mean re-implementing the widget's own data fetching for no benefit, and would desync the moment a step completes client-side after the initial load already ran.

What not to do

Do not conditionally render the checklist based on $page.url changes without accounting for SvelteKit's client-side navigation reusing the same page instance — a checklist mounted once in a layout and expected to persist across route changes needs the project and user id passed as reactive values, not computed once on first mount, or it goes stale on navigation instead of updating.

What to measure instead of guessing

Nobody has measured how different SvelteKit's SSR-then-hydrate flow makes this feel versus a pure SPA — that is worth checking on your own app rather than assuming. What matters concretely: confirm in the browser's network tab that the config and state calls fire once per navigation, not once per component re-render, which is the usual SvelteKit-specific bug with any third-party mount.

See the docs for the full embed script reference, and the live preview for a working instance.

Try it on your app