Configure OpenCouncil with environment variables for database, API keys, and service integrations
OpenCouncil uses environment variables to configure database connections, API keys, and external service integrations. This guide covers all required and optional environment variables.
Copy the example environment file to create your configuration:
cp .env.example .env
Then edit .env to add your specific values.
The .env.example file contains safe defaults for local development. Variables with defaults are not listed in the example file. See the full environment reference for all available options.
OpenCouncil requires PostgreSQL 14+ with the PostGIS extension for geospatial features.
OpenCouncil uses two connection strings to support connection pooling in production:
# Automatically set by development tools (Nix/Docker)DATABASE_URL="postgresql://opencouncil@localhost:5432/opencouncil?sslmode=disable"DIRECT_URL="postgresql://opencouncil@localhost:5432/opencouncil?sslmode=disable"
When using local databases via Nix or Docker, the development tools automatically override DATABASE_URL and DIRECT_URL with the correct local values. You can keep your .env configured for remote databases.
# Base URL for the application (used for authentication callbacks)NEXTAUTH_URL=http://localhost:3000# Secret for NextAuth.js session encryption# Generate with: openssl rand -base64 32NEXTAUTH_SECRET=your_generated_secret_here
Always generate a unique NEXTAUTH_SECRET for production deployments. Never commit secrets to version control.
OpenCouncil validates environment variables at startup using t3-env. If required variables are missing or invalid, the application will fail to start with a clear error message.Validation schema: src/env.mjs