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 / Backend / Server / Node.js Backend

Node.js Backend

Highlight ships @highlight-run/node which can be installed alongside highlight.run for capturing backend errors and reporting metrics in applications with Node.js backends. This SDK is compatible with many other backend frameworks built on top of Node.js.

Getting Started

This backend SDK requires one of our Client SDKs to be installed, so please follow the instructions there if you have not done so.

For server-side linking to Highlight sessions, your client-side call to H.init should include the tracingOrigins setting. See H.init() for more details.

H.init('<YOUR_PROJECT_ID>', { ... tracingOrigins: true, ... });
Copy
Adding Highlight to your Backend

First, import the package

# with npm npm install @highlight-run/node # with yarn yarn add @highlight-run/node
Copy
Initialize the Highlight backend

Somewhere in your app, typically during startup or when handling errors, initialize the Highlight backend with any necessary options. See H.init() for a full list of options.

import { H } from '@highlight-run/node' const highlightOptions = {} if (!H.isInitialized()) { H.init(highlightOptions) }
Copy
Handle errors

When your app throws a backend error, you can log that error to Highlight by calling H.consumeError() using the secureSessionId and requestId parameters from the request's header. Your error handling code will depend on the backend framework you use, but will likely look something like this:

import { H } from '@highlight-run/node' const onError = (request, error) => { const parsed = H.parseHeaders(request.headers) if (parsed !== undefined) { H.consumeError(error, parsed.secureSessionId, parsed.requestId) } }
Copy
Verify

To view and resolve the recorded error, log into app.highlight.run/errors and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved. You can also view frontend sessions where the error was thrown, and see the individual request which caused the error.