LogoNEXTDEVKIT Docs

Next.js

Environment variable configuration for Next.js standalone deployment

This configuration is ideal for traditional hosting, Docker deployments, or development environments. Next.js standalone mode provides flexibility for various hosting providers.

🚀 Core Application Settings

VariableDescriptionExampleRequired
BETTER_AUTH_SECRETSecret key for Better Auth session encryptionyour-32-character-secret-key
BETTER_AUTH_URLBase URL of your applicationhttps://yourdomain.com
NEXT_PUBLIC_APP_URLPublic URL for client-side usagehttps://yourdomain.com

📧 Email Configuration

VariableDescriptionExampleRequired
RESEND_API_KEYAPI key for Resend email servicere_123456789
RESEND_AUDIENCE_IDAudience ID for newsletter functionalityaud_123456789

🔐 OAuth Provider Settings

GitHub OAuth

VariableDescriptionExampleRequired
GITHUB_CLIENT_IDGitHub App Client IDa629723d24c123456
GITHUB_CLIENT_SECRETGitHub App Client Secretabc123def456ghi789jkl012

Google OAuth

VariableDescriptionExampleRequired
GOOGLE_CLIENT_IDGoogle OAuth Client ID123456789-abc123.apps.googleusercontent.com
GOOGLE_CLIENT_SECRETGoogle OAuth Client SecretGOCSPX-abc123def456ghi789

💳 Payment Integration (Stripe)

VariableDescriptionExampleRequired
STRIPE_SECRET_KEYStripe secret key for server-side operationssk_test_123... or sk_live_123...
STRIPE_WEBHOOK_SECRETWebhook endpoint secret for Stripe eventswhsec_123456789
NEXT_PUBLIC_PRICE_ID_PRO_MONTHLYStripe price ID for monthly pro planprice_123456789
NEXT_PUBLIC_PRICE_ID_PRO_YEARLYStripe price ID for yearly pro planprice_987654321
NEXT_PUBLIC_PRICE_ID_LIFETIMEStripe price ID for lifetime planprice_555666777

📁 Storage Configuration

VariableDescriptionExampleRequired
NEXT_PUBLIC_AVATARS_BUCKET_NAMES3 bucket name for avatar uploadsmy-app-avatars

☁️ AWS Infrastructure (if using AWS services)

VariableDescriptionExampleRequired
AWS_ACCESS_KEY_IDAWS access key for S3 and other servicesAKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEYAWS secret key for authenticationwJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

🌍 Cloudflare Integration (if using Cloudflare services)

VariableDescriptionExampleRequired
CLOUDFLARE_API_TOKENCloudflare API token for DNS and other servicesabc123def456ghi789jkl012
CLOUDFLARE_DEFAULT_ACCOUNT_IDCloudflare account IDa1b2c3d4e5f6g7h8i9j0

📝 Example .env File

# Core Application
BETTER_AUTH_SECRET=your-32-character-secret-key-here
BETTER_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Email Service
RESEND_API_KEY=re_123456789
RESEND_AUDIENCE_ID=aud_123456789

# OAuth Providers
GITHUB_CLIENT_ID=Iv1.a629723d24c123456
GITHUB_CLIENT_SECRET=abc123def456ghi789jkl012
GOOGLE_CLIENT_ID=123456789-abc123.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-abc123def456ghi789

# Payment Processing
STRIPE_SECRET_KEY=sk_test_123...
STRIPE_WEBHOOK_SECRET=whsec_123456789
NEXT_PUBLIC_PRICE_ID_PRO_MONTHLY=price_123456789
NEXT_PUBLIC_PRICE_ID_PRO_YEARLY=price_987654321
NEXT_PUBLIC_PRICE_ID_LIFETIME=price_555666777

# Storage
NEXT_PUBLIC_AVATARS_BUCKET_NAME=my-app-avatars

# AWS (Optional)
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

# Cloudflare (Optional)
CLOUDFLARE_API_TOKEN=abc123def456ghi789jkl012
CLOUDFLARE_DEFAULT_ACCOUNT_ID=a1b2c3d4e5f6g7h8i9j0

🛠️ Development vs Production

Development Environment

  • Use http://localhost:3000 for local URLs
  • Use Stripe test keys (starting with sk_test_)
  • OAuth redirect URIs should point to localhost

Production Environment

  • Use your actual domain for all URLs
  • Use Stripe live keys (starting with sk_live_)
  • Configure OAuth providers with production redirect URIs
  • Ensure all secrets are properly secured and rotated regularly

🔧 Next Steps

After setting up your environment variables:

  1. Test authentication - Verify OAuth providers work correctly
  2. Test payments - Ensure Stripe integration functions properly
  3. Test email - Confirm email sending works with your provider
  4. Deploy - Deploy to your chosen hosting platform

Your Next.js application is now ready for development and deployment! 🎉