Note To Self — How To Hide API Key in React
NOTES.
- npm install dotenv
2. At the top of the js file write require(‘dotenv’).config()
1 and 2 are not needed in React framework.


create .env file in root file
Must have REACT_APP in the beginning for React framework
Variable Name has to be All CAPS
Key doesn’t need to be wrapped in string
REACT_APP_VariableName=Key
REACT_APP_ZOMATO_API_KEY=123456789

create .gitignore file in root file
add the .env to the .gitignore, so it doesn’t get push up to github.

In place of the API key, write process.env.REACT_APP_ZOMATO_API_KEY
The whole thing is a variable for the key 123456789

After making changes to .env file restart the server.
ctrl+c and then npm start