Skip to main content

Introduction

@lerix-dev/lerix-nestjs is the server-side Lerix SDK for NestJS. Once the module is registered, every unhandled exception in your API is reported to the dashboard with its stack trace, host, release and request context, and your services get a typed client for the push notifications REST API.
Create a project with the NestJS framework in the dashboard and copy its API key and project id from Project Settings.

Requirements

The package has no runtime dependencies and works with both the Express and Fastify adapters.

1. Install the package

2. Register the module

Import LerixModule once in your root module:
app.module.ts
Enable shutdown hooks so in-flight reports are flushed when the process is stopped:
main.ts
That is the whole setup. The module registers a global exception filter and process-level handlers, so unhandled errors are reported from now on. See Error Tracking for what gets captured and how to report errors yourself.

Load options from ConfigService

forRootAsync accepts the same options plus imports and inject:
app.module.ts

3. Verify the integration

Add a route that throws and call it once:
app.controller.ts
The client receives Nest’s normal 500 response and the error appears in your dashboard within seconds. Remove the route afterwards.

Options

How your service appears in the dashboard

The SDK registers your service as a server app. The app id defaults to the name in package.json and the release to its version, so reports are grouped per service and per release. Override them with the app option when you deploy several instances of the same code base or want a git SHA as the build number:
An anonymous user is registered on first boot and stored in .lerix/state.json under the working directory, so restarts reuse it. Add that folder to .gitignore, or mount it in containers. Pass statePath: false to skip persistence, or userId to control the id yourself.

Next steps

Error Tracking

What the filter reports, how to change the policy, and manual reporting.

Push Notifications

Send, schedule, update and unsend notifications from your backend.