Welcome to Highlight
Getting Started
Overview
Backend / Server
Client / Frontend
Fullstack Frameworks
Tips
Content-Security-Policy
Local Development
Monkey Patches
Performance Impact
Proxying Highlight
Session Search Deep Linking
Troubleshooting
Upgrading Highlight
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
Grouping Errors
Sourcemaps
Versioning Errors
Product Features
Alerts
Analytics
Canvas
Comments
Environments
Frontend Observability
Keyboard Shortcuts
Performance Data
Segments
Session Search
Team Management
User Feedback
Web Vitals
WebGL
Integrations
Amplitude Integration
Clearbit Integration
Electron Integration
Front Plugin
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
Menu
Docs / Getting Started / Fullstack Frameworks / Highlight()

Highlight()

Highlight = (options?: NodeOptions) => <T>(origHandler: NextApiHandler<T>) => NextApiHandler<T>
Copy
Purpose

Highlight() generates a function that you can use to wrap your API handlers to provide backend error monitoring. If an error is thrown during the handler's execution, it is sent to Highlight and linked to the frontend session which caused the error.

Example Usage

Typically, you would configure any necessary settings, and then export a common wrapper you can use to wrap all of your API handlers.

import { Highlight } from '@highlight-run/next' export const withHighlight = Highlight()
Copy
import { withHighlight } from '../highlight.config' const handler = async (req, res) => { res.status(200).json({ name: 'Jay' }) } export default withHighlight(handler)
Copy
Options

disableErrorSourceContext : optional boolean, default false

  • Disables source code context lines for error reporting. This may be useful for performance if your source files are particularly large or memory is limited.

errorSourceContextCacheSizeMB : optional number, default 10

  • Source files are cached in memory to speed up error reporting and avoid costly disk access. The default cache size is 10MB, but this can be overridden. Specifying a value <= 0 removes all cache size limits.