react-firebase-starter icon indicating copy to clipboard operation
react-firebase-starter copied to clipboard

Possible to use environment variables?

Open AndroidDoctorr opened this issue 8 years ago • 2 comments

Is it possible to use environment variables in this project, like via a .env file in the root folder?

AndroidDoctorr avatar Jan 15 '18 06:01 AndroidDoctorr

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 avatar Feb 19 '18 16:02 koistya

@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.

jcorkhill avatar Jan 22 '19 01:01 jcorkhill