EaseLMS uses environment variables to configure various services and integrations. This guide provides a complete reference for all available variables.
Setup Instructions
Create a .env.local file in the apps/lms/ directory of your project:
cd apps/lms
touch .env.local
Never commit .env.local to version control. It’s already included in .gitignore.
Required Variables
These variables are essential for EaseLMS to function:
Supabase Configuration
# Supabase Project URL
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
# Supabase Anonymous Key (safe to expose in client)
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
# Supabase Service Role Key (keep secret!)
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
Get Supabase credentials
- Go to your Supabase project dashboard
- Navigate to Settings → API
- Copy the Project URL and API keys
Add to .env.local
Paste the values into your .env.local file
The SUPABASE_SERVICE_ROLE_KEY has full database access. Never expose it in client-side code or commit it to version control.
Application URL
# The URL where your application is accessible
NEXT_PUBLIC_APP_URL=http://localhost:3000
For production, change this to your actual domain:
NEXT_PUBLIC_APP_URL=https://yourdomain.com
Optional Variables
These variables enable additional features:
AWS S3 Storage
Required for uploading course videos, images, and resources.
# AWS Region
AWS_REGION=us-east-1
# AWS Access Credentials
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
# S3 Bucket Name
AWS_S3_BUCKET_NAME=your_bucket_name
# CloudFront Domain (optional, for CDN)
AWS_CLOUDFRONT_DOMAIN=your_cloudfront_domain
While optional for development, AWS S3 is highly recommended for production to handle file uploads and video streaming.
Payment Gateways
Enable course payments through Stripe and Flutterwave.
Stripe
# Stripe Secret Key (server-side)
STRIPE_SECRET_KEY=sk_test_...
# Stripe Publishable Key (client-side)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
Get Stripe keys
- Sign up at stripe.com
- Go to Developers → API keys
- Copy both the secret and publishable keys
Use test keys for development
Use keys starting with sk_test_ and pk_test_ for development. Switch to live keys (sk_live_ and pk_live_) for production.
Flutterwave
Popular for African markets with multi-currency support.
# Flutterwave Secret Key (server-side)
FLUTTERWAVE_SECRET_KEY=your_flutterwave_secret_key
# Flutterwave Public Key (client-side)
NEXT_PUBLIC_FLUTTERWAVE_PUBLIC_KEY=your_flutterwave_public_key
Currency Exchange Rates
Enable automatic currency conversion using exchangerate-api.com.
EXCHANGERATE_API_KEY=your_exchangerate_api_key
Email Notifications (SendGrid)
Enable automated email notifications for users and admins.
# SendGrid API Key
SENDGRID_API_KEY=your_sendgrid_api_key
# From Email Address
SENDGRID_FROM_EMAIL=noreply@yourdomain.com
# From Name
SENDGRID_FROM_NAME=EaseLMS
# Reply-To Address
SENDGRID_REPLY_TO=support@yourdomain.com
Generate API key
- Go to Settings → API Keys
- Click Create API Key
- Give it full access to Mail Send
- Copy the key (shown only once)
Verify sender email
- Go to Settings → Sender Authentication
- Verify your domain or single sender email
- Use the verified email as
SENDGRID_FROM_EMAIL
Email Types Sent
When configured, EaseLMS automatically sends:
User Emails:
- Welcome email on signup
- Course enrollment confirmation
- Course completion notification
- Certificate ready notification
- Payment confirmation
- Payment failed alert
Admin Emails:
- New enrollment notification
- New payment notification
- Course completion notification
Environment Variable Reference
Complete Example
Here’s a complete .env.local file with all variables:
# ============================================
# REQUIRED - Supabase
# ============================================
NEXT_PUBLIC_SUPABASE_URL=https://xxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGc...
SUPABASE_SERVICE_ROLE_KEY=eyJhbGc...
# ============================================
# REQUIRED - Application
# ============================================
NEXT_PUBLIC_APP_URL=http://localhost:3000
# ============================================
# OPTIONAL - AWS S3 Storage
# ============================================
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=wJalr...
AWS_S3_BUCKET_NAME=easelms-uploads
AWS_CLOUDFRONT_DOMAIN=d123456.cloudfront.net
# ============================================
# OPTIONAL - Payment Gateways
# ============================================
# Stripe
STRIPE_SECRET_KEY=sk_test_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
# Flutterwave
FLUTTERWAVE_SECRET_KEY=FLWSECK_TEST-...
NEXT_PUBLIC_FLUTTERWAVE_PUBLIC_KEY=FLWPUBK_TEST-...
# ============================================
# OPTIONAL - Currency Exchange
# ============================================
EXCHANGERATE_API_KEY=your_api_key_here
# ============================================
# OPTIONAL - Email (SendGrid)
# ============================================
SENDGRID_API_KEY=SG.xxx...
SENDGRID_FROM_EMAIL=noreply@yourdomain.com
SENDGRID_FROM_NAME=EaseLMS
SENDGRID_REPLY_TO=support@yourdomain.com
Variable Naming Conventions
Public vs Private Variables
NEXT_PUBLIC_* - Safe to expose to the browser, accessible in client-side code
- No prefix - Server-side only, never sent to the client
Never prefix sensitive keys (like SUPABASE_SERVICE_ROLE_KEY or STRIPE_SECRET_KEY) with NEXT_PUBLIC_ as this would expose them in the browser.
Development vs Production
Development Setup
# Use localhost
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Use test/sandbox keys for payments
STRIPE_SECRET_KEY=sk_test_...
FLUTTERWAVE_SECRET_KEY=FLWSECK_TEST-...
Production Setup
# Use your actual domain
NEXT_PUBLIC_APP_URL=https://yourdomain.com
# Use live/production keys
STRIPE_SECRET_KEY=sk_live_...
FLUTTERWAVE_SECRET_KEY=FLWSECK-...
Different platforms have different ways to set environment variables:
Vercel
- Go to your project settings
- Navigate to Environment Variables
- Add each variable with appropriate environment (Production/Preview/Development)
- Redeploy to apply changes
Railway
- Open your project
- Go to Variables tab
- Add each variable
- Changes apply automatically on next deployment
Docker
Use an .env file or pass variables in docker-compose.yml:
services:
app:
environment:
- NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL}
- NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}
# ... other variables
Security Best Practices
- Never commit
.env.local or .env files to version control
- Use different keys for development and production
- Rotate keys regularly, especially after team member changes
- Use secrets management in production (AWS Secrets Manager, etc.)
- Limit key permissions to only what’s needed
- Monitor usage of API keys for unusual activity
Troubleshooting
Variables not loading
- Restart the development server after changing
.env.local
- Ensure the file is in the correct location:
apps/lms/.env.local
- Check for syntax errors (no spaces around
=)
Public variables undefined in browser
Make sure they start with NEXT_PUBLIC_ and restart the dev server.
AWS/Stripe/SendGrid not working
Verify:
- Keys are correct and not expired
- Services are enabled in their respective dashboards
- For Stripe: webhook endpoints are configured
- For SendGrid: sender email is verified
Next Steps
After configuring your environment variables:
- Set up your database
- Deploy to production
- Customize your platform