Environment Variables
Environment variables let you store configuration values — API keys, feature flags, backend URLs — separately from your code. They're encrypted at rest and injected into your container at runtime.
Why Use Environment Variables?
- Security — API keys stay out of your source code and GitHub repositories
- Flexibility — change configuration without editing and redeploying code
- Multiple environments — use different values for development vs. production
Adding Environment Variables
- Open your project in AppX
- Go to Project Settings → Environment Variables
- Click Add Variable
- Enter the key and value
- Click Save
After saving, click Push to sync the variables to your running container (see Pushing Variables below).
Naming Convention
Environment variables in Expo must be prefixed with EXPO_PUBLIC_ to be accessible in your app's JavaScript code:
EXPO_PUBLIC_API_URL=https://api.myapp.com
EXPO_PUBLIC_STRIPE_KEY=pk_live_...
EXPO_PUBLIC_FEATURE_DARK_MODE=true
Variables without the EXPO_PUBLIC_ prefix are only available to build processes, not your app's runtime code.
Using Variables in Code
Access environment variables in your app:
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
const stripeKey = process.env.EXPO_PUBLIC_STRIPE_KEY;
The AI can also reference your environment variables when generating code. If you've defined EXPO_PUBLIC_API_URL, you can say in chat: "Fetch user data from the API using the API URL environment variable" and AppX will use it correctly.
Editing Variables
- Go to Project Settings → Environment Variables
- Click the pencil icon on the variable you want to edit
- Update the value
- Click Save
- Click Push to Container
Detecting Variables in Code
AppX can automatically scan your project code for environment variable references that haven't been defined yet.
- Go to Project Settings → Environment Variables
- Click Detect
AppX scans all your project files for process.env.EXPO_PUBLIC_* references and lists any variables that are used in code but not yet defined. You can add them directly from the detection results.
This is especially useful after AI generation — the AI may reference environment variables that you haven't set up yet. Running Detect ensures nothing is missing.
Pushing Variables to the Container
After adding or editing variables, click Push to sync them to your running container. The container restarts briefly (3–5 seconds) to load the new values.
The Push button syncs all environment variables to the container at once. You can make multiple changes and push them in a single action rather than pushing after each edit.
Deleting Variables
Click the trash icon next to a variable and confirm. Push to container to apply.
Deleting a variable that your code references will cause runtime errors. Check where the variable is used in your code before deleting it.
Encryption
All environment variable values are encrypted at rest using AES-256. Values are never stored in plain text in AppX's database. They're decrypted only when injected into your container at startup.
Variable values are masked in the AppX UI — they show as •••••••• by default. Click the eye icon to reveal.
Best Practices
Do use env vars for:
- API keys and tokens
- Backend URLs that differ between environments
- Feature flags
- Third-party service credentials (Firebase, Stripe, Sentry, etc.)
Don't use env vars for:
- Large configuration objects (use a config file instead)
- Data that changes at runtime (use app state or a database)
Environment Variables and GitHub
If you've connected a GitHub repository, your environment variables are not pushed to the repo. They stay in AppX. When someone clones the project, they'll need their own values for sensitive keys.
For shared work, document the required variable names (but not values) in your README.