I suggest you use the npm package dotenv.
You create a .env file in the root of your repository, and this package helps your project access any variable that's inside your .env file. You just need to:
npm install dotenv
Then you add this line to your App.js
require('dotenv').config()
and you're good to go!
Example:
> cat .env
DB_HOST="https://myserver.herokuapp.com"
To access the variable's name, you just have to call process.env.DB_HOST in your code.
NOTE:
If your project has been created using create-react-app, then you must name the variables like this:
REACT_APP_DB_HOST="https://myserver.herokuapp.com"
and if you want to access it you use:
process.env.REACT_APP_DB_HOST