# Fix JavaScript errors in production

> When users hit a JavaScript error in the browser, see what they were doing, read the stack trace in your own source files, and confirm the fix on real traffic.

Section: Find and fix real problems · Page: https://tryrelia.com/docs/javascript-errors · Last checked against the product: 2026-11-01
Video walkthrough: https://youtu.be/DrD9OWbQ_nQ

A browser error often shows up to users as something quietly missing: a blank card, a button that does nothing, a page that never finishes. Relia's browser SDK records these errors with what the user did just before, so you can find the line that broke.

The example is Relia's demo shop: on a product page the product card comes up blank, because the code reads `price` from something that is `undefined`.

## Before you start

- Relia's browser SDK in your web app. See [Watch your web app](https://tryrelia.com/docs/web-app-setup.md).
- For readable stack traces: source maps uploaded for each build (below). Without them the stack points into minified code.

## What you'll see

- **Home** says something needs you, for example *Users hit a JavaScript error on /products/:id (TypeError: Cannot read properties of undefined (reading 'price'))*. **Users** shows **Needs you**.
- A browser error alone becomes **Needs you** once at least 3 different people hit it. When the error comes with a failing API request in the same visit, Relia joins them into one incident.

## Find the cause

1. **Open the incident.** It names the error, the page and how many people hit it.
2. **Open a visit.** Go to **Users**, then **Sessions**, find a visit that ended in the error and click **View**.
3. **Read the Timeline.** It shows the pages, clicks and requests in order, so you can see what happened right before the error.
4. **Open Console.** The **Console Error** shows the message and the stack. With source maps, the top frame is your own file, line and function (for example `src/components/ProductCard.tsx:42 in renderPriceBadge`) with the code around it. **Show minified stack** still shows the original.
5. **Read Do this next.** With source maps it points straight at the line: *Fix TypeError: … at src/components/ProductCard.tsx:42 (in renderPriceBadge).*

## Get readable stack traces (source maps)

If the stack points into a bundle like `index-a8f3.js:1`, upload your source maps. `npx relia-sdk@latest init` sets this up for you when it sets up a web app. To do it by hand:

**Vite:** add the plugin to `vite.config`:

```ts
// vite.config.ts
import { reliaSourcemaps } from "relia-sdk/vite"

export default { plugins: [reliaSourcemaps({ projectId: "YOUR_PROJECT_ID" })] }
```

**Any other build:** upload after you build:

```bash
npx relia-sdk@latest sourcemaps upload ./dist --project-id YOUR_PROJECT_ID
```

Maps are uploaded after the build and then removed from the output, so your source code is never published. Uploading needs `RELIA_TOKEN` (an upload-only token written to `.env.local` by setup; run `npx relia-sdk@latest token` to make one). On a hosted build (Vercel, Netlify, Render, CI), add `RELIA_TOKEN` to the host's environment variables, or those builds skip the upload.

Source maps apply to errors from the build they were uploaded for, so the next error after you upload will be readable.

> **Tip:** watch [Browser errors show minified code? Upload source maps to fix it](https://youtu.be/ArLJuvippU8) (2 min).

## Fix it

Fix the line the stack points at. For errors like *Cannot read properties of undefined*, check where the value comes from: an API that sometimes returns less data, a field that was renamed, or data used before it has loaded.

On Growth and Pro, **Show how to fix** on the incident writes steps from the evidence, including the browser code location, and **Copy for your AI assistant** copies a brief for Claude Code, Cursor or another assistant.

## Check the fix worked

Ship the fix, then click **I fixed it** on the incident. Relia picks up new versions of your server by itself, but a change that only touches the browser code needs this click. Relia watches real visits. Once the error stays away for 30 minutes, the incident says **Fix confirmed** and you get *Your fix worked*. If people hit it again, you get *Still happening after your fix*.

## Next

- [Upload source maps](https://tryrelia.com/docs/source-maps.md)
- [Find where users get stuck](https://tryrelia.com/docs/users-stuck.md)
- [Identify your users](https://tryrelia.com/docs/identify-users.md): see which customers an error hit.

---
All Relia docs for AI assistants: https://tryrelia.com/llms.txt (index) · https://tryrelia.com/llms-full.txt (everything in one file)
