
Ship faster with confidence β A complete starter kit for integrating Rollbar error monitoring into your Next.js App Router application. Kickstart your error monitoring in minutes and ship with no worries.
π Public Demo: This app can be deployed as a public demo where users can configure their own Rollbar tokens via the UI (stored in localStorage). Perfect for live demos, workshops, or self-service trials!
This demo app shows how to:
Note: This app is designed to work as a public demo where users can configure their own Rollbar tokens without requiring environment variables or deployment configuration.
cd rollbar-vercelnpm install
Copy the example environment file:
cp .env.example .env.local
Edit .env.local and add your Rollbar client access token:
NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN=your_rollbar_client_token_hereNEXT_PUBLIC_ROLLBAR_ENV=development
To get your Rollbar client token:
post_client_item scopenpm run dev
Open http://localhost:3000 in your browser.
NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN - Your Rollbar client access tokenNEXT_PUBLIC_ROLLBAR_ENV - Set to production or your preferred environment namenpm install -g vercelvercel
Follow the prompts and set environment variables when asked.
By default, production builds in Next.js are minified and bundled, which results in unhelpful stack traces in Rollbar (showing webpack-internal paths). To get readable stack traces with actual file names and line numbers, you need to upload source maps to Rollbar.
This project is already configured with:
next.config.js - Enables production source mapsscripts/upload-sourcemaps.js - Uploads source maps to Rollbar after buildGo to Project Settings β Project Name -> Project Access Tokens
Find or create a token with post_server_item scope
Copy the token value
.env.local:ROLLBAR_SERVER_TOKEN=your_server_token_hereBASE_URL=https://your-app.vercel.app
npm run build:production
This will:
.map files to RollbarAdd these environment variables in Vercel Project Settings:
ROLLBAR_SERVER_TOKEN - Your server access tokenBASE_URL - Your Vercel deployment URL (e.g., https://your-app.vercel.app)SOURCE_VERSION - (Optional) Version tag for tracking (e.g., 1.0.0 or git commit SHA)Update your Vercel build command to:
npm run build:production
components/EventControls.js:57npm run build:productionnpm run dev) don't need source maps - they already have readable stack tracesROLLBAR_SERVER_TOKEN, the build will still succeed but skip source map uploadsThe demo provides four types of events you can send to Rollbar:
After sending events:
Event history is stored only in browser memory. This means:
This demo uses only Rollbar's browser SDK with a client access token. For production applications, consider:
rollbar-vercel/βββ app/β βββ globals.css # Global styles with Tailwindβ βββ layout.js # Root layout componentβ βββ page.js # Home page with demo controlsβββ components/β βββ EventControls.js # Main control panel with buttonsβ βββ EventSlideout.js # Event history slide outβ βββ Header.js # Simple header with logosβββ lib/β βββ rollbarClient.js # Rollbar SDK initializationβ βββ time.js # Timestamp and UUID utilitiesβββ public/β βββ logo.svg # Rollbar logoβββ .env.example # Environment variable templateβββ package.json # Dependencies and scriptsβββ postcss.config.js # PostCSS configurationβββ tailwind.config.js # Tailwind CSS configurationβββ vercel.json # Vercel deployment configβββ README.md # This file
npm run dev - Start development server on http://localhost:3000npm run build - Build production bundlenpm start - Start production servernpm run lint - Run ESLint (if configured)NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN is correctpost_client_item scopenpm install to ensure all dependencies are installed.next folder and node_modules, then reinstallThis is a demo project for educational purposes. Feel free to use and modify as needed.