Environment Configuration
Environment variables and configuration for VidsGenius
Environment Variables and Configuration
This document outlines the environment variables used in VidsGenius, including validation, requirements, and common issues.
Environment Configuration System
VidsGenius uses the @t3-oss/env-nextjs package to strongly validate environment variables at build time, ensuring type safety and preventing deployment issues caused by misconfigured variables.
Core Environment Variables
Authentication Variables
AUTH_SECRET- Secret for Next-AuthGOOGLE_CLIENT_ID- Google OAuth client IDGOOGLE_CLIENT_SECRET- Google OAuth client secret
Database
DATABASE_URL- Connection string for Postgres database
RESEND_API_KEY- API key for Resend email serviceEMAIL_FROM- Sender email address
Stripe
STRIPE_API_KEY- Secret API key for StripeSTRIPE_WEBHOOK_SECRET- Webhook signing secretNEXT_PUBLIC_STRIPE_*_PLAN_ID- Public plan IDs for various subscription tiers
Feature Flags
BETA_MODE- Enables beta features and restrictions ("true" or "false")MAINTENANCE_MODE- Enables maintenance mode ("true" or "false")
Common Environment Variable Issues
Boolean Environment Variables
For boolean flags like BETA_MODE and MAINTENANCE_MODE, the values must be the strings "true" or "false" (lowercase). The validation will fail if you use:
- Uppercase versions:
"TRUE"or"FALSE"❌ - Actual boolean values:
trueorfalse❌ - Numbers:
1or0❌
Our validation now includes preprocessing to handle uppercase variants, but it's best practice to use the lowercase string values.
Deployment Provider Configuration
When setting environment variables in deployment providers like Vercel:
- Ensure string values don't have extra quotes
- Use lowercase
"true"and"false"for boolean flags - Check that all required variables are set
Validation Schema
The application uses Zod to validate environment variables at build time:
// Example of our validation for feature flags
BETA_MODE: z.preprocess(
(val) => val === "TRUE" ? "true" : val === "FALSE" ? "false" : val,
z.enum(["true", "false"]).optional().default("false")
),This schema ensures that:
- The value is either "true" or "false"
- It's optional, defaulting to "false" if not provided
- Uppercase variants are automatically converted to lowercase
Local Development
For local development:
- Create a
.env.localfile with the required variables - Never commit
.env.localto version control - Use the
.env.examplefile as a reference