Skip to content
whoisbrowsing

Add whoisbrowsing to SvelteKit

Updated

TL;DR

To add whoisbrowsing to SvelteKit, paste one script tag into src/app.html, the page template every route is rendered into. No package, hook or component is needed.

Using an AI coding agent? Give it this prompt:

Add whoisbrowsing (live visitor view) to this project. Follow https://whoisbrowsing.com/SKILL.md exactly.

Add the tag to src/app.html

The SvelteKit docs describe src/app.html as your page template, an HTML document with placeholders such as %sveltekit.head% and %sveltekit.body% that SvelteKit fills in for each page (SvelteKit project structure). Add the tag inside <head>, next to the placeholder:

<!-- src/app.html -->
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%sveltekit.assets%/favicon.png" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="https://live.whoisbrowsing.com/s.js" data-site="YOUR_SITE_ID" defer></script>
    %sveltekit.head%
  </head>
  <body data-sveltekit-preload-data="hover">
    <div style="display: contents">%sveltekit.body%</div>
  </body>
</html>

Because the tag sits in the template, it is in the server-rendered HTML of every page, and client-side navigation does not remove it.

If you set a CSP nonce

SvelteKit can add a nonce to scripts through %sveltekit.nonce%. If you use a nonce-based policy, add nonce="%sveltekit.nonce%" to the tag. If your policy lists hosts instead, use the lines in the CSP section below.

Where to get your site ID

Open /try to create a site with no sign-in (you can claim it later), or sign in with Google. You get a site ID to replace YOUR_SITE_ID in the code above. Each website is separate: localhost and production never mix, and www. is the same website as the bare domain.

SvelteKit apps change pages in the browser without a full reload. You do not need extra code: the script follows client-side route changes on its own, so each page a visitor moves to shows up in your live view.

Content-Security-Policy

If your site sends a Content-Security-Policy header, allow the script and its live connection:

script-src https://live.whoisbrowsing.com;
connect-src wss://live.whoisbrowsing.com;

Add these to your existing script-src and connect-src lists instead of replacing them. If you have no CSP, skip this step.

Verify

  1. Deploy, or run your site locally. Use the site ID made for that address, because localhost and production are separate websites.
  2. Open the whoisbrowsing dashboard and click Watch.
  3. Open your site in a Chrome Incognito window or a Safari private window. Your own normal browser is never counted, so a private window is how you test as a visitor.
  4. You should appear as a coloured cursor on your real page, with a line for you in the side panel.

If nothing shows up, check that the tag is in the page source, that the site ID matches the address you opened, and that a CSP or ad blocker is not stopping live.whoisbrowsing.com. See how it works for what is sent, and the privacy page for what is never sent or stored.

Let your AI agent do it

Paste this into Claude Code, Cursor or Codex:

Add whoisbrowsing (live visitor view) to this project. Follow https://whoisbrowsing.com/SKILL.md exactly.

The agent reads the instructions, creates a site, puts the tag in the right file for SvelteKit and gives you a watch link. The full walkthrough is in Install with an AI agent.

More install guides

See every platform on the install page, or jump to Next.js and React. Prefer to try first? Open /try. To see what the tag does, go to the home page.