General
Billing
Configuration
Learn about the billing configuration.
The billing configuration ensures consistent behavior across the application and any billing provider.
Basic Setup
Configure your Stripe keys in .env:
.env
STRIPE_SECRET_KEY=sk_test_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
NEXT_PUBLIC_STRIPE_PRICE_PRO_MONTHLY=price_...
NEXT_PUBLIC_STRIPE_PRICE_PRO_YEARLY=price_...
NEXT_PUBLIC_STRIPE_PRICE_LIFETIME=price_...
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_STARTER=price_...
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_BASIC=price_...
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_PRO=price_...Products and Plans
Define your products and plans in your billing configuration file. A simple monthly pro plan would look like this:
config/billing.config.ts
import { env } from '@/lib/env';
export const billingConfig = {
enabled: true,
defaultCurrency: 'usd',
plans: {
free: {
id: 'free',
name: 'Free',
description: 'Get started with basic features',
isFree: true,
features: ['Basic analytics'],
limits: {
maxMembers: 3,
maxStorage: 1
}
},
pro: {
id: 'pro',
name: 'Pro',
description: 'Best for most teams.',
features: ['Feature 1', 'Feature 2'],
limits: {
maxMembers: 10,
maxStorage: 100
},
prices: [
{
id: 'pro_monthly',
stripePriceId: env.NEXT_PUBLIC_STRIPE_PRICE_PRO_MONTHLY ?? '',
type: 'recurring',
interval: 'month',
intervalCount: 1,
amount: 2900, // $29.00 in cents
currency: 'usd'
}
]
}
}
} satisfies BillingConfig;Environment Variables
Make sure to set the following environment variables:
STRIPE_SECRET_KEY- Your Stripe secret keyNEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY- Your Stripe publishable keySTRIPE_WEBHOOK_SECRET- Your Stripe webhook secret (for production)NEXT_PUBLIC_STRIPE_PRICE_PRO_MONTHLY- Monthly Pro price IDNEXT_PUBLIC_STRIPE_PRICE_PRO_YEARLY- Yearly Pro price IDNEXT_PUBLIC_STRIPE_PRICE_LIFETIME- One-time lifetime price IDNEXT_PUBLIC_STRIPE_PRICE_CREDITS_STARTER- Starter credit package price IDNEXT_PUBLIC_STRIPE_PRICE_CREDITS_BASIC- Basic credit package price IDNEXT_PUBLIC_STRIPE_PRICE_CREDITS_PRO- Pro credit package price ID
Email Configuration (Resend)
The starter kit uses Resend for sending emails. Configure Resend in your .env:
.env
RESEND_API_KEY=re_...
EMAIL_FROM=noreply@yourdomain.comSetting up Resend
- Create an account at Resend
- Get your API key from the dashboard
- Add your domain and verify it with DNS records
- Set
EMAIL_FROMto use your verified domain
For more details, see the Email documentation.