How to access environment variables in a react component?

This article is almost certainly the answer to your question:

If not, could you tell us more about how you are trying to use that value? That javascript looks fine, assuming that:

  1. you have that variable set during build
  2. that code RUNS during build (not, say, at browse time - where that is just a string, or anyway the environment variable isn’t set anymore) and interpolates its output into your static files.