Environment Variables
This guide documents all environment variables used to configure Openfront. Environment variables control database connections, authentication, payment providers, shipping integrations, file storage, email services, and more.All environment variables should be defined in a
.env file in your project root. Never commit this file to version control.Required Variables
These variables are required for Openfront to function:Database Connection
PostgreSQL database connection string.Format:
postgresql://username:password@host:port/databaseExample:Secret key for encrypting session data. Must be at least 32 characters long.Example:Generate a secure secret:
Optional Variables
Database (Advanced)
Shadow database URL for Prisma migrations. Used when your main database doesn’t support schema diffing.Format:
postgresql://username:password@host:port/database_shadowExample:Application Settings
Node.js environment mode.Options:
development, production, testExample:In production mode, secure cookies are enforced and additional optimizations are enabled.
Port for the Next.js application server.Example:
Default region code for the storefront.Example:
Backend URL for API calls. Useful when frontend and backend are on different domains.Example:
Payment Providers
Configure payment providers to accept online payments.Stripe
Stripe secret API key. Get this from your Stripe Dashboard.Format: Starts with
sk_test_ (test) or sk_live_ (production)Example:Stripe webhook signing secret for verifying webhook events.Format: Starts with
whsec_Example:Stripe publishable key for client-side operations.Format: Starts with
pk_test_ (test) or pk_live_ (production)Example:PayPal
PayPal REST API client secret.Example:
PayPal client ID for client-side SDK initialization.Example:
Enable PayPal sandbox mode for testing.Options:
true (sandbox), false (production)Example:PayPal webhook ID for verifying webhook signatures.Example:
PayPal API base URL. Override for sandbox testing.Example:
Shipping Providers
Configure shipping providers for rate calculation and label generation.Shippo
Shippo API key for shipping label generation and rate calculation.Format: Starts with Get your API key from Shippo Dashboard.
shippo_test_ (test) or shippo_live_ (production)Example:File Storage (S3-Compatible)
Configure S3-compatible storage for product images and other files.S3 bucket name for file storage.Example:
AWS region for your S3 bucket.Example:
AWS access key ID with S3 permissions.Example:
AWS secret access key.Example:
S3-compatible endpoint URL. Use this for DigitalOcean Spaces, Cloudflare R2, MinIO, etc.Examples:
Email Configuration (SMTP)
Configure SMTP for transactional emails like order confirmations and password resets.SMTP server hostname.Example:
SMTP server port.Common ports:
587 (TLS), 465 (SSL), 25 (unencrypted)Example:SMTP authentication username (usually your email address).Example:
SMTP authentication password or app-specific password.Example:
“From” email address for outgoing emails.Example:
Store URL to include in email templates.Example:
AI Assistant (Optional)
Configure the built-in AI assistant powered by OpenRouter.Model to use for AI assistant.Example:
Maximum tokens for AI responses.Example:
Advanced Configuration
View Order
Custom field ordering for admin dashboard views.Example:
Complete Example
Here’s a complete.env.example file with all variables:
.env.example
Environment-Specific Configuration
- Development
- Production
- Testing
.env.development
Security Best Practices
# Generate 32-byte secret
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Or with OpenSSL
openssl rand -hex 32
.env.development - Local development.env.production - Production deployment.env.test - Automated testingTroubleshooting
Environment variables not loading
Environment variables not loading
Make sure your
.env file is in the project root and properly formatted:NEXT_PUBLIC_ variables not updating
NEXT_PUBLIC_ variables not updating
NEXT_PUBLIC_ variables are embedded at build time. Restart your dev server or rebuild:Payment provider credentials invalid
Payment provider credentials invalid
Double-check:
- Using correct test vs. live keys
- Keys match the environment (test keys in development)
- No extra spaces or line breaks in values
- Webhook secrets match configured endpoints
S3 uploads failing
S3 uploads failing
Verify:
- Bucket exists and is accessible
- Access keys have proper permissions
- Region matches bucket region
- Endpoint URL is correct for S3 alternative
- CORS is configured if using browser uploads
Next Steps
Payment Setup
Configure Stripe or PayPal for payment processing
Shipping Setup
Set up shipping providers and rates
Email Templates
Customize transactional email templates
API Reference
Explore the GraphQL API