Categories
Uncategorized

Get environmental variables in NextJs

NextJS has a built-in support for environmental variables. This is how they do it

import { loadEnvConfig } from '@next/env';
const { API_URL } = loadEnvConfig('./', true).combinedEnv

This is useful for when you need to manually access what’s in those .env.* files.