# Catch JavaScript errors with one script tag

> Add Lampwick's script tag to your site's head and errors in your visitors' browsers become issues, next to your server's. No package, no build step.

A script tag in your site's `<head>` reports JavaScript errors from your visitors' browsers to Lampwick. It needs no package and no build step, so it also works in apps made with Lovable, Replit or v0.

## What you get

- Uncaught errors and unhandled promise rejections, with the stack trace, under **Issues** with a **Browser** label.
- Optional: `console.error` calls (`data-console`) and failed `fetch()` calls (`data-fetch`).
- Page URLs without the query string and fragment, which often hold tokens.
- A monthly budget of its own for browser errors, on top of your plan's events.

Lampwick doesn't apply source maps, so stack frames show positions in your bundle.

## Set it up

On the project's **Settings** page, under **Browser errors**, click **Get the snippet**. Copy the line into the `<head>` of your site's `index.html`, above the other scripts:

```html
<script src="https://app.lampwick.dev/b.js" data-key="YOUR_BROWSER_KEY" async></script>
```

`YOUR_BROWSER_KEY` starts with `lwpub_`; the snippet on the **Settings** page has it filled in. The key is meant to be in your page: it can only send errors to this project.

To test it, open your site and run this in the browser console:

```js
setTimeout(() => { throw new Error('Lampwick test') })
```

## Let your app builder do it

Paste this into the chat of Lovable, Replit or v0, with your key in it (the **Settings** page has this prompt ready to copy):

```text
Add the Lampwick error monitoring snippet to the <head> of index.html, exactly as written, before any other script:

<script src="https://app.lampwick.dev/b.js" data-key="YOUR_BROWSER_KEY" async></script>

Don't change the key or move it to an environment variable: it is a public, write-only key that is meant to be in the page. Don't wrap it in a component or install a package for it.
```

## Next step

The [browser errors docs](/docs/browser/) cover the options, **Allowed sites**, the limits and troubleshooting.
