Capture a TypeSafe request from your app and inspect its context and answer in the browser. We'll connect a Vite React frontend to an existing Express server.
For Next.js App Router, use the Next.js guide. To try the inspector without an API key, run the sample React + Vite app.
Before you begin#
Use an app with these dependencies:
- Node 22.12+ and ESM imports on the server.
- Matching React and React DOM 18.x or 19.x versions.
- TypeSafe SDK 0.7.x and a server-side API key.
- TypeScript 5.4+ if your app uses TypeScript. Your framework and type packages may require a newer compiler.
See the compatibility reference for compiler settings and type dependencies.
This walkthrough uses http://localhost:3000 for the browser and 127.0.0.1:3001 for Express. Keep the backend bound to loopback. For a shared server or tunnel, configure access controls before exposing the inspector.
1. Install the package#
Install in the workspace that imports the package. If your frontend and server use separate workspaces, install in each one.
pnpm add jev-devtools @typesafe-ai/sdknpm install jev-devtools @typesafe-ai/sdkyarn add jev-devtools @typesafe-ai/sdkbun add jev-devtools @typesafe-ai/sdkKeep your existing SDK version if it is in the supported 0.7.x range. React and React DOM are required peers even in a server-only workspace.
2. Create a server adapter#
Set TYPESAFE_API_KEY through your server's environment loader. Keep it out of browser variables such as VITE_* and NEXT_PUBLIC_*. The request in step 5 uses live inference.
Create server.ts beside your Express entry point:
// server.ts (Node only)
import { createJevDevtools } from "jev-devtools/server";
export const inspector = createJevDevtools({
enabled: process.env.NODE_ENV === "development",
origin: "http://localhost:3000", // Must match the browser URL exactly.
});
export const jev = inspector.createClient({
apiKey: process.env.TYPESAFE_API_KEY,
});Create an independent Node server adapter. Share it between your HTTP endpoints and instrumented clients.
createJevDevtools(options)- enabled
- Opt into server capture and inspector endpoints. Defaults to false; disabling capture does not stop inference.
- origin
- The exact browser origin, including scheme, hostname, and port.
- endpoint
- The inspector URL path. Defaults to /api/jev-devtools; must match the browser component.
- limit
- Maximum retained request traces across sessions. Defaults to 50; clamped to 1–200.
- redact
- Transform the captured copy before storage or streaming. Incompatible structured content remains as JSON in Trace.capture with warnings. The drawer keeps usable fields visible beside unavailable placeholders. SDK inputs and application values stay unchanged.
- authorize
- Your application access check. Required for an enabled non-loopback origin.
- getSession
- Derive a trusted recording scope from the request. Defaults to the shared local scope.
Opt into server capture and inspector endpoints. Defaults to false; disabling capture does not stop inference.
enabledThe exact browser origin, including scheme, hostname, and port.
originCreate an instrumented TypeSafe client. Captures systemOne calls when recording is enabled; otherwise returns an ordinary SDK client. Keep credentials on the server.
adapter.createClient(options, metadata?)- label
- Optional capture label. Defaults to Jev request.
- source
- Capture label: sample or live. Defaults to live. This does not switch transports or prevent inference.
API reference: createJevDevtools() · adapter.createClient()
The origin is the URL you open in the browser, including its scheme, hostname, and port. Keep it set even when capture is disabled. localhost and 127.0.0.1 are different origins.
Keep this file on Node. Import jev-devtools in React and jev-devtools/server on the server; never bundle the server module or its key into the frontend. The optional jev-devtools/flow entry also belongs on Node. Use only these public imports.
If you already create a TypeSafe client, replace that construction with inspector.createClient() and preserve your existing SDK options. Use the returned jev client for the calls you want to capture.
3. Connect the HTTP routes#
In your Express entry point, mount the inspector before your application's fallback handler:
import { inspector } from "./server.js";
app.use(inspector.middleware);Mount at the application root to serve inspector endpoints and their subpaths. Unrelated routes call next().
app.use(adapter.middleware)API reference: adapter.middleware
Here app is your existing Express application. Configure its existing listen() call to use port 3001 and host 127.0.0.1. Call inspector.dispose() when that server shuts down.
Add these server options to your existing vite.config.ts. Preserve your plugins and other configuration:
// Inside defineConfig({ ... }) in vite.config.ts
server: {
host: "127.0.0.1",
port: 3000,
strictPort: true,
proxy: {
"/api": {
target: "http://127.0.0.1:3001",
changeOrigin: false,
},
},
},The proxy sends both inspector and application API requests to Express. It preserves the full path and browser Host header. Merge this rule with any existing /api proxy instead of adding a second rule.
Start Express with NODE_ENV=development, then start Vite with your app's usual development command. Open http://localhost:3000/api/jev-devtools in the browser. You should receive the inspector's JSON configuration. A 403 or 404 response means the routes or origin need attention before you continue.
4. Mount the drawer#
Add JevDevtools once in your existing React root. Keep your application's content where this example shows <main>:
import { JevDevtools } from "jev-devtools";
export function Root() {
return (
<>
<main>Your application</main>
<JevDevtools enabled={import.meta.env.DEV} defaultOpen={false} />
</>
);
}Mount the inspector once near your application root. It connects after mounting when enabled; it renders nothing during SSR.
<JevDevtools enabled defaultOpen={false} />- enabled
- Load and connect the browser inspector. Defaults to false; enable the server adapter separately.
- defaultOpen
- Whether the drawer starts expanded. Defaults to true; false starts at the launcher.
- endpoint
- Same-origin inspector path. Defaults to /api/jev-devtools; must match the server adapter.
- redactAdditionalSensitiveData
- Mask supported personal fields in the display. Does not remove captured data. Available since 0.5.0; defaults to true.
Load and connect the browser inspector. Defaults to false; enable the server adapter separately.
enabledWhether the drawer starts expanded. Defaults to true; false starts at the launcher.
defaultOpenAPI reference: JevDevtools
Open http://localhost:3000. You should see the Jev DevTools launcher. No stylesheet import or provider is needed. Both the server adapter and React component must be enabled; this example uses Vite's import.meta.env.DEV flag for the component.
5. Make a request#
Create request.ts beside server.ts on your Node server:
// request.ts (Node only)
import { choice } from "@typesafe-ai/sdk";
import { jev } from "./server.js";
export async function classifyMessage(message: string) {
const result = await jev.systemOne({
state: { message },
questions: {
team: choice("Which team can help?", {
billing: "Charges and payments",
delivery: "Shipping and tracking",
other: "Everything else",
}),
},
});
console.log(result.answers.team.choice); // The selected team from the SDK response
return result;
}Call await classifyMessage("I was charged twice.") from an existing application HTTP handler. That handler must use the same server module and process as the inspector routes. Trigger the handler from your frontend through the /api proxy.
The server console prints the model's chosen team: billing, delivery, or other. The choice depends on the response; this is a live request with no predetermined answer.
Verify your integration#
- Open the Jev DevTools launcher and select the recorded request.
- Open Context. Find the message
I was charged twice.. - Open Questions. Check that the returned team matches your server log.
- Open Raw to compare the captured response with the application result.
- Close and reopen the drawer. Your selection should remain while the trace is retained.
If no request appears, check that your handler uses the exported jev client rather than another SDK instance. See The drawer is empty for the remaining checks.
Before shipping your app, confirm that production disables both the adapter and component. Disabling capture leaves SDK requests working.
Look up an API#
Use the API glossary for method options and return values. To connect application steps, continue with Flows from scratch.