Docs
Environment Configuration

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-Auth
  • GOOGLE_CLIENT_ID - Google OAuth client ID
  • GOOGLE_CLIENT_SECRET - Google OAuth client secret

Database

  • DATABASE_URL - Connection string for Postgres database

Email

  • RESEND_API_KEY - API key for Resend email service
  • EMAIL_FROM - Sender email address

Stripe

  • STRIPE_API_KEY - Secret API key for Stripe
  • STRIPE_WEBHOOK_SECRET - Webhook signing secret
  • NEXT_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: true or false
  • Numbers: 1 or 0

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:

  1. Ensure string values don't have extra quotes
  2. Use lowercase "true" and "false" for boolean flags
  3. 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.local file with the required variables
  • Never commit .env.local to version control
  • Use the .env.example file as a reference