Quickstart
Connect your app in about ten minutes, whatever its backend is written in: create a project, choose your stack, and paste its setup.
1. Create a project
Sign up, open Projects and create one project per app. Give it:
- Allowed origins: the addresses your app runs on, one per line, for example
http://localhost:3000and your production URL. Only browsers on these sites can send spans with the public key. - GitHub repository (optional): lets the dashboard link a failing span to the exact line of code.
You then see two keys. The public key (pk_…) goes in browser code. The secret key (sk_…) is shown once: copy it now, it is stored only as a hash.
2. Connect your stack
Choose what your backend is written in. Next.js apps use the DevLens SDKs, which record the browser, the server and Prisma queries. Every other backend uses OpenTelemetry, the industry standard, and for most languages that needs no code changes (see Connect a backend). The same picker appears in your project with its keys filled in.
Uses the DevLens SDKs. The DevLens SDKs record the browser too, with file:line from your TypeScript source.
Copies these steps as a prompt for Claude Code, Cursor or any coding agent. Your secret key isn't included.
1. Install
Install (Next.js)npm install @devlenshq/sdk-browser @devlenshq/sdk-node
2. Set the environment
Environment (Next.js)NEXT_PUBLIC_DEVLENS_ENDPOINT="https://devlenshq.dev/api/ingest" NEXT_PUBLIC_DEVLENS_KEY="pk_…" DEVLENS_SECRET_KEY="<the sk_ key you copied when you created the project>"
3. Add the setup code
Starts the browser SDK. Render <DevLensInit /> once in your root layout.
app/devlens-init.tsx"use client"; import { useEffect } from "react"; import { init } from "@devlenshq/sdk-browser"; export function DevLensInit() { useEffect(() => { init({ endpoint: process.env.NEXT_PUBLIC_DEVLENS_ENDPOINT!, publicKey: process.env.NEXT_PUBLIC_DEVLENS_KEY!, }); }, []); return null; }Wrap the action with track, and use the fetch it hands you.
Any component where a user action calls your APIimport { track } from "@devlenshq/sdk-browser"; const res = await track("Submit registration", (fetch) => fetch("/api/register", { method: "POST", body }));Starts the server SDK. Import it first in every API route.
lib/devlens.tsimport path from "node:path"; import { configure } from "@devlenshq/sdk-node"; const endpoint = process.env.NEXT_PUBLIC_DEVLENS_ENDPOINT; const secretKey = process.env.DEVLENS_SECRET_KEY; // server only, never NEXT_PUBLIC_ // Telemetry must never break your app: without keys, record nothing and carry on. if (endpoint && secretKey) { configure({ endpoint, secretKey, repoRoot: path.resolve(process.cwd()) }); // repo-relative source paths }Records every Prisma query (model and operation only, never its arguments).
lib/db.tsimport { instrumentPrisma } from "@devlenshq/sdk-node"; export const prisma = instrumentPrisma(new PrismaClient({ adapter }));Records the request and continues the browser's trace. Routes must use the Node.js runtime.
app/api/…/route.ts (each route)import "@/lib/devlens"; import { withDevLens } from "@devlenshq/sdk-node"; export const runtime = "nodejs"; export const POST = withDevLens("POST /api/register", async (req) => { /* your handler */ });
Keep the secret key on the server: never in browser code, and in Next.js never in a variable starting with NEXT_PUBLIC_, which Next.js ships to the browser.
3. Record your first trace
Run your app and use it. Open the project in DevLens: the trace list updates by itself, and new traces appear within a few seconds. Make something fail (submit a form twice, for example) to see a failing trace with its root cause.
Next.js: going further
To see a service function as its own step in the graph, wrap the call with span:
import { span } from "@devlenshq/sdk-node";
// Inside a route wrapped with withDevLens:
await span("RegistrationService.registerUser", () => registerUser(input));For file:line locations in your TypeScript files rather than compiled output, start Node with NODE_OPTIONS=--enable-source-maps, in development and in production. Instrumented routes must use the Node.js runtime, not Edge.
Links to the exact line on GitHub
If you gave the project a GitHub repository, also pass configure the commit your server is running, as a full 40-character SHA. Hosts usually provide it, for example RENDER_GIT_COMMIT on Render or VERCEL_GIT_COMMIT_SHA on Vercel:
configure({
endpoint,
secretKey,
repoRoot: path.resolve(process.cwd()),
commitSha: process.env.RENDER_GIT_COMMIT, // or VERCEL_GIT_COMMIT_SHA, or your CI's commit
});Links are only built for spans your server sent with the secret key, never for browser spans. With OpenTelemetry, set devlens.commit_sha instead (see Other languages).
Naming things
In any language, use fixed names for actions, routes and spans, such as "Submit registration" or "POST /api/register", never names built from user input like `register ${email}`. Names are stored, and DevLens redacts personal data only on a best-effort basis. See Security and privacy.