Documentation
Database

Environment Variables

Every secret the app reads. Required ones break the build; optional ones gracefully disable a feature.

Required

VariableUsed byNotes
NEXT_PUBLIC_SUPABASE_URLBrowser + serverProject URL.
NEXT_PUBLIC_SUPABASE_ANON_KEYBrowser + serverPublic — safe to ship to client.
SUPABASE_SERVICE_ROLE_KEYServer-onlyBypasses RLS. NEVER expose to the browser. Used in admin routes and the invite flow.

Google stack

VariableUsed by
GOOGLE_CLIENT_IDOAuth flow (/api/auth/google)
GOOGLE_CLIENT_SECRETOAuth flow
GOOGLE_REDIRECT_URIMust match the URI registered in Google Cloud Console (e.g. http://localhost:3000/api/auth/google/callback)
GOOGLE_API_KEYPageSpeed Insights, Places API (GBP reviews)
GOOGLE_ADS_DEVELOPER_TOKENGoogle Ads route
GOOGLE_ADS_LOGIN_CUSTOMER_IDGoogle Ads — sets login-customer-id header (our MCC ID)

GoHighLevel

VariableUsed by
GHL_API_KEYAgency API key. Reads every sub-account.
GHL_AGENCY_IDOptional — used for agency-level GHL endpoints.

Meta

VariableUsed by
META_APP_IDMeta OAuth flow
META_APP_SECRETMeta OAuth + token exchange

n8n / external

VariableUsed by
N8N_WEBHOOK_SECRETBearer auth on POST /api/metrics/external

Optional

VariableEffect when missing
OPENAI_API_KEYAI Insights panel features stay disabled. Reserved for future agent integration.
SLACK_WEBHOOK_URLSubmit Request notifications stop posting to Slack.
Service role key handling
SUPABASE_SERVICE_ROLE_KEY bypasses RLS entirely. It must:
  • Never be prefixed with NEXT_PUBLIC_.
  • Never appear in a 'use client' file.
  • Never be logged to console in production.
  • Be rotated immediately if leaked.

How env vars are loaded

Next.js loads .env.local for development, .env.production.local for production builds, then falls back to .env. We do not check any of these into git. .env.example is the only env file in the repo — keep it up to date when you add a new variable.