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 / Backend / Server / Express Backend

Express Backend

Highlight ships @highlight-run/node which can be installed alongside highlight.run for capturing backend errors in applications with Express backends.

Usage

The usage of this Backend SDK requires one of our Client SDKs to be installed, so please follow the instructions there if you have not done so.

The @highlight-run/node Package

First, import the package

yarn add @highlight-run/node
Copy
Adding Highlight to Express

Pass configurations into the errorHandler and Highlight is ready to go!

Where you place the app.use(highlightErrorHandler) definition is important. It must be set after route handler definitions (app.get(...), etc) and before other error middleware.

import * as Highlight from '@highlight-run/node' // or like this with commonjs // const Highlight = require('@highlight-run/node') const app = express() // define any configurations needed // <https://docs.highlight.run/api/hinit#w0-highlightoptions> const highlightOptions = {} // initialize the handler const highlightErrorHandler = Highlight.Handlers.errorHandler(highlightOptions) app.get('/', (req, res) => { if (Math.random() < 0.1) { throw new Error(`random error ${Math.random()}`) } res.send(`Hello World! ${Math.random()}`) }) // This should be before any other error middleware and after all controllers (route definitions) app.use(highlightErrorHandler) app.listen(port, () => { console.log(`Example app listening on port ${port}`) })
Copy
Verify

To validate your Highlight backend setup, you'll need to setup up a testing route handler that throws an error. See the block above for an example. Add some code to your frontend to make an HTTP request to /error. You should be able to view your frontend session making the request and find the error traceback in the errors page.

To view and resolve the recorded error, log into app.highlight.io 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.