Skip to main content

Environment Variables

Required Environment Variables

Ensure all environment variables are configured in Vercel DashboardSettingsEnvironment Variables:

Supabase (Next.js app)

NEXT_PUBLIC_SUPABASE_URL
NEXT_PUBLIC_SUPABASE_ANON_KEY
SERVICE_ROLE_KEY # service role; server-only
SUPER_ADMIN_TEAM_ID # team id of the super-admin team; server-only, hydrated to TeamsContext
DIRECTUS_API_EMAIL_SEARCH
DIRECTUS_API_PASSWORD_SEARCH
DIRECTUS_URL_SEARCH

The voter-search route also accepts per-request credential keys (credentials.{name, emailKey, passwordKey, endpointKey}) so a different Directus tenant can be addressed by adding any extra DIRECTUS_API_* env vars and passing the env var names in the request body.

Redis (Upstash)

REDIS_URL                       # rediss://default:<password>@<host>:<port>

Supabase Edge Functions

Set via the Supabase CLI (supabase secrets set …) or in the Supabase dashboard. Required by the various functions under supabase/functions/**:

# All edge functions
SUPABASE_URL
SUPABASE_ANON_KEY
SUPABASE_SERVICE_ROLE_KEY

# send-email
SMTP_HOST
SMTP_PORT
SMTP_USERNAME
SMTP_PASSWORD
SMTP_SENDER_EMAIL
SMTP_SENDER_NAME

# sync-to-redis
REDIS_URL

Setting Environment Variables in Vercel

  1. Go to Vercel Dashboard → Your Project
  2. Navigate to SettingsEnvironment Variables
  3. Add each variable for the appropriate environments:
    • Production (main branch)
    • Preview (all branches)

Environment Variable Best Practices

Do:

  • Set variables for all environments
  • Use different credentials for dev/staging/production
  • Keep SERVICE_ROLE_KEY secure (never commit)
  • Test with production-like values in staging

Don't:

  • Commit .env.local files
  • Use production credentials in development
  • Share environment variables in code or PRs