Requirements
- Next.js 13+ (App Router or Pages Router)
- React 18+
This is a dedicated Next.js library — a
LerixNextProvider pre-marked
'use client', plus the same LerixErrorBoundary and
useLerix()/useLerixNotifications() hooks the React SDK
uses, built on @lerix-dev/lerix-core. If you’re using plain React (not Next.js),
use @lerix-dev/lerix-react directly instead.1. Add the dependency
2. Configure your API key and project ID
Add to.env.local:
.env.local
NEXT_PUBLIC_ — that’s Next.js’s own convention for
env vars exposed to client-side code, required here since the SDK
registers/reports from the browser.
Find your API key and project ID in the Lerix Dashboard under Project Settings.
3. Register the SDK
Wrap your root layout inLerixNextProvider and LerixErrorBoundary:
app/layout.tsx
pages/_app.tsx instead.
layout.tsx itself stays a Server Component — LerixNextProvider and
LerixErrorBoundary are pre-marked 'use client' internally, so wrapping
them around children doesn’t force your whole tree to become client-only.
LerixNextProvider reads NEXT_PUBLIC_LERIX_API_KEY/NEXT_PUBLIC_LERIX_PROJECT_ID
automatically — pass an options prop explicitly only if you want to
override them:
Parameters
4. Verify the integration
You’re all set! Continue to Error Tracking to report custom errors and enable automatic capture, or Push Notifications to enable push delivery.