I am having trouble using react-native-config in my React Native app. Here’s my code:
app.js
import Config from 'react-native-config';
console.log(Config);
.env
SECRET_KEY="kndlknv94ii4rpp"
The console.log statement in app.js returns an empty object. What am I doing wrong?
API keys should return on Config.SECRET_KEY but Config object itself returns an empty object
2
Answers
I believe it’s because of your env file format. As in the doc example, they are not using quotation marks. This might be a solution.
Create a new file .env in the root of your React Native app:
Then access variables defined there from your app:
Documentation here.