Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

274
Views
Can I use @next/env package in next.config.js?

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!