# Browser errors show minified code

> Upload your build's source maps so browser errors in Relia point at your own file, line and function instead of a minified bundle.

Section: When something doesn't work · Page: https://tryrelia.com/docs/source-maps · Last checked against the product: 2026-11-01
Video walkthrough: https://youtu.be/ArLJuvippU8

A production build squeezes your code into files like `index-a8f3.js`. Without source maps, a browser error in Relia points there. With source maps, Relia shows the original file, line and function, with the code around it. Your maps are uploaded to Relia and removed from the build output, so your source code is never published.

## What you'll see

- In a session's **Console** tab, the stack points at a minified file. Under it Relia says: **Minified code (…). Upload source maps to see your file and line**.
- On the project's **Setup** tab, the row **Source maps (readable browser errors)** says **None uploaded yet. They upload on your next build.**
- In your host's build log, the build still succeeds, with one yellow line: `[relia] source maps were not uploaded: …`.

## Find the cause

`npx relia-sdk@latest init` already wires the upload when it sets up a web app:

- **Vite apps** get the `reliaSourcemaps` plugin in `vite.config`.
- **Other bundlers** get `&& relia sourcemaps upload <dist or build> --project-id <id> --build-step` added to the `build` script. With `--build-step` a failed upload never breaks your build, and the maps are still removed.
- It writes an upload token, `RELIA_TOKEN`, to `.env.local` and makes sure `.gitignore` covers `.env.local`. This token can only upload source maps for this one project.

The usual cause: your host (Vercel, Netlify, Render, CI) builds without your `.env.local`, so it has no token. The build log says `no Relia token`.

## Fix it

1. In your app's folder, open `.env.local` and copy the value of `RELIA_TOKEN`. Lost it? Write it again:

   ```bash
   npx relia-sdk@latest token
   ```

   It finds the project id in the folder (or pass `--project-id <id>`), asks you to sign in if needed, and writes `RELIA_TOKEN` to `.env.local`. A new token replaces your previous upload token for that project.
2. In your host's environment variables, add `RELIA_TOKEN` with that value.
3. Build and deploy again. The build log now reports the uploaded maps and that they were removed from the output.

> **Note:** Next.js is not wired by `init`. Turn on `productionBrowserSourceMaps` in `next.config`, and run the upload after `next build` (see below).

## Set it up by hand

**Vite**, in `vite.config.ts`:

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

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

The plugin turns on hidden source maps when your config doesn't set `build.sourcemap`, uploads after the build, then deletes the `.map` files. Options: `projectId`, `release`, `keepMaps` (keep the `.map` files in the output; default `false`), `failOnError` (fail the build when the upload fails; default `false`) and `disabled`. If your config sets `build.sourcemap: false`, there is nothing to upload: remove it or set it to `"hidden"`.

**Any build**, after the build step:

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

Uploading needs `RELIA_TOKEN` (from the environment, or from `.env.local` / `.env` in the folder) or the login saved by `npx relia-sdk@latest init`. Maps are matched by the bundle's file name, so no release setup is needed. All flags are in the [CLI reference](https://tryrelia.com/docs/cli.md#sourcemaps-upload).

## Check the fix worked

- The **Setup** tab row says **Browser errors point at your own files.**
- The next browser error in a session's **Console** tab shows your file and line (for example `src/main.ts:4 in handlePay`) with the line highlighted. A toggle still shows the minified stack.

Errors that happened before the upload stay minified; new ones are readable.

> **Tip:** watch [Fix JavaScript errors in production with readable stack traces](https://youtu.be/DrD9OWbQ_nQ) (2 min).

## If something's wrong

- **`no project id`**: pass `--project-id <id>` or set `RELIA_PROJECT_ID`.
- **`no .map files in ./dist`**: your build does not write source maps. Turn them on in your bundler, or check the folder name (`dist`, `build`…).
- **401 or "token expired"**: run `npx relia-sdk@latest token` again and update `RELIA_TOKEN` on your host.

## Next

- [Monitor a web app](https://tryrelia.com/docs/web-app-setup.md)
- [Fix JavaScript errors](https://tryrelia.com/docs/javascript-errors.md)
- [CLI reference](https://tryrelia.com/docs/cli.md)
- [Environment variables](https://tryrelia.com/docs/environment-variables.md)

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