Environment Setup

Configure your development environment and manage environment variables.

Environment Variables

Create a .env.local file in your project root with the following variables:

# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# Stripe Configuration
STRIPE_SECRET_KEY=your_stripe_secret_key
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
# Email Configuration
RESEND_API_KEY=your_resend_api_key
# Application URLs
NEXT_PUBLIC_SITE_URL=http://localhost:3000
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Authentication
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_nextauth_secret # Generate with: openssl rand -base64 32

API Keys Setup

Supabase

Get your Supabase API keys from your project settings:

# 1. Go to https://app.supabase.com
# 2. Select your project
# 3. Go to Project Settings > API
# 4. Copy the following:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

Stripe

Set up your Stripe API keys for payment processing:

# 1. Go to https://dashboard.stripe.com/apikeys
# 2. Get your API keys:
STRIPE_SECRET_KEY=sk_test_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
# 3. Set up webhooks at https://dashboard.stripe.com/webhooks
# 4. Add the webhook secret:
STRIPE_WEBHOOK_SECRET=whsec_...

Email (Resend)

Configure Resend for sending transactional emails:

# 1. Create an account at https://resend.com
# 2. Go to API Keys
# 3. Create a new API key
RESEND_API_KEY=re_...

Development Environment

Set up your local development environment:

# Install dependencies
npm install
# Start the development server
npm run dev
# Run tests
npm run test
# Build for production
npm run build
# Start production server
npm run start

Environment Types

Development (.env.local)

Local development environment variables, not committed to version control.

Testing (.env.test)

Environment variables for running tests, can be committed to version control.

Production (.env.production)

Production environment variables, set through your hosting platform.

Next Steps