Examples
Practical integration recipes for Next.js, auth, payments, and edge validation.
Use these recipes to implement TrackStack quickly with predictable production behavior.
Recommended implementation paths
| Goal | Start here | Why |
|---|---|---|
| Baseline setup | Quickstart | Install SDK and send first event |
| App integration | SDK setup | Production React/Next.js patterns |
| Auth identity sync | Integrations | Clerk/Auth0/NextAuth identity helpers |
| Event taxonomy | B2B SaaS events | Canonical naming for clean reporting |
| Destination behavior | Supported platforms | Platform-specific delivery expectations |
| API validation | API playground | Test requests against runtime OpenAPI |
Copy-paste snippets
pnpm add @trackstack/sdk
import { createTrackStack } from "@trackstack/sdk";
export const trackstack = createTrackStack({
publicKey: process.env.NEXT_PUBLIC_TRACKSTACK_KEY!,
edge: process.env.NEXT_PUBLIC_EDGE_URL ?? "https://edge.gettrackstack.com",
});
trackstack.capture("Purchase", {
eventId: "evt_001",
email: "jane@example.com",
value: 1299,
currency: "USD",
transactionId: "txn_001",
});
eventId is optional. Provide it when you need deterministic dedup IDs; otherwise the SDK generates one per event.
Environment checklist
NEXT_PUBLIC_TRACKSTACK_KEY(required)NEXT_PUBLIC_EDGE_URL(optional override)NEXT_PUBLIC_POSTHOG_KEY(optional, when using PostHog proxy)
How to use these examples
- Start with Quickstart to validate ingestion
- Wire framework/auth behavior with SDK setup and Integrations
- Verify payloads in API playground
- Keep production naming aligned with B2B SaaS events