• Pricing
  • Blog
Log inBook a demo

Better Auth Plugin

@commet/better-auth syncs your auth users with Commet customers automatically and adds subscriptions, usage tracking, and feature checks to your authClient.

G
Guido Irigoyen·@guidooirigoyen·December 11, 2025
Changelog

Add billing to your Better Auth setup without touching the Commet SDK directly. Your authClient now handles everything.

bash
npm install @commet/better-auth

What's New#

We shipped @commet/better-auth - a plugin that extends Better Auth with billing primitives.

Your authClient now handles:

  • Customer sync (automatic on signup)

  • Subscription management

  • Feature flags

  • Usage tracking

  • Seat management

  • Customer portal access

Note

No separate SDK initialization. No manual customer mapping. The plugin automatically syncs your auth users with Commet customers.

How It Works#

Install the Plugin#

typescript
// src/lib/auth.ts
import { betterAuth } from 'better-auth'
import { commet } from '@commet/better-auth'

export const auth = betterAuth({
  plugins: [
    commet({
      apiKey: process.env.COMMET_API_KEY!,
      environment: 'sandbox'
    })
  ]
})

Use It Everywhere#

typescript
import { authClient } from '@/lib/auth-client'

// Check feature access
const { allowed } = await authClient.features.canUse('api_access')

// Track usage
await authClient.usage.track('api_call')

// Manage seats
await authClient.seats.add('team_member', 1)

// Get subscription
const sub = await authClient.subscription.get()

// Open customer portal
const { url } = await authClient.customer.portal()

Why This Matters#

With the plugin, you don't need to manually sync user states between your auth system and billing system.

Before#

typescript
// Get user from auth
const session = await getSession()

// Map to billing customer
const customer = await findCustomer(session.user.id)

// Check billing state
const sub = await commet.subscriptions.get(customer.externalId)

// Gate feature
if (sub.status !== 'active') redirect('/upgrade')

After#

typescript
const { allowed } = await authClient.features.canUse('api_access')
if (!allowed) redirect('/upgrade')

Template#

We have complete reference implementations in our templates showing how to implement the plugin with different billing models. Run commet create to get started.

Next steps#

If you're using Better Auth, this is the fastest way to add billing. Visit the Better Auth docs to get started.

Subscription billing built for developers and agents

Get startedBook a demo

Accept global payments, handle usage-based pricing, subscriptions, and seats — without building your own infrastructure.

Frameworks

  • Next.js
  • Remix
  • Nuxt
  • SvelteKit
  • Astro
  • Express
  • Hono
  • Django
  • FastAPI

Resources

  • Documentation
  • Guides
  • Blog
  • Templates
  • Changelog
  • Glossary
  • Billing for AI models

Company

  • Solutions
  • About
  • Open Source

Compare

  • Stripe Billing
  • Orb
  • Chargebee
  • Lago
  • Autumn
  • Yuno

AI

  • Commet Agents
  • MCP Server
  • Skills
  • Skills on GitHub
  • Claude Code
  • Codex
  • Cursor
Follow us
© 2026 Commet Co.TermsPrivacy PolicyCookie Policy