Can REACT read windows environment variables?

Viewed 25

enter image description here

Hi guys,

Can REACT read windows environment variables? I know that it wouldn't be best practices and I should be using the .env file but this seems like something I should be able to make my application do and unfortunately all the google is around using the .env file which is how I am going to do it in the end but I would still like to know the answer here.

Thanks guys.

1 Answers

React doesn't know anything about environment variables; it's a library that runs in an HTML page in your browser. (HTML and JavaScript don't know anything about environment variables, for that matter, and that's only a good thing.)

The bundler/toolchain you use may schlep some environment variables over to the JavaScript code, e.g.

All of the above-linked tools support reading environment variables from, well, the environment, as well as .env files (commonly known as envfiles).

Related