Configuration¶
This guide explains all the environment variables needed to run Learnify.
Environment Variables¶
Create a .env file in the root directory with the following variables:
Database¶
Getting your DATABASE_URL:
- Sign up at neon.tech
- Create a new project
- Copy the connection string from the dashboard
- Add
?sslmode=requireto the end
Authentication¶
OAuth Providers (Optional)¶
Setting up Google OAuth:
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google
Setting up GitHub OAuth:
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set Authorization callback URL:
http://localhost:3000/api/auth/callback/github
Stripe¶
STRIPE_SECRET_KEY="sk_test_..."
STRIPE_PUBLISHABLE_KEY="pk_test_..."
STRIPE_WEBHOOK_SECRET="whsec_..."
Getting Stripe Keys:
- Sign up at stripe.com
- Go to Developers > API Keys
- Copy the publishable and secret keys (use test keys for development)
Setting up Webhooks:
- Go to Developers > Webhooks
- Add endpoint:
https://your-domain.com/api/webhooks/stripe - Select events:
checkout.session.completed,payment_intent.succeeded - Copy the webhook signing secret
Cloudinary¶
CLOUDINARY_CLOUD_NAME=""
CLOUDINARY_API_KEY=""
CLOUDINARY_API_SECRET=""
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=""
NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET=""
Setting up Cloudinary:
- Sign up at cloudinary.com
- Go to Dashboard to find your cloud name, API key, and secret
- Create an unsigned upload preset:
- Go to Settings > Upload
- Add upload preset
- Set signing mode to "Unsigned"
Application¶
Change this to your production URL when deploying.
Complete Example¶
# Database (Neon)
DATABASE_URL="postgresql://user:pass@host/db?sslmode=require"
# NextAuth
AUTH_SECRET="generate-a-secure-random-string"
AUTH_URL="http://localhost:3000"
# OAuth Providers
AUTH_GOOGLE_ID="your-google-client-id"
AUTH_GOOGLE_SECRET="your-google-client-secret"
AUTH_GITHUB_ID="your-github-client-id"
AUTH_GITHUB_SECRET="your-github-client-secret"
# Stripe
STRIPE_SECRET_KEY="sk_test_xxx"
STRIPE_PUBLISHABLE_KEY="pk_test_xxx"
STRIPE_WEBHOOK_SECRET="whsec_xxx"
# Cloudinary
CLOUDINARY_CLOUD_NAME="your-cloud"
CLOUDINARY_API_KEY="123456789"
CLOUDINARY_API_SECRET="xxx"
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="your-cloud"
NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET="your-preset"
# App
NEXT_PUBLIC_APP_URL="http://localhost:3000"