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

172
Views
Cannot reach key from .env file

I'm on React.Js and using emailjs to manage contact form. In order to sends the form, I must fill the user-id and template-id. But I don't want it to be visible so I put it on the .env file like that:

REACT_APP_USER_ID= user_id
REACT_APP_TEMPLATE_ID= template_id

To pass these values easely in the sendForm() property, I've put them on variables : (useContact.jsx)

const template = REACT_APP_TEMPLATE_ID
const user = REACT_APP_USER_ID

But unfortunately with this config the form is not sent.

my folder architecture [.env, package.json, .gitignore, src/Components/Contact/useContact.jsx]

It works when pass the raw version of the values.

Thank You.

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

0

You can access the environment variables by accessing process.env variable like this

const template = process.env.REACT_APP_TEMPLATE_ID
const user = process.env.REACT_APP_USER_ID

Note: you have to restart the server after updating .env file

about 4 years ago · Juan Pablo Isaza Report

0

Env variables are accessible through process.env

It depends how are you loading your .env file, I would suggest you to take a look at dotenv package in order to load your env files

An example you could follow it's the one from this stackoverflow answer

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!