Skip to main content

Environment Variables

All environment variables required by SvelteBolt with descriptions and troubleshooting tips.

Environment File Setup

Copy the example file and fill in your values:

cp .env.example .env

Supabase Variables

VariableExample ValueRequiredWhere to Get It
PUBLIC_SUPABASE_URLhttps://abc123.supabase.co✅ YesSupabase Dashboard → Settings → API
PUBLIC_SUPABASE_ANON_KEYeyJhbGciOiJIUzI1NiIsInR5cCI6...✅ YesSupabase Dashboard → Settings → API
SUPABASE_SERVICE_ROLE_SECRETeyJhbGciOiJIUzI1NiIsInR5cCI6...✅ YesSupabase Dashboard → Settings → API

How to Find Supabase Keys

  1. Go to supabase.com and sign in
  2. Select your project
  3. Navigate to Project SettingsData API and API Keys
  4. Copy the Project URL for PUBLIC_SUPABASE_URL
  5. Copy the anon/public key for PUBLIC_SUPABASE_ANON_KEY
  6. Copy the service_role key for SUPABASE_SERVICE_ROLE_SECRET

Stripe Variables

VariableExample ValueRequiredWhere to Get It
ENABLE_STRIPE true✅ YesN/A
PUBLIC_STRIPE_KEYpk_test_51ABC123...✅ YesStripe Dashboard → Developers → API Keys
STRIPE_SECRET_KEYsk_test_51ABC123...✅ YesStripe Dashboard → Developers → API Keys
STRIPE_WEBHOOK_SECRETwhsec_ABC123...✅ YesStripe Dashboard → Developers → Webhooks
PUBLIC_TRIAL_PERIOD_DAYS14⚠️ OptionalSet manually (0 = no trial)

How to Find Stripe Keys

API Keys:

  1. Go to dashboard.stripe.com
  2. Navigate to DevelopersAPI Keys
  3. Use Test mode keys for development
  4. Copy Publishable key for PUBLIC_STRIPE_KEY
  5. Reveal and copy Secret key for STRIPE_SECRET_KEY

Webhook Secret:

  1. Go to DevelopersWebhooks
  2. Create or select your webhook endpoint
  3. Click Reveal signing secret
  4. Copy the value for STRIPE_WEBHOOK_SECRET

Trial Period Configuration:

  • PUBLIC_TRIAL_PERIOD_DAYS controls the free trial length for subscriptions
  • Set to 14 for a 14-day trial, 7 for 7 days, etc.
  • Set to 0 to disable the trial period completely
  • This value is used in the Stripe checkout session creation

Disabling Stripe:

  • If you want to disable Stripe integration, set ENABLE_STRIPE=false
  • This will disable all Stripe-related features in the app
  • Ensure you handle this in your application logic to avoid errors

Complete .env Example

# Supabase Configuration
PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co
PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
SUPABASE_SERVICE_ROLE_SECRET=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

# Stripe Configuration
ENABLE_STRIPE=true
PUBLIC_STRIPE_KEY=pk_test_51ABC123DEF456GHI789...
STRIPE_SECRET_KEY=sk_test_51ABC123DEF456GHI789...
STRIPE_WEBHOOK_SECRET=whsec_ABC123DEF456...
PUBLIC_TRIAL_PERIOD_DAYS=14

Troubleshooting

Common Issues

❌ "Invalid API key" errors:

  • Verify you're using the correct environment (test vs live)
  • Check for extra spaces or characters in your keys
  • Ensure you've copied the complete key

❌ "CORS errors" with Supabase:

  • Verify your PUBLIC_SUPABASE_URL is correct
  • Check your project is not paused in Supabase

❌ Stripe webhook failures:

  • Verify STRIPE_WEBHOOK_SECRET matches your webhook endpoint
  • Check webhook endpoint URL is correct
  • Ensure webhook is listening for correct events

❌ Missing environment variables:

  • Check .env file exists in project root
  • Restart your development server after adding variables
  • Verify variable names match exactly (case-sensitive)

❌ Trial period not working:

  • Verify PUBLIC_TRIAL_PERIOD_DAYS is set correctly
  • Set to 0 to disable trials completely
  • Ensure the value is a valid number (no quotes needed)
  • Check that Stripe checkout sessions are using this value

Development vs Production

Development (Test Mode):

  • Use Stripe test keys (pk_test_, sk_test_)
  • Use Supabase development project
  • Test payments won't charge real money

Production (Live Mode):

  • Use Stripe live keys (pk_live_, sk_live_)
  • Use Supabase production project
  • Real payments will be processed

Security Notes

  • Never commit .env files to version control
  • Use different keys for development and production
  • Regularly rotate your service role secrets
  • Monitor API key usage in Stripe/Supabase dashboards