@observerkit/next
v0.3.0
Published
Next.js plugin for ObserverKit — injects debug IDs and uploads source maps
Downloads
547
Readme
@observerkit/next
Next.js plugin for ObserverKit — injects debug IDs into your build output and uploads source maps after next build. Works with both Turbopack (Next.js 16+ default) and webpack mode.
Requirements
- Next.js
>=15.4.1(usescompiler.runAfterProductionCompile) - Turbopack debug-IDs require Next.js
>=16.0.0
Install
pnpm add -D @observerkit/nextSetup
Wrap your next.config.ts (or next.config.js) with withObserverkit:
// next.config.ts
import withObserverkit from "@observerkit/next"
import type { NextConfig } from "next"
const nextConfig: NextConfig = {
// your existing Next.js config
}
export default withObserverkit(nextConfig, {
projectKey: process.env["OBSERVERKIT_PROJECT_KEY"] ?? "",
})What it does
- Enables
productionBrowserSourceMaps: true - Enables
experimental.serverSourceMaps: trueso webpack-mode server bundles emit maps too (Turbopack emits them natively) - Enables
turbopack.debugIds: true(Next.js 16+) so Turbopack emits standards-compliant debug IDs - In webpack mode, injects equivalent debug-ID registration into JS chunks
- After
next build, scans.next/recursively for.mapfiles and uploads the ones carrying adebugIdto ObserverKit viacompiler.runAfterProductionCompile - By default, deletes all
.mapfiles from the build output afterwards — even when the upload fails or is skipped — and blankssourceMappingURL=references in emitted chunks (webpack and Turbopack output), so source maps never ship and devtools never 404
Options
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| projectKey | string | required | ObserverKit project key |
| endpoint | string | https://ingest.observerkit.com | Ingest API base URL |
| deleteAfterUpload | boolean | true | Delete every .map file from .next/ after the upload attempt (even on failure, so maps never ship) and blank sourceMappingURL references in chunks |
Notes
- The hook never throws. Upload failures are logged to
console.errorso they don't break the build. - If you self-host your Next.js production server and rely on Node's
--enable-source-mapsfor runtime stack traces, setdeleteAfterUpload: falseso server-side.mapfiles stay on disk. - When the user has already set
productionBrowserSourceMapsorturbopack.debugIds, the plugin respects the user value. - Both client (
.next/static/) and server (.next/server/) sourcemaps are uploaded. - When
projectKeyis empty (e.g.OBSERVERKIT_PROJECT_KEYunset in dev or CI), the plugin logs a warning and leaves your config untouched. It never breaksnext devor a keyless build.
