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
DATABASE_URLDatabase connection URLpostgresql://xxx

BETTER_AUTH_SECRET is a random string used for encryption and generating hashes. You can generate a 32-character secure key using the following command:

# Generate a 32-character secure key
openssl rand -base64 32

📧 Email Configuration

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

If you need to enable email/password login functionality that requires email verification, you need to set RESEND_API_KEY. If you need newsletter functionality, you need to set RESEND_AUDIENCE_ID.

If you only enable social media login without transactional emails or newsletter functionality, you don't need to set RESEND_API_KEY and RESEND_AUDIENCE_ID.

For more information about email configuration, see:

Email

Configure email templates and newsletter functionality for user communication.

🔐 OAuth Provider Settings

GitHub OAuth

VariableDescriptionExampleRequired
GITHUB_CLIENT_IDGitHub App Client IDa629723d24c123456
GITHUB_CLIENT_SECRETGitHub App Client Secretabc123def456ghi789jkl012

If you need to enable GitHub login functionality, you need to set GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET.

Google OAuth

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

If you need to enable Google login functionality, you need to set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.

For more information about OAuth configuration, see:

Authentication

Set up user authentication and authorization with multiple providers like OAuth, and more.

💳 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

For more information about payment configuration, see:

Payment

Integrate Stripe for handling payments and subscriptions with flexible pricing plans.

📁 Storage Configuration

VariableDescriptionExampleRequired
NEXT_PUBLIC_AVATARS_BUCKET_NAMES3 bucket name for avatar uploadsmy-app-avatars

This configuration needs to match the bucket name configured in your S3 or Cloudflare R2.

☁️ AWS S3 Configuration (if using AWS S3 services)

VariableDescriptionExampleRequired
STORAGE_REGIONS3 regionus-east-1
STORAGE_ACCESS_KEY_IDS3 AWS access keyAKXXX
STORAGE_SECRET_ACCESS_KEYS3 AWS secret keyXXX

🌍 Cloudflare R2 Configuration (if using Cloudflare R2 services)

VariableDescriptionExampleRequired
STORAGE_REGIONCloudflare R2 regionauto
STORAGE_ACCESS_KEY_IDCloudflare R2 access keyxxx
STORAGE_SECRET_ACCESS_KEYCloudflare R2 secret keyxxx
STORAGE_ENDPOINTCloudflare R2 endpointhttps://xxx.r2.cloudflarestorage.com

Storage

Set up file storage solutions for your application assets and user uploads.

📊 Analytics Configuration

VariableDescriptionExampleRequired
NEXT_PUBLIC_GOOGLE_ANALYTICS_IDGoogle Analytics website IDG-xxx
NEXT_PUBLIC_UMAMI_WEBSITE_IDUmami Analytics website IDxxx
NEXT_PUBLIC_UMAMI_SCRIPT_URLUmami Analytics script URLhttps://xxx.js
NEXT_PUBLIC_PLAUSIBLE_DOMAINPlausible Analytics domainxxx
NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URLPlausible Analytics script URLhttps://xxx.js

For more information about analytics configuration, see:

Analytics

Track user behavior and application performance with integrated analytics solutions.

💰 Affiliate Marketing Configuration

VariableDescriptionExampleRequired
NEXT_PUBLIC_AFFILIATE_AFFONSO_IDAffonso affiliate IDxxx

NEXT_PUBLIC_AFFILIATE_AFFONSO_ID is the Affonso affiliate ID used to track affiliate performance.

For more information about affiliate configuration, see:

Affiliate

Integrate Affonso to handle affiliate performance tracking.

📝 Example .env File

BETTER_AUTH_SECRET=
BETTER_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_APP_URL=http://localhost:3000

# ---------Database----------
DATABASE_URL=

# ---------Email----------
RESEND_API_KEY=
RESEND_AUDIENCE_ID=

# ---------Auth----------
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET

# ---------Payment----------
STRIPE_SECRET_KEY=sk_test_
STRIPE_WEBHOOK_SECRET=whsec_
NEXT_PUBLIC_PRICE_ID_PRO_MONTHLY=price_
NEXT_PUBLIC_PRICE_ID_PRO_YEARLY=price_
NEXT_PUBLIC_PRICE_ID_LIFETIME=price_

# ---------Storage----------

NEXT_PUBLIC_AVATARS_BUCKET_NAME=nextdevkit-avatars

# Clouflare R2
STORAGE_REGION=auto
STORAGE_ACCESS_KEY_ID=
STORAGE_SECRET_ACCESS_KEY=
STORAGE_ENDPOINT=https://xxx.r2.cloudflarestorage.com

# S3
#STORAGE_REGION=us-east-1
#STORAGE_ACCESS_KEY_ID=
#STORAGE_SECRET_ACCESS_KEY=

# ---------Analytics----------

NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-xxx

# Umami Analytics
NEXT_PUBLIC_UMAMI_WEBSITE_ID=
NEXT_PUBLIC_UMAMI_SCRIPT_URL=

# Plausible Analytics
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=
NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL=

# ---------Affiliate----------
NEXT_PUBLIC_AFFILIATE_AFFONSO_ID=

🛠️ 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 email - Confirm email sending works with your provider
  3. Deploy - Deploy to your chosen hosting platform

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