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 key
  • STRIPE_PUBLISHABLE_KEY - Your Stripe publishable key
  • STRIPE_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.com

Setting up Resend

  1. Create an account at Resend
  2. Get your API key from the dashboard
  3. Add your domain and verify it with DNS records
  4. Set EMAIL_FROM to use your verified domain

For more details, see the Email documentation.