• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

257
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 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error