Getting started

Framework guides

Where to call init() in React, Next.js, Vue, Nuxt, SvelteKit or plain HTML.
On Nuxt, Astro, Next.js or TanStack Start, one package sets up the browser SDK and the server SDK together. See Framework integrations.

The SDK only touches document.modelContext, so it works with any framework. Two rules apply everywhere:

  1. Browser only. Never call init() during server-side rendering.
  2. Before tools are registered. Tools registered earlier are not tracked unless you wrap them.

Call init once at module scope of the client entry, before any component registers tools.

src/main.tsx
import { AgentStats } from '@agentstats/sdk'

AgentStats.init({ key: 'al_pub_…' })