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
Variable | Example Value | Required | Where to Get It |
---|---|---|---|
PUBLIC_SUPABASE_URL | https://abc123.supabase.co | ✅ Yes | Supabase Dashboard → Settings → API |
PUBLIC_SUPABASE_ANON_KEY | eyJhbGciOiJIUzI1NiIsInR5cCI6... | ✅ Yes | Supabase Dashboard → Settings → API |
SUPABASE_SERVICE_ROLE_SECRET | eyJhbGciOiJIUzI1NiIsInR5cCI6... | ✅ Yes | Supabase Dashboard → Settings → API |
How to Find Supabase Keys
- Go to supabase.com and sign in
- Select your project
- Navigate to Project Settings → Data API and API Keys
- Copy the Project URL for
PUBLIC_SUPABASE_URL
- Copy the anon/public key for
PUBLIC_SUPABASE_ANON_KEY
- Copy the service_role key for
SUPABASE_SERVICE_ROLE_SECRET
Stripe Variables
Variable | Example Value | Required | Where to Get It |
---|---|---|---|
ENABLE_STRIPE | true | ✅ Yes | N/A |
PUBLIC_STRIPE_KEY | pk_test_51ABC123... | ✅ Yes | Stripe Dashboard → Developers → API Keys |
STRIPE_SECRET_KEY | sk_test_51ABC123... | ✅ Yes | Stripe Dashboard → Developers → API Keys |
STRIPE_WEBHOOK_SECRET | whsec_ABC123... | ✅ Yes | Stripe Dashboard → Developers → Webhooks |
PUBLIC_TRIAL_PERIOD_DAYS | 14 | ⚠️ Optional | Set manually (0 = no trial) |
How to Find Stripe Keys
API Keys:
- Go to dashboard.stripe.com
- Navigate to Developers → API Keys
- Use Test mode keys for development
- Copy Publishable key for
PUBLIC_STRIPE_KEY
- Reveal and copy Secret key for
STRIPE_SECRET_KEY
Webhook Secret:
- Go to Developers → Webhooks
- Create or select your webhook endpoint
- Click Reveal signing secret
- 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