6min

Next.js Backend

Highlight ships @highlight-run/next which can be installed alongside highlight.run and @highlight-run/react for capturing backend errors and stack traces in Next.js applications.

Usage

Under the hood this SDK relies on our Node SDK, which makes all features available there also available here. The usage of this backend SDK requires our Next.js client SDK to be installed, so please follow the instructions Next.js if you have not done so.

The @highlight-run/next Package

First, import the package

Shell
|

Configure

Define the Highlight backend package with intended options in a common function file

TypeScript
|

Adding withHighlight as a middleware

Wrap each of your route handlers in the NextJS /api/ directory with the withHighlight function we defined in the configuration step.

TypeScript
|

Verify

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

ÔĽŅ

Updated 01 Apr 2022
Did this page help?
Yes
No