I would like to use an api key stored in an environment variable. I know I can just put it directly in the html (I don't think it is bad security wise since it is a public key). But I can't get access it an my react component.
useEffect(()=>{
SetRecaptchaKey(import.meta.env.VITE_SITE_RECAPTCHA_KEY);
console.log(recaptchaKey)
});
outside my component function (above) I have this:
const key = import.meta.env;
console.log(key)
it logs the object in the console, and it has the variable i'm looking for.
Another thing, is that I have two VITE_... variables and another variable. Only one of VITE_.. is loaded (which is what I want) but I don't understand why.
Thanks in advance