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

345
Views
how to set heroku env variables to appear in NextJS app?

Somewhat unfamiliar ground for me, but I'm trying to set a banner on my page that says "Current Env: REVIEW" or "Current Env: STAGING" depending on what phase of my deployment process I'm on in Heroku.

Currently, I have environment variables on Heroku like this: CURRENT_ENV: REVIEW. However, when I try to access the variables with the logic below, they come up as undefined in my deployed app. I'm curious what the proper approach is to get these variables set up correctly so my app has the ability to detect whether it's in review or staging.

_app.ts

  const getCurrentEnv = (): string => {
    console.log(process.env.NEXT_PUBLIC_CURRENT_ENV, process.env.CURRENT_ENV);
    // while deployed on heroku logs: PRODUCTION, undefined

    return process.env.NEXT_PUBLIC_CURRENT_ENV === 'DEVELOPMENT'
      ? process.env.NEXT_PUBLIC_CURRENT_ENV
      : process.env.CURRENT_ENV;
  };

.env.production

NEXT_PUBLIC_CURRENT_ENV="PRODUCTION"

.env.development

NEXT_PUBLIC_CURRENT_ENV="DEVELOPMENT"
about 4 years ago · Juan Pablo Isaza
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!