Overview
Mizen requires several environment variables to be configured for full functionality. This guide covers all required and optional environment variables.Environment Files
Mizen uses different environment files for different deployment environments:.env.local- Local development (not committed to git).env.development.local- Development-specific overrides.env.test.local- Testing environment.env.production.local- Production-specific overrides
Required Environment Variables
Groq API Key
The Groq API is used for AI-powered recipe parsing and ingredient extraction.Create a Groq account
Sign up at https://console.groq.com/
Accept model terms
If you encounter a “model_terms_required” error, visit the model playground to accept the terms for the models you plan to use.
Supabase Configuration
Supabase is used for database operations and authentication..env.local
How to get Supabase credentials
How to get Supabase credentials
- Create a project at https://supabase.com
- Navigate to Settings > API
- Copy the Project URL for
NEXT_PUBLIC_SUPABASE_URL - Copy the anon/public key for
NEXT_PUBLIC_SUPABASE_ANON_KEY - Copy the service_role key for
SUPABASE_SERVICE_ROLE_KEY
Optional Environment Variables
Notion Integration (Feedback System)
If you want to enable the feedback system that sends data to Notion:.env.local
Setting up Notion integration
Setting up Notion integration
- Create a Notion integration at https://www.notion.so/my-integrations
- Copy the Internal Integration Token for
NOTION_API_KEY - Create a database in Notion for feedback
- Share the database with your integration
- Copy the database ID from the URL for
NOTION_FEEDBACK_DATABASE_ID
Application Versioning
.env.local
Deployment Environment
.env.local
Complete Example
Here’s a complete.env.local file template:
.env.local
Environment Variable Usage
Client-Side vs Server-Side
Next.js handles environment variables differently based on their prefix:Client-Side
Variables prefixed with
NEXT_PUBLIC_ are exposed to the browser.Server-Side
Variables without the prefix are only available on the server.
Validating Your Setup
After configuring your environment variables:Check for missing variables
The application will log errors in the console if required environment variables are missing.
Troubleshooting
Groq API errors
Groq API errors
Error:
GROQ_API_KEY is not configuredSolution: Ensure the GROQ_API_KEY is set in your .env.local file and the server has been restarted.Error: model_terms_requiredSolution: Visit https://console.groq.com/playground and accept the terms for the models being used.Supabase connection issues
Supabase connection issues
Error:
Invalid Supabase URL or authentication failuresSolution:- Verify the URL format:
https://your-project.supabase.co - Check that the anon key and service role key match your project
- Ensure Row Level Security policies are configured correctly
Environment variables not loading
Environment variables not loading
Issue: Changes to
.env.local not taking effectSolution:- Restart the Next.js development server completely
- Clear
.nextcache:rm -rf .next - Verify the file is named exactly
.env.local(not.env.local.txt) - Check that the file is in the project root directory
Security Best Practices
Use Strong Keys
Generate cryptographically secure API keys and rotate them regularly.
Limit Permissions
Use the minimum permissions necessary. For example, use anon keys for client-side Supabase access.
Never Commit Secrets
Always add
.env* files to .gitignore to prevent accidental commits.Use Different Keys
Use separate API keys for development, staging, and production environments.
Next Steps
Installation
Install dependencies and set up your development environment
Docker Setup
Deploy Mizen using Docker containers