Skip to content

Loading Environment Variables with dotenv

At wakeflow, we adopt a standardized approach to loading environment variables in our front-end and back-end development. For managing environment variables, we utilize the dotenv package, which offers a simple and efficient solution. In this guide, we'll explore how dotenv enables us to load environment variables seamlessly and maintain consistency across our projects.


To start using dotenv, you can install it using npm or yarn:

npm i dotenv


yarn add dotenv


Create a .env file in the root directory of your project.

Define your environment variables in the .env file using the KEY=VALUE syntax. For example:


In Node.js ONLY, import and declare the following in app.js in order for your project to have access to environment variables. No need to do this step in React.js

import dotenv from 'dotenv';

To use an enviroment variables in Node.js and React.js use:

const apiKey = process.env.API_KEY


If you have any questions about this process, reach out to