Add environment variable
This is how we add environment variables to the project:
Add to .env.example:
NEW_VARIABLE=value_example
Add to apps/web/env.ts:
// For server-only variables
server: {
NEW_VARIABLE: z.string(),
}
// For client-side variables
client: {
NEXT_PUBLIC_NEW_VARIABLE: z.string(),
}
experimental__runtimeEnv: {
NEXT_PUBLIC_NEW_VARIABLE: process.env.NEXT_PUBLIC_NEW_VARIABLE,
}
For client-side variables:
NEXT_PUBLIC_client and experimental__runtimeEnv sectionsAdd to turbo.json under globalDependencies:
{
"tasks": {
"build": {
"env": [
"NEW_VARIABLE"
]
}
}
}