Closed rockstar00711 closed 2 years ago
Hello. I am gonna set some environment variables something like API key. I am using expo and babel.
I have followed expo documentation but no luck. https://docs.expo.dev/guides/environment-variables/#from--babelconfigjs
I would appreciate if anybody has advice about this. Here is my babel.config.js Thanks.
//babel.config.js module.exports = function(api) { api.cache(true); return { presets: [‘babel-preset-expo’], plugins: [ [ “module-resolver”, { “extensions”: [ “.js”, “.ts”, “.tsx”, “.css” ], “root”: [ “./src” ], “alias”: { “assets”: “./src/assets”, “type”: “./src/type”, } }, ], [ “inline-dotenv”, { path: ‘.env’ } ] ] }; }; //.env API_KEY=something //const.js export const THIRDPARTY = { api_key: process.env.API_KEY, } //home.js useEffect(() => { console.log("env_api_key", THIRDPARTY.api_key); ////////undefined/////// })
Hey @rockstar0711 - stackoverflow might be a better place for this question
Hello. I am gonna set some environment variables something like API key. I am using expo and babel.
I have followed expo documentation but no luck. https://docs.expo.dev/guides/environment-variables/#from--babelconfigjs
I would appreciate if anybody has advice about this. Here is my babel.config.js Thanks.