Environment Variables
Sunday requires several environment variables to run properly.
Required Variables
Create a .env file in the root directory with these required variables:
# MongoDB Connection
MONGODB_URI=mongodb://localhost:27017
DB_NAME=sunday
# JWT Authentication
JWT_SECRET=your-super-secret-jwt-key-here
# Application URL
NEXT_PUBLIC_APP_URL=http://localhost:3000Environment Variable Reference
Database
| Variable | Description | Example |
|---|---|---|
MONGODB_URI | MongoDB connection string | mongodb://localhost:27017 or mongodb+srv://... |
DB_NAME | Database name | sunday |
Authentication
| Variable | Description | Example |
|---|---|---|
JWT_SECRET | Secret key for JWT signing | A random 64+ character string |
⚠️ Important: Use a strong, random string for
JWT_SECRETin production. Generate one with:openssl rand -hex 32
Email (Optional)
For email verification and password reset features:
| Variable | Description | Example |
|---|---|---|
MAIL_HOST | SMTP server host | smtp.gmail.com |
MAIL_PORT | SMTP port | 465 |
MAIL_SECURE | Use SSL/TLS | true |
MAIL_USER | SMTP username | your-email@gmail.com |
MAIL_PASS | SMTP password or app password | your-app-password |
MAIL_FROM_NAME | Sender name | Sunday |
MAIL_FROM_ADDRESS | Sender email | noreply@sunday.com |
CAPTCHA (Optional)
For spam protection on auth forms:
| Variable | Description |
|---|---|
NEXT_PUBLIC_CAP_SITE_KEY | Cap.js site key |
CAP_SECRET_KEY | Cap.js secret key |
File Storage (Optional)
For file uploads:
| Variable | Description |
|---|---|
BLOB_READ_WRITE_TOKEN | Vercel Blob storage token |
Example .env File
# ===================
# Database
# ===================
MONGODB_URI=mongodb://localhost:27017
DB_NAME=sunday
# ===================
# Authentication
# ===================
JWT_SECRET=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6
# ===================
# Application
# ===================
NEXT_PUBLIC_APP_URL=http://localhost:3000
# ===================
# Email (Optional)
# ===================
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_SECURE=true
MAIL_USER=your-email@gmail.com
MAIL_PASS=your-app-password
MAIL_FROM_NAME=Sunday
MAIL_FROM_ADDRESS=noreply@yourdomain.comProduction Considerations
In production environments:
- Never commit
.envfiles - Add.envto.gitignore - Use secure secrets - Generate random values for
JWT_SECRET - Use environment managers - Consider using Vercel, Railway, or similar for managing environment variables
- Enable HTTPS - Update
NEXT_PUBLIC_APP_URLto usehttps://
MongoDB Atlas Setup
For production, we recommend MongoDB Atlas:
- Create a free cluster at mongodb.com/atlas (opens in a new tab)
- Create a database user with a strong password
- Add your server's IP to the IP Access List
- Get your connection string and update
MONGODB_URI:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority