npm install @trailbase/sdkimport { TrailbaseClient } from '@trailbase/sdk';
const trailbase = new TrailbaseClient({
apiKey: process.env.TRAILBASE_API_KEY!,
region: 'us-east-1', // or 'eu-west-1'
});For Next.js, initialize the Trailbase client in a shared module (e.g., lib/trailbase.ts) and import it in your API routes and Server Actions. Do not expose the API key to the client — only use Trailbase in server-side code.
// In an API route or Server Action
export async function POST(req: Request) {
const session = await getSession();
await trailbase.track('document.create', {
actor: session.userId,
target: documentId,
metadata: { title, teamId },
});
// ... your business logic
}// Query audit logs
const events = await trailbase.search({
actor: userId,
action: 'document.*',
from: '2026-01-01',
});Join the waitlist for early access. Five-minute setup, no infrastructure changes.
Get Early Access