Pages in the browser
Record what users do on the pages of a Next.js app or a single-page app on Vite, each view and action with the API calls it made.
Tracepanel records your pages in the browser: each view and what users do
on it, with the API calls each made. In a Next.js app, the badge in the root
layout does it. A single-page app on Vite gets it from the Vite plugin, with
the badge and the panel. An Angular app gets it from provideTracepanel().
See Angular.
Next.js
Set up Next.js as in Installation. The
<Tracepanel /> badge in the root layout records the pages too. Its options
are the plugin's browser options:
// app/layout.tsx
<Tracepanel browser={{ service: "shop-web", propagateTo: ["http://127.0.0.1:8000"] }} />browser={false} leaves the recording out and keeps the badge. Next.js's own
client logs, such as hot reload, stay out of the pages' traces.
A page the server rendered is one load in the panel's list: the view of its
load, such as VIEW /docs, with the page's own request, GET /docs, and its
calls under it.
The recording is a script in the page's <head>. It runs before your app's
scripts, so it sees every fetch() they make, even from a client that keeps
fetch from when it is made, as openapi-fetch does. A script you load
before it should look fetch up on each call.
The app's server sends the traces on to the console at /__tracepanel__/.
It starts the agent when none runs, and a new one when the agent went away.
Add the Vite plugin
Install @tracepanel/js in the frontend and add the plugin:
// vite.config.ts
import { tracepanel } from "@tracepanel/js/vite";
export default { plugins: [tracepanel({ dir: "../backend" })] };dir is the backend project's directory, where its .tracepanel/ is. The
plugin puts the panel's script into index.html. It serves the backend's
console on Vite's own origin, at /__tracepanel__/, so the panel and the
console work on the page. When the console doesn't answer, the plugin says
why on that address. See The agent.
The plugin names the page's framework from the project's package.json:
Angular, Preact, Solid, Svelte, Vue or React, with its installed version,
such as React 19.2.0. The badge and the console say it served the page,
not the API its calls reach. A page with none of them is named Browser.
The backend can be any app Tracepanel traces, in Node.js or in Python. A backend that serves its own console, such as Django or FastAPI, is named by its console instead:
tracepanel({ console: "http://localhost:8000/__tracepanel__/" });When the page loads before the API's first request, the plugin starts the backend's agent itself.
Call an API on another origin
The page's calls to the API go to another origin, such as
http://127.0.0.1:8000. The panel reads each call's trace from its response
headers, and the SDKs expose those headers on CORS responses, so the panel
lists every call the app makes.
Read what users do
Each view of a page is a trace: its load, or a route change in the app. So is each action on it:
- a click or a submit that called the API, named after its control, such as
click "Save" - calls the page made in the background, which no one started
A view or an action keeps its calls, its errors and its console output, with the line that logged each record. It lasts until its last call answered.
A GraphQL call keeps the document it sent beside its operation, its whitespace collapsed and cut at 2,000 characters. The call's row in the panel shows the query however the server that answered records its trace, such as an Apollo Router that records no document by default.

The console lists them in Pages, each view first and its actions under it. The panel lists each view and action as a row, with the requests it made under it. See The console and The panel.
A call to the page's own origin carries a W3C traceparent, so the console
links it to the API's trace. To link calls to another origin too, name it in
propagateTo. That origin's CORS must allow the traceparent header, and,
while the panel's Profile is on, the X-Tracepanel-Profile header the calls
carry then. Express's cors() allows both as it is, and so does
CORSMiddleware with allow_headers=["*"] in a FastAPI or Starlette backend.
A CORS setup that lists its headers needs both in the list.
A call the page makes while the panel's Profile is on is profiled by the
panel's cookie, which goes along to the page's origin, and its Profile tab
says Profiled: by the panel's cookie. The header with a traceparent and
no cookie of the panel's stays another app's ask, by its caller.
tracepanel({
dir: "../backend",
browser: { service: "shop-web", propagateTo: ["http://127.0.0.1:8000"] },
});service names the pages' app in the console. browser: false leaves the
recording out and keeps the panel. Vite's own client logs, such as its
connection and hot reload, stay out of the pages' traces.
Record without Vite
Without Vite, call record() in the page:
import { record } from "@tracepanel/js/browser";
record({ service: "shop-web" });It sends the traces to the console on the page's origin, at
/__tracepanel__/. api names another path. ignoreSources takes parts of
the paths of scripts whose console output isn't the page's, such as a dev
server's client.
Call it before the app makes its first call. A client that keeps fetch
from when it is made, as openapi-fetch does, keeps the one from before the
recording. Make such a client after record(), or pass it a fetch that
looks up window.fetch on each call.
Keep the console local
The console takes the pages' traces from this machine only. Through the Vite
plugin or a Next.js app's server, it answers this machine only, even with
the dev server on the network (vite --host, next dev -H 0.0.0.0). Its
traces, and what it lets a local caller do, such as switching the user, are
for you alone.