Getting Started
Environment Variables

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:3000

Environment Variable Reference

Database

VariableDescriptionExample
MONGODB_URIMongoDB connection stringmongodb://localhost:27017 or mongodb+srv://...
DB_NAMEDatabase namesunday

Authentication

VariableDescriptionExample
JWT_SECRETSecret key for JWT signingA random 64+ character string

⚠️ Important: Use a strong, random string for JWT_SECRET in production. Generate one with:

openssl rand -hex 32

Email (Optional)

For email verification and password reset features:

VariableDescriptionExample
MAIL_HOSTSMTP server hostsmtp.gmail.com
MAIL_PORTSMTP port465
MAIL_SECUREUse SSL/TLStrue
MAIL_USERSMTP usernameyour-email@gmail.com
MAIL_PASSSMTP password or app passwordyour-app-password
MAIL_FROM_NAMESender nameSunday
MAIL_FROM_ADDRESSSender emailnoreply@sunday.com

CAPTCHA (Optional)

For spam protection on auth forms:

VariableDescription
NEXT_PUBLIC_CAP_SITE_KEYCap.js site key
CAP_SECRET_KEYCap.js secret key

File Storage (Optional)

For file uploads:

VariableDescription
BLOB_READ_WRITE_TOKENVercel 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.com

Production Considerations

In production environments:

  1. Never commit .env files - Add .env to .gitignore
  2. Use secure secrets - Generate random values for JWT_SECRET
  3. Use environment managers - Consider using Vercel, Railway, or similar for managing environment variables
  4. Enable HTTPS - Update NEXT_PUBLIC_APP_URL to use https://

MongoDB Atlas Setup

For production, we recommend MongoDB Atlas:

  1. Create a free cluster at mongodb.com/atlas (opens in a new tab)
  2. Create a database user with a strong password
  3. Add your server's IP to the IP Access List
  4. Get your connection string and update MONGODB_URI:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority