Skip to content

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#

WhereWhat 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#

Terminal
npm install @belvador/tanstack-start@0.6.1

Router#

src/instrument.ts
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,  });}
src/router.tsx
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#

src/server.ts
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-router and @tanstack/react-start 1.168 or newer, React 18 or 19.

  • Cloudflare Workers with the nodejs_compat flag. 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.

Try it on your own Hetzner project

Free during the beta. Hetzner bills the server; Belvador never bills per event.