- CommonJS
npm install dotenv
const dotenv = require("dotenv").config();
const apiKey = process.env.API_KEY;
- ModuleJS (ES6)
npm install dotenv
import dotenv from "dotenv";
dotenv.config();
const apiKey = process.env.API_KEY;
- CommonJS
npm install dotenv
const dotenv = require("dotenv").config();
const apiKey = process.env.REACT_APP_API_KEY;
- ModuleJS
npm install dotenv
import dotenv from "dotenv";
dotenv.config();
const apiKey = process.env.REACT_APP_API_KEY;
- ModuleJS
const { VITE_API_KEY } = import.meta.env;
const apiKey = VITE_API_KEY;