Commet
  • Pricing
Log InTry out

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.

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

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

How It Works

Install the Plugin

// 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

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

// 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

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.

Developers

  • Documentation
  • Templates
  • GitHub

Frameworks

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

Resources

  • Blog
  • Changelog
  • Pricing

AI

  • Agents
  • MCP Server
  • Agent Skills
  • Claude Code
  • Codex
  • Cursor

Learn

  • Guides
  • Glossary
  • Solutions
  • Billing for AI Models
  • Comparison

Compare

  • Stripe alternative
  • Orb alternative
  • Recurly alternative
  • Paddle alternative
  • Chargebee alternative
  • Lago alternative

Company

  • About
  • Open Source
  • Terms
  • Privacy

Countries

  • Mexico
  • Argentina
  • Colombia
  • Chile
  • Peru
  • Ecuador
  • Uruguay
  • Paraguay
  • Bolivia
  • Panama
  • El Salvador
  • Brazil
System statusXLinkedInGitHub