Next.js
Applies toAlpha
Next.js has its own build pipeline with no place for a Vite plugin. Have Next emit browser Source
Maps, then run openrum sourcemaps upload after next build. Before you start, create an upload
token and store it as the CI secret
OPENRUM_UPLOAD_TOKEN.
-
Install the command line
Section titled “Install the command line”openrumships in the@openrum/clipackage. Add it to your application as a dev dependency:Terminal window pnpm add -D @openrum/cliRun
pnpm exec openrum sourcemaps upload --helpto confirm the command is available. The package has no Vite dependency. -
Emit Source Maps and upload after the build
Section titled “Emit Source Maps and upload after the build”next.config.ts import type { NextConfig } from "next";const config: NextConfig = {productionBrowserSourceMaps: true,};export default config;package.json {"scripts": {"build": "next build && openrum sourcemaps upload --out-dir .next/static --url-prefix _next/static/"}}The CLI reads
OPENRUM_BASE_URL,OPENRUM_PROJECT_ID,OPENRUM_RELEASEandOPENRUM_UPLOAD_TOKENfrom the environment; see Plugin and CLI options for the full list.--out-dir .next/static: Next writes browser chunks and their.mapfiles here. Server code lives in.next/serverand is not uploaded.--url-prefix _next/static/: browsers request scripts at/_next/static/chunks/…, but paths below.next/staticdo not include_next/static/. Without the prefix, Artifact names do not match stack frame URLs.
With
basePath: "/app", scripts are served from/app/_next/static/…, so useapp/_next/static/. With anassetPrefixCDN URL, take that URL’s path and append_next/static/. -
Make the SDK report the same Release
Section titled “Make the SDK report the same Release”Set the CLI’s
releaseand the SDK’sreleasefrom one CI variable:app/monitoring.tsx "use client";import { init } from "@openrum/browser";import { useEffect } from "react";export function Monitoring() {useEffect(() => {init({dsn: process.env.NEXT_PUBLIC_OPENRUM_DSN!,release: process.env.NEXT_PUBLIC_APP_RELEASE, // same as OPENRUM_RELEASE});}, []);return null;}NEXT_PUBLIC_variables are inlined into the browser bundle duringnext build, so set it in the build step.init()must run in the browser; see Next.js SDK for the full setup..github/workflows/deploy.yml - name: Build and upload Source Mapsrun: pnpm buildenv:OPENRUM_BASE_URL: https://rum.example.comOPENRUM_PROJECT_ID: <your-project-id>OPENRUM_RELEASE: ${{ github.sha }}NEXT_PUBLIC_APP_RELEASE: ${{ github.sha }}OPENRUM_UPLOAD_TOKEN: ${{ secrets.OPENRUM_UPLOAD_TOKEN }} -
Verify mapping
Section titled “Verify mapping”After deploying, follow Verify mapping: confirm the Artifacts are ready on Source Map, check a real frame with the match tester, then trigger a known error. If a frame is not mapped, first compare the frame URL’s path with the Artifact names; see Why a frame is not mapped.
Release Alpha · commit local