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.The base URL for all API requests
Example Values
NEXT_PUBLIC_API_VERSION
API version to use.API version identifier (default: “v1”)
Example
API_TIMEOUT
Request timeout in milliseconds.Maximum time to wait for API responses (default: 30000)
Example
Authentication
NEXT_PUBLIC_AUTH_ENABLED
Enable or disable authentication.Whether authentication is required (default: true)
Example
JWT_SECRET
Secret key for JWT token signing (server-side only).Secret key used to sign and verify JWT tokens
Example
SESSION_SECRET
Secret for session encryption (server-side only).Secret key for encrypting session data
Example
TOKEN_EXPIRY
JWT token expiration time.Token expiration duration (default: “1h”)
Example
OAuth Providers
GOOGLE_CLIENT_ID
Google OAuth client ID.Client ID from Google Cloud Console
GOOGLE_CLIENT_SECRET
Google OAuth client secret (server-side only).Client secret from Google Cloud Console
Example
GITHUB_CLIENT_ID
GitHub OAuth client ID.Client ID from GitHub OAuth App
GITHUB_CLIENT_SECRET
GitHub OAuth client secret (server-side only).Client secret from GitHub OAuth App
Example
Database
DATABASE_URL
Database connection string (server-side only).Full database connection URL
Example
Analytics & Tracking
NEXT_PUBLIC_GA_ID
Google Analytics tracking ID.Google Analytics measurement ID (e.g., G-XXXXXXXXXX)
Example
NEXT_PUBLIC_SEGMENT_KEY
Segment analytics write key.Segment write key for analytics
Example
Feature Flags
NEXT_PUBLIC_ENABLE_BETA_FEATURES
Enable beta/experimental features.Toggle beta features (default: false)
NEXT_PUBLIC_ENABLE_ANALYTICS
Enable analytics tracking.Toggle analytics (default: true)
NEXT_PUBLIC_ENABLE_NOTIFICATIONS
Enable push notifications.Toggle notifications (default: true)
Example
File Storage
AWS_S3_BUCKET
AWS S3 bucket name (server-side only).S3 bucket for file storage
AWS_ACCESS_KEY_ID
AWS access key ID (server-side only).AWS IAM access key
AWS_SECRET_ACCESS_KEY
AWS secret access key (server-side only).AWS IAM secret key
AWS_REGION
AWS region.AWS region (e.g., us-east-1)
Example
Email Service
SMTP_HOST
SMTP server hostname (server-side only).SMTP server address
SMTP_PORT
SMTP server port (server-side only).SMTP port (typically 587 or 465)
SMTP_USER
SMTP username (server-side only).SMTP authentication username
SMTP_PASSWORD
SMTP password (server-side only).SMTP authentication password
FROM_EMAIL
Default sender email address.Email address to send from
Example
Application Settings
NODE_ENV
Current environment.Application environment
PORT
Server port.Port for the application server (default: 3000)
NEXT_PUBLIC_APP_URL
Public application URL.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.