How to use dotenv to create environment variables
Everyone knows how much GitHub important for us, it gives a lot of benefits for software engineering, for push our grefat applications and keep them safe. But that’s will be so risky to push your credentials to GitHub especially if you have public repository, because everyone can have access to this sensitive information and can be used, for example google Api key. Well there’s a solution for that and we can see that in this article by using this dotenv
What is dotenv
Dotenv give access to environment variables by loading all sensitive keys in our environment into process.en.
Lets install dotenv so we can use it.
# with npm
npm install --save dotenv# or with Yarn
yarn add dotenv
Now after we installed dotenv, its time to create a file .env
in root directory of our application.
In our .env
file we can add all variables with sensitive keys as value=key
and use them in our application.
Now we have access to FIRST_NAME
variable loaded from our environment, Let’s check it and see to call that environment.