Skip to main content
VIJ Admin is configured entirely through environment variables. This page documents all available variables, their purposes, and recommended values.

Required Variables

These variables must be set for VIJ Admin to function.

MONGODB_URI

string
required
MongoDB connection string for storing error logs.Format: mongodb://[username:password@]host[:port]/database[?options]Examples:
Connection Options:
  • retryWrites=true - Automatically retry write operations
  • w=majority - Write concern for data durability
  • authSource=admin - Database for authentication
  • ssl=true - Enable SSL/TLS encryption
  • maxPoolSize=50 - Maximum connection pool size
  • minPoolSize=10 - Minimum connection pool size
Never commit this value to version control. Use .env.local (git-ignored) or environment-specific configuration.

NEXT_PUBLIC_BASE_URL

string
required
The public URL where your VIJ Admin dashboard is accessible.Usage: Used for API endpoints, redirects, and client-side routing.Format: Complete URL with protocol (http/https) and domain/port.Examples:
The NEXT_PUBLIC_ prefix makes this variable available in both server and client code.
Update this variable when:
  • Changing domains
  • Moving from development to production
  • Changing ports
  • Adding/removing SSL

Optional Variables

These variables enable additional features or customize behavior.

GEMINI_API_KEY

string
Google Gemini API key for AI-powered error analysis.Get a key: Visit ai.google.dev to create an API key.Example:
Features Enabled:
  • AI error summaries
  • Root cause analysis
  • Suggested fixes
  • Pattern detection
Without this key:
  • VIJ works normally
  • AI features are disabled
  • No error messages shown
Google Gemini offers a generous free tier. Most VIJ installations stay within free limits.

NODE_ENV

string
default:"development"
Node.js environment mode.Values:
  • development - Development mode with debugging enabled
  • production - Production mode with optimizations
  • test - Test mode (used for automated testing)
Examples:
Development
Production
Effects:
Always use NODE_ENV=production for production deployments to enable performance optimizations and security features.

PORT

number
default:"3000"
Port number for the Next.js server.Examples:
Default
Custom Port
Production (Behind Proxy)
When using a reverse proxy (Nginx, Apache), you typically keep this at 3000 and configure the proxy to forward requests.

MONGODB_OPTIONS

string
Additional MongoDB connection options as JSON.Example:
Common Options:
Most applications don’t need custom options. The defaults are optimized for typical usage.

LOG_RETENTION_DAYS

number
default:"90"
Number of days to retain logs before automatic deletion.Examples:
30 Days
1 Year
Disabled (Keep Forever)
Behavior:
  • Logs older than this value are deleted automatically
  • Deletion runs daily at midnight UTC
  • Set to 0 to disable automatic deletion
Longer retention periods increase database size. Monitor storage usage and implement appropriate retention policies.

ENABLE_TELEMETRY

boolean
default:"false"
Enable anonymous usage telemetry for VIJ development.Values: true or falseExamples:
Enabled
Disabled
Data Collected (if enabled):
  • Installation count
  • Feature usage (anonymized)
  • Error rates (aggregate only)
  • No PII or error content
Telemetry helps improve VIJ. All data is anonymous and aggregated. You can disable it anytime.

Environment-Specific Configuration

Development (.env.local)

.env.local

Production (.env.production)

.env.production

Staging (.env.staging)

.env.staging

Platform-Specific Configuration

Vercel

Set environment variables in the Vercel dashboard:
  1. Go to Project SettingsEnvironment Variables
  2. Add variables for each environment (Production, Preview, Development)
  3. Deploy
Required for Vercel:
Vercel automatically sets NODE_ENV=production for production deployments.

Docker

Pass environment variables via Docker run command:
Or use environment file:

Docker Compose

docker-compose.yml

Kubernetes

Use Kubernetes secrets:
Reference in deployment:

Loading Environment Variables

Next.js Built-in Support

Next.js automatically loads:
  • .env.local - All environments (git-ignored)
  • .env.production - Production builds
  • .env.development - Development builds
  • .env - All environments (committed to git)
Priority (highest to lowest):
  1. process.env (system environment)
  2. .env.$(NODE_ENV).local
  3. .env.local (not loaded when NODE_ENV=test)
  4. .env.$(NODE_ENV)
  5. .env
Never commit .env.local files. Use .env.example as a template.

Manual Loading (Node.js)

For scripts or custom tooling:

Environment File Template

Create .env.example for documentation:
.env.example

Security Best Practices

Add to .gitignore:
.gitignore
Prevents accidental quota exhaustion and isolates environments.
  • MongoDB passwords: Every 90 days
  • API keys: Every 180 days
  • Update in all environments
  • Document rotation in runbook
For production:
  • AWS Secrets Manager
  • HashiCorp Vault
  • Azure Key Vault
  • Google Secret Manager
lib/config.ts

Troubleshooting

Issue: Variables are undefined at runtimeSolutions:
  1. Check file name is exactly .env.local (not .env.txt or .env)
  2. Restart dev server after changes
  3. Ensure no typos in variable names
  4. Check .env.local is in project root
  5. For client-side variables, use NEXT_PUBLIC_ prefix
Issue: Client code cannot access environment variablesSolution: Use NEXT_PUBLIC_ prefix
Issue: Invalid connection string formatCommon mistakes:
URL-encode special characters in passwords:
  • @%40
  • :%3A
  • /%2F
  • ?%3F
  • #%23
Issue: Changes to environment variables not reflectedSolution:
  1. Update variables in Vercel dashboard
  2. Trigger a new deployment (redeploy or push commit)
  3. Environment variables are set at build time, not runtime

Next Steps

Dashboard Setup

Complete setup guide for VIJ Admin

Deployment Guide

Deploy VIJ Admin to production

SDK Configuration

Configure the vij-sdk client

Quickstart

Get started with VIJ in minutes