Environment variables in Quasar
Posted on 2020-08-30T05:16:57Z by Kevin Foong
Make sure you keep any sensitive information in environment variables such as database passwords and API keys. In Vue you can use the
dotenv package and in Quasar you can use the
quasar-dotenv package which is wrapper around
cd to your project folder and install
npm install quasar-dotenv
Now create a
.env file in your project root and add any variables. For example:
OW_API_KEY = '002db37bfc6be228c33d416df8a6e917'
GM_API_KEY = 'CIzaTyDL6C63jOmI2KCbysrmRSJ_2DriHfFMqZY'
In Quasar you can now access your variables via
.env to ensure it is not pushed to Github.
Also create a
.env.example file in your root folder which is a skeleton file, to give other users an idea of the variables required.