I am wanting to access the env config from next.config.js in order to surface some env vars set in .env.local and set some server runtime config based on them.
Is it reasonable in next.config.js to do...
const { loadEnvConfig } = require("@next/env");
const env = loadEnvConfig(".").combinedEnv;
It works, but I can't find any docs that explain how to do this, or if it's a supported package/api.
As documented here: https://nextjs.org/docs/basic-features/environment-variables#test-environment-variables
When you run loadEnvConfig it actually updates process.env to include config that next js uses, so this should work...
const { loadEnvConfig } = require("@next/env");
loadEnvConfig(".")
// process.env.SOMETHING <~~ includes value of SOMETHING set in .env.local