Overview
EpiNeko requires environment variables for Supabase authentication and database connectivity. All variables must be configured before running the application.Required Variables
Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL
NEXT_PUBLIC_SUPABASE_URL
Required: Yes
Type: Public
Description: Your Supabase project URLWhere to find it:
Type: Public
Description: Your Supabase project URL
- Go to your Supabase Dashboard
- Select your project
- Navigate to Settings → API
- Copy the “Project URL”
The
NEXT_PUBLIC_ prefix makes this variable accessible in client-side code.NEXT_PUBLIC_SUPABASE_ANON_KEY
NEXT_PUBLIC_SUPABASE_ANON_KEY
Required: Yes
Type: Public
Description: Your Supabase anonymous/public API keyWhere to find it:
Type: Public
Description: Your Supabase anonymous/public API key
- Go to your Supabase Dashboard
- Select your project
- Navigate to Settings → API
- Copy the “anon public” key under Project API keys
Environment File Setup
Create .env.local
Create a.env.local file in the root of your project:
Example Configuration
.env.local
Variable Usage in Code
Client-Side Usage
Variables prefixed withNEXT_PUBLIC_ are accessible in browser code:
src/utils/supabase/client.ts
Server-Side Usage
Server components and API routes can access all environment variables:src/utils/supabase/server.ts
Middleware Usage
The middleware also accesses public environment variables:src/utils/supabase/middleware.ts
Validation
Runtime Validation
The application validates required environment variables at runtime:Check Before Starting
Verify your configuration before running the app:Deployment Configuration
Vercel
Add variables
Add each variable with appropriate values:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEY
Security Best Practices
Never Commit Secrets
Add
.env.local to .gitignoreUse RLS Policies
Protect data with Row Level Security
Rotate Keys Regularly
Update API keys periodically
Environment Separation
Use different keys for dev/staging/prod
.gitignore Configuration
Ensure your.gitignore includes:
.gitignore
Troubleshooting
Error: Missing Supabase environment variables
Error: Missing Supabase environment variables
Cause: Environment variables are not set or not accessible.Solution:
- Verify
.env.localexists in project root - Check variable names match exactly (case-sensitive)
- Restart development server after adding variables
- Ensure no extra spaces around
=sign
Variables not updating after changes
Variables not updating after changes
Cause: Development server needs restart to load new environment variables.Solution:
- Stop the development server (Ctrl+C)
- Start it again:
npm run dev - Clear Next.js cache if needed:
rm -rf .next
Undefined environment variables in client code
Undefined environment variables in client code
Cause: Variables without
NEXT_PUBLIC_ prefix are not exposed to the browser.Solution:- Ensure all client-side variables have
NEXT_PUBLIC_prefix - Server-only secrets should NOT have this prefix
- Rebuild after adding the prefix
Authentication errors after deployment
Authentication errors after deployment
Cause: Environment variables not configured in deployment platform.Solution:
- Check Vercel/deployment platform settings
- Verify all variables are added
- Ensure correct environment is selected
- Redeploy after adding variables
Additional Configuration
Optional Enhancements
While not currently used, you might want to add these for enhanced functionality:NEXT_PUBLIC_SITE_URL
NEXT_PUBLIC_SITE_URL
- OAuth redirect URLs
- Email confirmation links
- Absolute URL generation
SUPABASE_SERVICE_ROLE_KEY
SUPABASE_SERVICE_ROLE_KEY
- Admin operations
- Bulk data operations
- Bypassing RLS for migrations
Environment Variable Checklist
Use this checklist when setting up a new environment:- Created
.env.localfile in project root - Added
NEXT_PUBLIC_SUPABASE_URLwith correct project URL - Added
NEXT_PUBLIC_SUPABASE_ANON_KEYwith anon key from Supabase - Verified
.env.localis in.gitignore - Restarted development server
- Tested authentication flow
- Configured production environment variables in Vercel
- Verified production deployment works
Related Documentation
Deployment Guide
Deploy with environment variables
Services
Learn how services use variables
Supabase Setup
Initial Supabase configuration