Importing dotenv the ES6-modules way

The dotenv documentation state that importing dotenv should be done as following:

import * as dotenv from 'dotenv'
dotenv.config()

There is another way loading your custom .env-file into your project immediately:

import 'dotenv/config`

Using dotenv-variables after importing the dotenv/config:

// Destructure process.env object
const { env } = process

// Call your specific .env-variables
env.mySecretVariable
...
env.API_KEY

15 december 2022