Leave Localhost logoLeave LocalhostDocs
Observability

Sentry

Leave Localhost is pre-configured with Sentry for error tracking in the Next.js frontend (apps/app).

Leave Localhost is pre-configured with Sentry for error tracking in the Next.js frontend (apps/app).

Setup

  1. Create a Sentry account and project.
  2. Add your DSN to the environment variables:
NEXT_PUBLIC_SENTRY_DSN=https://...@...sentry.io/...
  1. For sourcemap uploading during Vercel builds, provide the Auth Token:
SENTRY_AUTH_TOKEN=...
SENTRY_ORG=...
SENTRY_PROJECT=...

Configuration Files

Sentry configuration lives in three files in apps/app:

  • sentry.client.config.ts — Browser configuration.
  • sentry.server.config.ts — Node.js runtime configuration.
  • sentry.edge.config.ts — Edge runtime configuration.

The Next.js instrumentation.ts and instrumentation-client.ts hooks load these configurations automatically when NODE_ENV === "production".

Development vs Production

Sentry initialization is wrapped in a check:

if (
  process.env.NODE_ENV === "production" &&
  process.env.NEXT_PUBLIC_SENTRY_DSN
) {
  Sentry.init({ ... });
}

This prevents local development errors and test runner failures from polluting your Sentry dashboard.

Catching Errors

Sentry automatically catches:

  • Unhandled React rendering errors
  • Unhandled Promise rejections
  • Next.js Route Handler exceptions

If you need to manually capture an error in a catch block:

import * as Sentry from "@sentry/nextjs";

try {
  await doSomethingRisky();
} catch (error) {
  Sentry.captureException(error);
  // handle gracefully
}

On this page