bugsnap

guide ยท sveltekit

Add an 18 KB Bug Report Widget to SvelteKit

How do you add a bug report widget to SvelteKit? Paste BugSnap's 18 KB defer script before </body> in src/app.html. It persists across client-side navigations with zero runtime dependencies, masks sensitive inputs before capture, and attaches up to 20 recent errors at $0 forever.

1. add it to src/app.html

Open src/app.html and paste the tag right before </body>:

<script
  src="https://getbugsnap.pages.dev/widget.js"
  data-project-key="YOUR_PROJECT_KEY"
  data-trigger="on-error"
  defer
></script>

2. ssr and client navigation

Placing the script in src/app.html avoids Svelte component hydration overhead and keeps the on-error listener active across all SvelteKit routes. The page shell loads once, so the widget is not re-mounted on each client-side navigation.

No TypeScript setup is needed: you never import the widget, so src/app.d.ts stays unchanged.

3. why it fits sveltekit

  • Zero runtime dependencies: 18 KB minified (about 8 KB gzipped), loaded with defer so it never blocks Svelte hydration.
  • Invisible by default: with data-trigger="on-error" it stays hidden until a JavaScript crash, failed API call, broken image or dead click.
  • Masked before capture: passwords, emails, phones, card and checkout inputs, payment iframes and data-bugsnap-mask elements never reach the screenshot.
  • Markdown for AI fixes: each report includes up to 20 recent errors and copies as Markdown for Claude Code, Cursor or Codex.

Using another stack? See the Next.js, React & Vite and Astro guides. Testing a bug yourself? Scrub your console output with the free log privacy redactor, then turn it into an agent prompt with the bug report to AI prompt generator. Or go back to the BugSnap homepage.

frequently asked questions

Where do I put the BugSnap script in SvelteKit?

In src/app.html, right before the closing body tag. That shell wraps every route, so one tag covers the whole app.

Does it survive SvelteKit client-side navigation?

Yes. The script loads once with the page shell and its window-level error listener stays active as routes change.

What does it cost?

$0 forever on the hosted tier (5 projects and 100 reports a month), or unlimited when self-hosted under the MIT license.

add bugsnap in one line.

$0 free forever and MIT open source. Hidden until a real bug, privacy masking always on.

<script src="https://getbugsnap.pages.dev/widget.js" data-project-key="YOUR_PROJECT_KEY" data-trigger="on-error" defer></script>