Google's Firebase is a great system and environment to quickly build apps. However, there are a few tricky things to work around, such as deploying to different environments.

Here is what I do to create a staging and production environments with different configurations in Firebase.

1. Setup a unique Firebase project for each environment, e.g. Production, Staging, and Development.

2. At a command prompt, assign an alias for each project with:

firebase use --add

3. Create a different .env file for each environment: .env.production, .env.staging, .env.development. Place your specific configs for those environments there.

4. Install "dotenv" with:

npm i --save-dev dotenv

This is assuming your using NodeJS.

5. Add a build script "build-staging" to your package.json file (or build-dev):

"build-staging": "dotenv -e .env.staging react-scripts build"

6. Build with the script:

npm run build-staging

7. Deploy to Firebase:

firebase deploy -P staging


Also if you're concerned about your Firebase costs (or have been burned by them in the past), check out 🔥Firemon🔥 to help manage and control your Firebase usage costs.