Frontend observability ΒΆ

Nais provides frontend observability through the Grafana Faro Web SDK. Faro runs in the browser and instruments your app, shipping telemetry through the platform collector (Alloy) into the shared observability stores: errors and events land in Loki, browser spans in Tempo, and Core Web Vitals in Mimir. You then view and triage it all in Nais APM.

With 95+ applications already using Faro, it's the standard way to monitor frontend applications on Nais.

Recommended: instrument with `@nais/apm`

The recommended way to add Faro to a browser app is the @nais/apm SDK β€” a thin Faro wrapper with zero-config init(), mandatory PII scrubbing, a required namespace, and a fixed console instrumentation that keeps real stack traces. It's the instrument half of Nais APM: add @nais/apm, then view and triage the results on the APM Frontend and Issues tabs.

Start with Track frontend errors with @nais/apm. Reach for raw Faro (the guides below) only when you need the lower-level SDK directly β€” everything the platform recommends, including trace propagation (init({ tracing: true })), is available through @nais/apm.

What you get ΒΆ

  • Core Web Vitals β€” TTFB, FCP, CLS, LCP, INP (collected automatically)
  • Logging β€” console.info, console.warn, and console.error messages
  • Exceptions β€” stack traces with automatic sourcemap deobfuscation
  • Custom events and metrics β€” anything you want to track
  • Tracing β€” OpenTelemetry-based browser traces, optionally connected to backend spans

Get started ΒΆ

  1. Recommended β€” errors as issues in APM: 🎯 Track frontend errors with @nais/apm
  2. Next.js (App Router or Pages Router): Next.js quickstart with @nais/apm
  3. Need the lower-level SDK directly? Set up Faro Β· Next.js with raw Faro
  4. Want end-to-end traces? Connect frontend to backend
  5. Stack traces look minified? Sourcemaps Β· Troubleshooting

After the basic setup, check that you have these configured:

SettingWhy it mattersGuide
beforeSend PII filteringFaro captures URLs and console output that may contain fΓΈdselsnummer or tokensPrivacy and sensitive data
propagateTraceHeaderCorsUrlsWithout this, browser traces never connect to your backend spansTrace propagation
paused on localhostPrevents local development noise from polluting production dashboardsLocal development
app.versionLets you filter errors and metrics by deploySetting app.version
Error boundaryCatches React rendering errors that are otherwise silently lostReact error boundaries

Collector endpoints ΒΆ

The collector URL tells Faro where to send telemetry data. If you use the auto-configuration in nais.yaml, this is set for you.

Collector endpointEnvironment
https://telemetry.nav.no/collectprod
https://telemetry.ekstern.dev.nav.no/collectdev

On-premises clusters are not supported.

Inspecting frontend data in Grafana ΒΆ

Find your app in the Nais APM service inventory and open it. Browser telemetry surfaces on two tabs:

  • Frontend β€” Core Web Vitals, pageloads, sessions, per-page performance, browser breakdown, and web-vitals attribution (what's driving LCP, INP, and CLS).
  • Issues β€” browser exceptions grouped into issues, side by side with backend errors. Filter the source to Browser to isolate frontend errors, then open an issue for its stack trace and impact.

Nais APM Issues tab filtered to browser-sourced exceptions

For a full tour of the tabs, see Get started with Nais APM; for capturing errors from your own code, see Track frontend errors with @nais/apm.

For deeper analysis, use the Explore view with one of the Loki data sources. Here are some useful queries:

logql

Traces are available from data sources ending with -tempo. Use TraceQL to query them.

Local development ΒΆ

For local development, check out the tracing demo repository and run docker-compose up. This gives you a local Grafana, Loki, and Tempo stack to test against. See the README in that repository for details.

Guides ΒΆ

The recommended path is the @nais/apm SDK. Pick the quickstart for your framework:

Framework quickstartDescription
Next.js with @nais/apmApp Router and Pages Router: client init, error boundary, route tracking, tracing
React + Vite with @nais/apmReact SPA: entry-point init, error boundary, React Router tracking
Migrate from SentryMove an existing @sentry/* app onto @nais/apm

The raw-Faro guides below are the lower-level path β€” reach for them only when you need to work with the Faro SDK directly. Everything the platform recommends, including trace propagation, is available through @nais/apm (init({ tracing: true })).

GuideDescription
Set up FaroInstall, configure, and deploy Faro in any frontend app
Next.js App RouterFaro integration for Next.js with App Router
Custom metricsSend custom measurements and query them in Grafana
Trace propagationConnect frontend traces to backend spans
SourcemapsHow stack trace deobfuscation works
Auto-configurationGenerated config values and environment variables
TroubleshootingCSP, CORS, and common issues

Further reading ΒΆ