Check out example codes for ".env typescript". It will help you in understanding the concepts better.

Code Example 1

npm install dotenv;
 OR 
yarn add dotenv;


import * as dotenv from 'dotenv';

//inside your starter code, do this
...
...
dotenv.config();
...

Learn ReactJs, React Native from akashmittal.com