Manage environment variables with split .env.client and .env.api structure. Use when adding new env vars, debugging config issues, or setting up environments.
This project uses split env files (see docs/PRDs/env-system-refactor.md):
| File | Purpose | Prefix |
|---|---|---|
.env.client | Public browser vars | NEXT_PUBLIC_* |
.env.api | Server secrets | No prefix |
.env.client:
NEXT_PUBLIC_API_URL=https://api.example.com
const url = process.env.NEXT_PUBLIC_API_URL;
.env.api:
STRIPE_SECRET_KEY=sk_live_xxx
// Only in app/api/*, server/*, or Server Components
const key = process.env.STRIPE_SECRET_KEY;
.env.clientNEXT_PUBLIC_Copy example files:
cp .env.client.example .env.client
cp .env.api.example .env.api
Set vars in Cloudflare Pages dashboard under Settings > Environment Variables.