Advanced

dotenvx.config(path: directory, convention: 'nextjs')

Use a directory as the base for convention files.

This is useful when loading a workspace's env files from a monorepo root.

// index.js
require('@dotenvx/dotenvx').config({
  path: 'apps/web',
  convention: 'nextjs'
})

The directory becomes the base for every file in the convention:

apps/web/.env.development.local
apps/web/.env.local
apps/web/.env.development
apps/web/.env

Without a convention, a directory path loads the .env inside it:

require('@dotenvx/dotenvx').config({
  path: 'apps/web'
})