Web Security 101 - Part 1: Secrets
There are ways to expose environment variables to front-end code in the browser. There are packages like dotenv that allow you to configure environment variables in files. You can configure them when you host a site using a platform like Heroku or Netlify. You can also set them in your terminal environment manually.