Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda