Skip to content

Environment Variables

All variables live in a single .env file at the repository root. Copy .env.example to get started.

These must be set before starting the stack.

VariableUsed byDescription
TWITCH_CLIENT_IDapi, botYour app’s client ID from the Twitch Developer Console
TWITCH_CLIENT_SECRETapiYour app’s client secret (never exposed to the frontend)
TWITCH_BOT_CALLBACK_URIapiFull URL of the bot OAuth callback — e.g. https://your-domain.com/auth/bot/callback
BOT_USER_IDbotTwitch user ID of the bot account (not the broadcaster)
BOT_ACCESS_TOKENbotOAuth access token for the bot account — requires user:bot + user:write:chat scopes
VITE_TWITCH_CLIENT_IDfrontendSame client ID — baked into the SPA at build time
VITE_TWITCH_REDIRECT_URIfrontendFrontend OAuth callback — e.g. https://your-domain.com/auth/twitch/callback
VariableUsed byDescription
DATABASE_URLapi, botFull Postgres connection string — e.g. postgresql://maple:password@postgres:5432/maple
POSTGRES_USERpostgresDatabase username (default: maple)
POSTGRES_PASSWORDpostgresRequired. Database password — choose a strong value
POSTGRES_DBpostgresDatabase name (default: maple)
VariableUsed byDescription
ENCRYPTION_KEYapi, bot64-character hex string — encrypts all stored OAuth tokens. Generate with openssl rand -hex 32
VariableUsed byDescription
FRONTEND_URLapi, botThe public URL of the frontend — used for CORS and OAuth redirects. e.g. https://your-domain.com
VITE_API_URLfrontendThe public URL of the frontend — baked into the SPA. Set to the same value as FRONTEND_URL e.g. https://your-domain.com
VITE_DOC_URLfrontendThe public URL of the docs site — baked into the SPA. e.g. https://docs.your-domain.com
VariableDefaultDescription
LASTFM_API_KEYLast.fm API key — required for !song command and now-playing overlay
API_PORT3099Host port for the API container
FRONTEND_PORT5173Host port for the frontend container
DOCS_PORT4321Host port for the docs container
DB_POOL_MAX10Max Postgres connections in the bot’s pool
DB_IDLE_TIMEOUT_MS30000Idle connection timeout in the bot’s pool
DB_CONNECTION_TIMEOUT_MS5000Timeout when acquiring a connection from the pool
DB_STATEMENT_TIMEOUT_MS10000Max time a single query can run before being cancelled

The BOT_ACCESS_TOKEN is a user token for the bot’s own Twitch account (not a broadcaster token). To obtain one:

  1. Start the API server
  2. Visit https://your-domain.com/bot/token-helper in your browser (or http://localhost:3099/bot/token-helper if testing locally)
  3. Complete the Twitch OAuth flow for the bot account
  4. Copy the displayed BOT_ACCESS_TOKEN=... value into .env

The token requires the user:bot and user:write:chat scopes. It does not expire automatically but can be revoked from the bot account’s Twitch connections page.