Overview
Environment variables are used to configure the application for different environments (development, staging, production) without changing code. They are typically stored in.env files.
Environment variables prefixed with
NEXT_PUBLIC_ are exposed to the browser. All other variables are only available on the server side.API Configuration
NEXT_PUBLIC_API_URL
Base URL for the backend API.string
required
The base URL for all API requests
Example Values
NEXT_PUBLIC_API_VERSION
API version to use.string
API version identifier (default: “v1”)
Example
API_TIMEOUT
Request timeout in milliseconds.number
Maximum time to wait for API responses (default: 30000)
Example
Authentication
NEXT_PUBLIC_AUTH_ENABLED
Enable or disable authentication.boolean
Whether authentication is required (default: true)
Example
JWT_SECRET
Secret key for JWT token signing (server-side only).string
required
Secret key used to sign and verify JWT tokens
Example
SESSION_SECRET
Secret for session encryption (server-side only).string
required
Secret key for encrypting session data
Example
TOKEN_EXPIRY
JWT token expiration time.string
Token expiration duration (default: “1h”)
Example
OAuth Providers
GOOGLE_CLIENT_ID
Google OAuth client ID.string
Client ID from Google Cloud Console
GOOGLE_CLIENT_SECRET
Google OAuth client secret (server-side only).string
Client secret from Google Cloud Console
Example
GITHUB_CLIENT_ID
GitHub OAuth client ID.string
Client ID from GitHub OAuth App
GITHUB_CLIENT_SECRET
GitHub OAuth client secret (server-side only).string
Client secret from GitHub OAuth App
Example
Database
DATABASE_URL
Database connection string (server-side only).string
required
Full database connection URL
Example
Analytics & Tracking
NEXT_PUBLIC_GA_ID
Google Analytics tracking ID.string
Google Analytics measurement ID (e.g., G-XXXXXXXXXX)
Example
NEXT_PUBLIC_SEGMENT_KEY
Segment analytics write key.string
Segment write key for analytics
Example
Feature Flags
NEXT_PUBLIC_ENABLE_BETA_FEATURES
Enable beta/experimental features.boolean
Toggle beta features (default: false)
NEXT_PUBLIC_ENABLE_ANALYTICS
Enable analytics tracking.boolean
Toggle analytics (default: true)
NEXT_PUBLIC_ENABLE_NOTIFICATIONS
Enable push notifications.boolean
Toggle notifications (default: true)
Example
File Storage
AWS_S3_BUCKET
AWS S3 bucket name (server-side only).string
S3 bucket for file storage
AWS_ACCESS_KEY_ID
AWS access key ID (server-side only).string
AWS IAM access key
AWS_SECRET_ACCESS_KEY
AWS secret access key (server-side only).string
AWS IAM secret key
AWS_REGION
AWS region.string
AWS region (e.g., us-east-1)
Example
Email Service
SMTP_HOST
SMTP server hostname (server-side only).string
SMTP server address
SMTP_PORT
SMTP server port (server-side only).number
SMTP port (typically 587 or 465)
SMTP_USER
SMTP username (server-side only).string
SMTP authentication username
SMTP_PASSWORD
SMTP password (server-side only).string
SMTP authentication password
FROM_EMAIL
Default sender email address.string
Email address to send from
Example
Application Settings
NODE_ENV
Current environment.'development' | 'staging' | 'production'
required
Application environment
PORT
Server port.number
Port for the application server (default: 3000)
NEXT_PUBLIC_APP_URL
Public application URL.string
required
Full URL where the app is hosted
Example
Usage in Code
Accessing Environment Variables
Environment Files
File Structure
The
.env.local file takes precedence over other environment files and should never be committed to version control.