Star us on GitHub
Star
Company
Open Source
Mission & Values
Getting Started
Overview
Fullstack Mapping
Backend / Server
Frontend / Client
Fullstack Frameworks
Session Replay
Console Messages
HTML iframe Recording
Identifying Users
Live Mode
Network DevTools
Privacy
Rage Clicks
Recording Network Requests and Responses
Session Sharing
Session Shortcut
Tracking Events
Versioning Sessions
Error Monitoring
Error Sharing
Grouping Errors
Sourcemaps
Versioning Errors
Product Features
Alerts
Analytics
Canvas
Comments
Cross Origin Iframe Recording
Digests
Environments
Frontend Observability
Keyboard Shortcuts
Performance Data
Segments
Session Search
Team Management
User Feedback
Web Vitals
WebGL
Integrations
Amplitude Integration
Clearbit Integration
ClickUp Integration
Discord Integration
Electron Support
Front Plugin
Height Integration
Intercom Integration
Linear Integration
Mixpanel Integration
React.js Integration
Segment Integration
Sentry Integration
Slack Integration
Vercel Integration
highlight.run Changelog
5.0.0
5.0.1
5.1.0
5.1.1
5.1.2
5.1.3
5.1.4
5.1.5
5.1.6
5.1.7
5.1.8
5.2.0
5.2.1
5.2.2
5.2.3
Tips
Content-Security-Policy
Local Development
Monkey Patches
Performance Impact
Proxying Highlight
Session Search Deep Linking
Troubleshooting
Upgrading Highlight
Menu
Docs / Welcome to Highlight / Getting Started / Fullstack Frameworks / Next.JS / Next.js Overview

Next.js Overview

The Highlight Next.js SDK adds additional features to Highlight, including:

Getting Started

The features in this SDK require the Highlight client SDK to be installed, so please follow the Next.js instructions if you have not yet done so.

For server-side linking to Highlight sessions, your call to H.init should include the tracingOrigins setting. If you're going to use withHighlightConfig and proxy your Highlight requests with a rewrite, you should set backendUrl. See H.init() for more details.

H.init('<YOUR_PROJECT_ID>', { ... tracingOrigins: true, backendUrl: '/highlight-events', ... });
Copy
SDK Setup

Import the @highlight-run/next Package

# with npm npm install @highlight-run/next # with yarn yarn add @highlight-run/next
Copy
Wrapping your next.config.js

In order for Highlight to be aware of your project during build time, you need the HIGHLIGHT_SOURCEMAP_UPLOAD_API_KEY variable in your build environment. Refer to our environment variables doc to get this set up in your cloud provider of choice.

If you want to configure source map uploads during your production builds and enable the Next.js Highlight proxy rewrite, you can wrap your Next.js config with withHighlightConfig. See withHighlightConfig() for more details.

import { withHighlightConfig } from '@highlight-run/next' export default withHighlightConfig({ // your next.config.js options here })
Copy
Next.js Custom Metrics

If you want to monitor backend errors, this API wrapper will send your errors to Highlight and link them to the session where the network request was made. Define a withHighlight wrapper with any common options in a common function file. For example, you can create a highlight.config.ts file in the root of your next.js codebase. See Highlight() for more details.

import { Highlight } from '@highlight-run/next' export const withHighlight = Highlight()
Copy

You can then wrap each of your handlers in the Next.js api/ directory with the withHighlight function from the previous step.

import { withHighlight } from '../highlight.config' const handler = async (req, res) => { res.status(200).json({ name: 'Jay' }) } export default withHighlight(handler)
Copy
Wrapping your API routes

Refer to the next.js metrics docs in order to report custom metrics from your Next.js application.