bugsnap

guide ยท astro

How to add an 18 KB bug report widget to Astro

Add BugSnap's single deferred <script> tag to src/layouts/Layout.astro before </body>. It is 18 KB (about 8 KB gzipped), has zero dependencies, needs no Astro integration or session-replay middleware, and is $0 forever.

1. add it to src/layouts/Layout.astro

Open your base layout and paste the snippet right before </body>. is:inline tells Astro to leave the tag as written instead of bundling it:

---
const bugsnapKey = import.meta.env.PUBLIC_BUGSNAP_KEY;
---
<html lang="en">
  <body>
    <slot />
    <script
      is:inline
      src="https://getbugsnap.pages.dev/widget.js"
      data-project-key={bugsnapKey}
      data-trigger="on-error"
      defer
    ></script>
  </body>
</html>

Put PUBLIC_BUGSNAP_KEY in .env. The PUBLIC_ prefix makes it available when the page renders.

2. why it fits Astro's zero-bloat approach

  • No hydration cost: a small deferred script. No React or Vue island just to show a bug form.
  • Invisible by default: with on-error, your docs, marketing site or app stays clean until a visitor hits a broken image, failed API call, JavaScript crash or dead click.
  • Masked before capture: passwords, emails, card inputs and payment iframes are masked before the screenshot is drawn, and there is no always-on session replay.
  • Markdown for AI fixes: copy any report as Markdown for Claude Code, Cursor or Codex, or send it to GitHub Issues. Try the format with the free bug report to AI prompt generator.

Want the details? Read how BugSnap masks cards, passwords and tokens before a screenshot exists, and how to turn live bug reports into prompts for AI coding agents.

frequently asked questions

Does BugSnap work with Astro static output and SSR?

Yes. It is a plain browser script tag, so it works the same on static builds (Cloudflare Pages, Netlify, Vercel) and on SSR deployments.

Do I need an Astro integration package or middleware?

No. One script tag in Layout.astro handles error detection, masked screenshots and delivery.

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>