Open kibolho opened 8 months ago
I use dotenv on most projects, as it's way more customizable than Expo's default env loading. You can use it to change environments dynamically; it's a breeze. EXPO_PUBLIC_
prefixing didn't ever entirely do the job for me anyway.
Here's a good article on it: https://elazizi.com/posts/environment-variables-in-react-native-the-right-way/
This does seem to be a Babel plugin on Expo itself, doing the environment resolution. It makes me think this package would resolve correctly if you're prefixing.
Can you send some snippets on how this is being used? As long as you have babel-preset-expo
installed, I'm confident you should be getting envs correctly.
I was using the env variables in eas.json:
"production": {
"env": {
"EXPO_PUBLIC_API_BASE_URL": "my_base_url"
}
}
And then using it as:
export const API_BASE_URL = process.env.EXPO_PUBLIC_API_BASE_URL;
And I also have babel-preset-expo
installed.
But it didn't work with remote updates because it doesn't read the eas.json. I will test using it with .env files and reading it via dotenv. Thanks! @GSTJ
Is there a way to directly use expo. env? Currently, my project heavily relies on expo. env @GSTJ
Hey @GSTJ thanks for this package! This is not this package's fault, but it is related to what this package sets out to solve. The package works perfectly, but when I try to add environment variables both in the .env and within the app.json, the bundle generated by the app center CLI does not resolve the variables. Any ideas what can be done?
Trying to bundle with this command:
Since we are not using expo-cli to create the bundle maybe we need to add the env variable in a different way: https://github.com/lugg/react-native-config/issues/249