Environment Variables Reference
Comprehensive reference for all environment variables used across Hyperscape packages.Server (packages/server/.env)
Required (Production)
Database
Server Configuration
Streaming & GPU Rendering
Audio Capture
RTMP Streaming
Stream Recovery
Solana
Arena & Betting
AI Agents
CDN & Assets
Performance
Memory Management
Game URLs
Client (packages/client/.env)
Required
API Endpoints
Development
Plugin Hyperscape (packages/plugin-hyperscape/.env)
LLM Providers
At least one required:Hyperscape Connection
Asset Forge (packages/asset-forge/.env)
AI Services
Server Configuration
Ecosystem Config (ecosystem.config.cjs)
PM2 configuration for production deployment. Reads from environment or provides defaults.
Key Variables
All server variables above, plus:GitHub Secrets (CI/CD)
Required for automated deployments:Vast.ai Deployment
Streaming
Database & Security
Blockchain
Cloudflare
Environment-Specific Configurations
Local Development
Minimal configuration for local development:bun run dev.
Production (Railway)
Production (Vast.ai Streaming)
Variable Precedence
- Environment variables (highest priority)
.envfile in package directory- Default values in code
ecosystem.config.cjs:
Security Best Practices
Never Commit Secrets
Add to.gitignore:
Use GitHub Secrets
For CI/CD, store secrets in GitHub repository settings:- Settings → Secrets and variables → Actions
- Add repository secrets (not environment secrets for better compatibility)
Rotate Secrets Regularly
- JWT_SECRET: Rotate every 90 days
- API keys: Rotate when team members leave
- Stream keys: Rotate if exposed in logs
Generate Secure Secrets
Troubleshooting
Secrets Not Persisting (Vast.ai)
Problem: Stream keys or DATABASE_URL not working after deployment. Cause: Git reset overwrites .env file, or stale environment variables override .env values. Fix: Secrets are now written to/tmp/hyperscape-secrets.env before git reset, then copied back. Verify:
JWT_SECRET Missing Error
Problem: Server throws error on startup: “JWT_SECRET is required in production/staging” Cause: JWT_SECRET not set in production environment. Fix:Stream Keys Not Working
Problem: Streams not appearing on Twitch/Kick/X. Cause: Stale stream keys in environment override .env file values. Fix: The deploy script now explicitly unsets and re-exports stream keys:DATABASE_URL Lost After Git Reset
Problem: Database connection fails after deployment. Cause: Git reset overwrites .env file. Fix: Secrets are now written to/tmp before git reset: