Every screen reads sample data from typed TypeScript files. Connect your API one screen at a time and keep the sample data for screens you haven't connected yet.
1. Find what the screen reads
Open the screen's file and follow its imports from lib/data.ts and lib/data-ops.ts. Some table and list components import sample data themselves; note those too.
For example, the /traces screen shows Trace records. A Trace has these fields: id, name, feature, model, status, latencyMs, inputTokens, outputTokens, cost, user, time, score, spans.
2. Keep the kit's types
If your API returns a different shape, write one small mapping function from your shape to the kit's type instead of changing every component:
import type { Trace } from "@/lib/data";
// Map one record from your API to the kit's Trace type.
export function toTrace(api: ApiRecord): Trace {
return {
id: String(api.id),
// …one line per field the screen uses
} as Trace;
}3. Load the data
Next.js edition
Pages are server components, so they can await data directly. Keep secrets in server environment variables.
// app/(app)/traces/page.tsx
async function getTraces(): Promise<Trace[]> {
const res = await fetch(`${process.env.API_URL}/traces`, { cache: "no-store" });
if (!res.ok) throw new Error("Could not load traces");
return res.json();
}
export default async function Page() {
const traces = await getTraces();
// pass traces to the table or list component as a prop
}Client components (files that start with "use client") can't await. Give them their data from the page instead.
React + Vite edition
Use a React Router loader, so data loads before the screen renders:
// src/routes.tsx
{ path: "traces", lazy: () => import("./pages/traces/index").then((m) => ({ Component: m.default, loader: m.loader })) },
// src/pages/traces/index.tsx
export async function loader() {
const res = await fetch(`${import.meta.env.VITE_API_URL}/traces`);
if (!res.ok) throw new Response("Could not load traces", { status: res.status });
return (await res.json()) as Trace[];
}
// in the component: const traces = useLoaderData() as Trace[];TanStack Query or SWR work too. Everything in a Vite app runs in the browser, so never put secret keys in VITE_ variables. Call your own backend, which holds the secrets.
4. Pass the data in as a prop
Give the table or list component the data as a prop instead of letting it import the sample file. Other screens keep using sample data until you connect them.
5. Handle loading, empty and error states
Use EmptyState from components/patterns/empty-state for empty and error states, and Skeleton from components/ui/misc while loading.
6. Wire up actions
Interactive pieces (approvals, toggles, bulk actions) keep their state locally and call toast(...) where a real app would call your API. Replace each of those with your API call, and keep a toast for the result, such as "Saved" or "Couldn't save: …".
See the integration guides for field mappings from common tools to the kit's types.