Source maps

See errors at src/checkout.ts:42 instead of index-3f9a2c.js:1:48213.

  1. Build
  2. Upload maps
  3. Delete them from the output
  4. Errors show your code

Set it up

Make an API key

In Organization settings → API keys, add a key with the Source maps preset. Add it to your CI or hosting build environment as DATABUDDY_API_KEY.

Add the plugin

vite.config.ts
import { databuddySourceMaps } from "@databuddy/sdk/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [databuddySourceMaps()],
});

Deploy

Builds with the key upload their maps and delete them, so they're never served. Builds without it, such as on your laptop, stay exactly as they were.

The website comes from the client ID your app already sets (NEXT_PUBLIC_DATABUDDY_CLIENT_ID, or VITE_DATABUDDY_CLIENT_ID including from .env). Set DATABUDDY_WEBSITE_ID if there's none.

ViteNext.jsCLI
VersionsVite 4+13+ with webpack, 15.4.1+ with TurbopackAny bundler
Turns maps onHidden maps, if build.sourcemap is unsetproductionBrowserSourceMapsYou do
Deletes them after uploadYes, even when the upload failsYes, even when the upload failsWith --delete
Already serving maps on purposeUploads and keeps themUploads and keeps themKeeps them without --delete

Needs @databuddy/sdk 3.10+ and Node.js 18+. Works in ES module and CommonJS configs.

Options

Plugin optionCLI flag
failOnError: trueExits 1 on any failureFail the build when an upload fails. By default it's logged and the build goes on.
stripSources: true--strip-sourcesUpload without your code. Frames still map to file, line and function.
websiteId--website-id <id>The website, when no client ID is set
--dry-runList what would upload, without a key
--concurrency <n>Parallel uploads, 8 by default

Unchanged maps aren't sent again, so uploading on every deploy is cheap. For your own scripts, uploadSourceMaps(dir) from @databuddy/sdk/sourcemaps is the same uploader.

Skip uploads if your website serves maps

When a file has no uploaded map, Databuddy reads the map its script points to (sourceMappingURL comment, SourceMap header or data: URL), only from your website's domain and subdomains. Uploading is still better: your code stays private, and old builds keep mapping after you deploy over them.

Who sees your code

Original file, line, functionLines of code
Members who can manage source mapsYesYes
Viewers and read-only API keysYesNo
Public dashboard visitorsNoNo

Maps are stored privately with Tigris, never served or published, and deleted with their website or organization.

Limits

One map25 MB, sent with Content-Length
Uploads2,000 an hour per website and per API key; 10 GB a day per organization. Over either: 429 with Retry-After.
File namesLetters, digits and . _ - ~ @ + [ ], ending in .js.map, .mjs.map or .cjs.map
Kept for30 days after upload, renewed weekly while the map keeps showing errors

How is this guide?