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_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...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'
// ... free plan config
},
pro: {
id: 'pro',
name: 'Pro',
description: 'Best for most teams.',
features: ['Feature 1', 'Feature 2'],
prices: [
{
id: 'pro_monthly',
stripePriceId: env.NEXT_PUBLIC_STRIPE_PRICE_PRO_MONTHLY ?? '',
type: 'recurring',
interval: 'month',
amount: 2900, // $29.00 in cents
currency: 'usd'
}
]
}
}
// ... credit packages and other config
} satisfies BillingConfig;Environment Variables
Make sure to set the following environment variables:
STRIPE_SECRET_KEY- Your Stripe secret keySTRIPE_PUBLISHABLE_KEY- Your Stripe publishable keySTRIPE_WEBHOOK_SECRET- Your Stripe webhook secret (for production)
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.