r/nestjs • • 13h ago

NestJS Observe now traces from the browser to your Nest API (announcing frontend support)

Post image
6 Upvotes

Frontend monitoring for NestJS Observe is live as of this week.

Short video: https://www.youtube.com/watch?v=11F9SMf9Zzo

The main thing: a page view and the Nest requests it caused are now one trace. When a page is slow or breaks, you open the trace and see the page's load, the fetch it made, and under that the Nest side: controller, service methods, queries and logs. No matching timestamps across two tools.

What it records from the browser:

- Page views with Web Vitals (LCP, INP, CLS, FCP, TTFB), and what caused each one: the element, the image, the script
- JavaScript errors with source maps, plus the clicks, calls and console lines that led up to them- - fetch calls, and custom spans if you want to time your own code

A few things that fall out of having both sides in one trace:

- For a slow page, which Nest method or query its largest paint was waiting on
- Which buttons cost your backend the most server time
- On an endpoint's page, which frontend routes call it, before you change it

There are adapters for Angular, React, React Router, TanStack Router, Next.js and Vue. On the Nest side you need `@nestjs/observe` 0.3.30 or later and nothing else. It also works beside OpenTelemetry if you already run that in the browser.

Pricing, since someone will ask: it's on every plan including Free. A page view counts as 5 events, an error as 1, and the fetch calls inside a page view are free. Busy frontend can't eat your backend's allowance, so be careful, and if you don't need to track everything - set up "Browser sampling" in the dashboard (or SDK https://github.com/nestjs/observe-browser search for sampleRate)

Docs: https://observe.nestjs.com/documentation/frontend