react-firebase-starter
react-firebase-starter copied to clipboard
Possible to use environment variables?
Is it possible to use environment variables in this project, like via a .env file in the root folder?
In case with Firebase, you add environment variables by using Firebase CLI:
$ firebase functions:config:set db.password="<secret>"
And then reference that variable in your server-side code like this:
import { config } from 'firebase-functions';
const password = config().database.password;
If you need environment variables for client-side portion of the app, you can pass them using REACT_APP_ prefix, see Create React App docs here.
@koistya How can I use environment variables with Firebase Hosting client-side if I'm using my own boilerplate and not Create React App?
Thanks.