When using Vite to bootstrap a react app, the .env
file must be in the same directory as the package.json
and not in the src
directory.
After that, import it with import.meta.env.VITE_API_KEY
P.S: VITE_API_KEY
is the name of the environmental variable you initally created.