Console →
Guides

Tracking Usage in Next.js

Full walkthrough on using SettleSettle within the Next.js ecosystem:

  • Where to create the SDK singleton (lib/settle.ts)
  • How to track events in server components
  • How to track events in Route Handlers (app/api/...)
  • How to check wallet balance before allowing an action
  • How to handle InsufficientCreditsError in the API layer
Common mistake: importing SDK in client components (will expose API key). Always ensure files that initialize the SDK are either marked server-only or only imported in server files.