When you create your key in the Google API Console and choose the set up credentials for the Maps JavaScript API, the wizard will instruct you how to secure the key, and will prompt you for URLs you wish to authorize.
For more info refer here : How do I securely use Google API Keys
Answer from Kasinaat 007 on Stack OverflowGoogle maps api key in html/javascript - Stack Overflow
Where to store google maps API key for react app?
How do i get browser and server API for google maps - Google Maps Community
Need help!!! With Google maps API key
Videos
When you create your key in the Google API Console and choose the set up credentials for the Maps JavaScript API, the wizard will instruct you how to secure the key, and will prompt you for URLs you wish to authorize.
For more info refer here : How do I securely use Google API Keys
If I remember you should have a public and a private key. You can expose your public key (if combo exists, whatever the service) and restrict it use using HTTP referrer into your google api console. It means that your key will only work with the domain you provided.
Hope it will answer your question.
I’m resting a react app with a google maps api component. The api has to be inserted into the react app. How do I deploy the react app while keeping the api key secure? The only options I see for env variables are for cloud functions.