Framework guide
Error tracking for TanStack Start, in the browser and on the server
@belvador/tanstack-start reports errors from both halves of a TanStack Start app — the router in the browser, and the server entry and middleware running on Cloudflare Workers. Apps built with Lovable are TanStack Start apps, so this is their setup too.
The short answer#
One package,
@belvador/tanstack-start, wired in the router, the server entry and the middleware.It reports browser errors, route error boundaries, and server function and server route failures on Workers.
It works for apps built with Lovable, which are TanStack Start apps on Cloudflare Workers.
Redirects,
notFound(), status codes below 500 and cancelled requests are not reported.
Three places, one package#
| Where | What only it can see |
|---|---|
Router (src/router.tsx) | Errors that route error boundaries catch, plus uncaught browser errors |
Server entry (src/server.ts) | Errors that escape a request on Workers |
Middleware (src/start.ts) | Server function and server route failures, with the request's context |
Each part reports what the others miss, so the guide wires all three (TanStack Start guide).
Install#
npm install @belvador/tanstack-start@0.6.1Router#
import { init } from "@belvador/tanstack-start/client";// Imported first by src/start.ts and src/router.tsx. Runs only in the browser.if (typeof window !== "undefined") { init({ dsn: "https://<public-key>@ingest.belvador.dev/<project-id>", release: import.meta.env.VITE_APP_VERSION, // your build or commit id environment: import.meta.env.MODE, });}import "./instrument"; // first line, before the route treeimport { withBelvadorRouter } from "@belvador/tanstack-start/client";// In getRouter(): wrap the options you already pass to createRouter.// createRouter(withBelvadorRouter({ routeTree, ...yourOptions }))// It reports route errors, calls your own defaultOnCatch after that, and adds// TanStack's error component only if you set no defaultErrorComponent.Server entry#
import handler from "@tanstack/react-start/server-entry";import { withBelvador } from "@belvador/tanstack-start/server";// Requires Cloudflare Workers with nodejs_compat enabled.// If src/server.ts already exists, wrap its default export instead of `handler`.// vite.config.ts needs tanstackStart: { server: { entry: "server" } } (Lovable apps have it).export default withBelvador( (env: { BELVADOR_DSN?: string; BELVADOR_RELEASE?: string }) => ({ dsn: env.BELVADOR_DSN ?? "https://<public-key>@ingest.belvador.dev/<project-id>", release: env.BELVADOR_RELEASE, }), handler,);The middleware step and the Content Security Policy line are in the guide. Keep what your app already does: add to an existing src/server.ts or src/start.ts, do not replace them.
Requirements#
@tanstack/react-routerand@tanstack/react-start1.168 or newer, React 18 or 19.Cloudflare Workers with the
nodejs_compatflag. Lovable apps already have it.
More than errors#
Cron jobs in the same app can report check-ins with
withMonitor()(cron monitoring).Traces and logs go through the standard OpenTelemetry exporter (OpenTelemetry for TanStack Start).
An AI agent prompt in the guide sets the package up in Lovable or another coding agent.
Limits#
Redirects,
notFound(), errors with a status below 500 (499 included) and requests the visitor cancelled are not reported — they are not bugs.An error thrown in a route loader while the page renders on the server is usually reported from the browser, without the server stack. Server functions called from loaders keep their server stack.
No replay and no browser tracing.
Server code that runs outside Belvador's middleware is reported as a connection problem on the project, so you can find it (connection problems).
Questions#
Does this work on Node.js hosting instead of Workers?#
The server half is built and tested for Cloudflare Workers. On another runtime, use the browser part and the Node.js setup for the server.
Posts on this topic
All posts- A prompt to add error tracking to a Lovable app, and how to check itThe prompt to add error tracking to a Lovable app: which files, in which order, what to keep, and how to prove it works. Old order 0 of 12, fixed 12 of 12.
- Monitoring vibe-coded apps: what breaks after you publishWhat breaks in a vibe-coded app after you publish, why uptime checks still see 200 OK, and the three checks that catch it. Tested on five real failures.
- TanStack Start loader errors: why the SSR stack points at your HTML pageWhy a TanStack Start loader error thrown during SSR shows a stack from your HTML page, how reporting from the server can double it, and how to get it once.
- Lovable app shows a blank page: find the cause in the consoleLovable app blank or frozen after publishing? Read the first console error to tell five causes apart, fix each one, and give Lovable the evidence it needs.
Try it on your own Hetzner project
Free during the beta. Hetzner bills the server; Belvador never bills per event.