Add an Environment Variable
Last updated
Last updated
Jet uses @ngx-env/builder, which automatically exposes environment variables prefixed with NG_APP_
.
Let's say you want to add an environment variable BASE_URL
. We'll add the required prefix and name it NG_APP_BASE_URL
.
Step 1: Add it to the Env
interface:
Step 2: Add it to /.env
:
Step 3: Add it to your CI pipeline:
Step 4: Access it using import.meta.env.NG_APP_BASE_URL ?? ''
. Always provide a fallback value to prevent your app from crashing when an environment variable isn't found.