Jet
BuyFollow on X
  • Home
  • Satisfied Requirements
  • License
  • Architecture
    • Overview
    • Internal Dependency Graph
    • External Dependencies
    • Conventions
  • Recipes
    • Get Started
    • Add a Page
    • Customise Fonts
    • Customise Icons
    • Customise Languages
    • Customise Themes
    • Add an Environment Variable
  • Classes
    • Jet Mat Paginator Intl
    • Transloco HTTP Loader
  • Components
    • App Component
    • Footer Component
    • Home Page Component
    • Message Page Component
    • Not Found Page Component
    • Page Component
    • Profile Page Component
    • Reset Password Page Component
    • Settings Page Component
    • Sign In Page Component
    • Sign Out Page Component
    • Sign Up Page Component
    • Update Password Page Component
  • Constants
    • Color Scheme Options
    • Default Color Scheme Option
    • Default Language Option
    • Default Settings
    • Language Options
    • Navigation Menu Items
  • Directives
    • Analytics Directive
  • Enums
    • Bucket
    • LocalStorage Key
    • Query Param
    • SessionStorage Key
    • Table
  • Guards
    • Is Authenticated
    • Is Not Authenticated
  • Interfaces
    • Color Scheme Option
    • Language Option
    • Navigation Menu Item
    • Profile
    • Progress Bar Configuration
    • Settings
  • Services
    • Alert Service
    • Analytics Service
    • Logger Service
    • Profile Service
    • Progress Bar Service
    • Service Worker Service
    • Settings Service
    • Storage Service
    • Supabase Service
    • Toolbar Title Service
    • User Service
  • Types
    • Available Color Scheme
    • Available Font
    • Available Language
    • Available OAuth Provider
Powered by GitBook
On this page

Was this helpful?

  1. Recipes

Add an Environment Variable

PreviousCustomise ThemesNextJet Mat Paginator Intl

Last updated 8 months ago

Was this helpful?

Jet uses , 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:

env.d.ts
declare interface Env {
  readonly NG_APP_BASE_URL: string; // Add
  readonly NODE_ENV: string;
}

declare interface ImportMeta {
  readonly env: Env;
}

Step 2: Add it to /.env:

.env
NG_APP_BASE_URL=https://example.com/api

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.

@ngx-env/builder
Environment variable in CI pipeline
Environment variable in CI pipeline