A sample Next.js application demonstrating environment variable management for ServerCompass deployments.
This demo project showcases how to:
- Use environment variables in Next.js applications
- Display configuration values on the frontend
- Manage public vs. private environment variables
- Deploy applications with ServerCompass
The application uses the following environment variables:
These variables are prefixed with NEXT_PUBLIC_ and are exposed to the browser:
NEXT_PUBLIC_APP_NAME- Application nameNEXT_PUBLIC_API_URL- API endpoint URLNEXT_PUBLIC_ENVIRONMENT- Deployment environment (production, staging, development)NEXT_PUBLIC_VERSION- Application version
These are NOT exposed to the browser:
DATABASE_URL- Database connection stringAPI_SECRET_KEY- Secret key for API authentication
-
Clone and install dependencies:
cd servercompass-demo npm install -
Set up environment variables:
cp .env.example .env
Then edit
.envwith your actual values. -
Run the development server:
npm run dev
-
Open your browser:
Navigate to http://localhost:3000 to see the application displaying your environment variables.
servercompass-demo/
├── app/
│ ├── page.tsx # Main homepage displaying env vars
│ ├── layout.tsx # Root layout
│ └── globals.css # Global styles
├── .env # Environment variables (git-ignored)
├── .env.example # Environment variables template
└── package.json
- Visit ServerCompass
- Connect your repository
- Configure your environment variables
- Deploy
Alternatively, deploy with Vercel:
npm run buildCheck out the Next.js deployment documentation for more details.
- Next.js Documentation - Learn about Next.js features and API
- ServerCompass - Server deployment and management
- Environment Variables in Next.js