Understanding the Credit System
How the credit-based billing system works and how to implement it in your SaaS.
One of the key features of Taufolio is its credit-based billing system. This article explains how it works and how you can customize it for your needs.
What Are Credits?#
Credits are a virtual currency used to perform actions in your SaaS. Instead of unlimited usage, users purchase or earn credits that are consumed when they use premium features.
Why Use Credits?#
Credits offer several advantages over traditional subscription models:
- Fair pricing - Users pay for what they use
- Flexibility - Easy to add new features with different costs
- Predictable costs - You can estimate server costs per credit
- Upselling opportunities - Users can purchase more credits when needed
How It Works#
When a user signs up, they receive trial credits based on your configuration:
// config/features.ts
export const features = {
trialCredits: 150, // Credits for new users
}Each action in your app can have a credit cost. Use the withCreditCheck helper:
import { withCreditCheck } from '@/actions/credits'
await withCreditCheck(spaceId, 5, 'AI Generation', async () => {
// Your expensive operation here
})Subscription Tiers#
You can configure different subscription tiers with different credit allocations:
- Starter - 500 credits/month
- Pro - 2,000 credits/month
- Enterprise - Unlimited
Credits reset each billing cycle, encouraging users to use their allocation.
Customization Tips#
Consider these factors when setting credit costs:
- Server/API costs per operation
- Value delivered to the user
- Competition pricing
- User expectations
Start conservative and adjust based on user feedback!