.env.local cho local development (git-ignored). .env.production, .env.development cho môi trường cụ thể. NEXT_PUBLIC_ prefix expose biến xuống client bundle - KHÔNG đặt secrets với prefix này.
- Không có prefix: chỉ server-side.
- Trong App Router: server components đọc trực tiếp
process.env.VAR. - Client: chỉ NEXT_PUBLIC_ vars.
.env.local is for local development and is git-ignored. .env.production and .env.development are for specific environments.
- The
NEXT_PUBLIC_prefix exposes a variable to the client bundle — never put secrets there. - Variables without the prefix are server-side only.
- In the App Router, Server Components read
process.env.VARdirectly. - On the client, only
NEXT_PUBLIC_variables are available.