0

I'm currently developing a mobile app using Expo, React Native, and Firebase. In my local environment, everything is working fine, but I would like to have the ability to switch between development and production environments.

The structure of my application is as follows:

myApp/
  /app                    // front end app
  /assets
  /components
  /functions              // firebase cloud functions
  .firebaserc
  firebaseConfig.json     // project api keys etc
  index.json
  ...

Based on my understanding, I believe I need to:

  1. Create another app on Firebase for the production environment.

  2. Create separate firebaseConfig.js files for each environment (production, testing).

  3. Import the appropriate config based on the current environment.

    const devApp = initializeApp(firebaseDevConfig, 'dev')

  4. Define the environment I want to use (production, testing).

    NODE_ENV=development

This part seems clear to me for the client-side, but I'm unsure about my Firebase Cloud Functions (/functions folder) as they initialize the app on their own...

What do I need to do to switch the environment for both the client-side and the Cloud Functions?

Thank you in advance.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • You can tell the Firebase CLI which project you want to deploy Cloud Functions to using the `firebase use` command. See the documentation. https://firebase.google.com/docs/cli/#project_aliases – Doug Stevenson Jun 29 '23 at 17:27
  • Hi Doug and thanks for the response. So you mean it's normal the two are independent, and I should keep the initial version for my client app, and follow the `firebase use` method for the cloud functions ? – Stan Manscour Jun 29 '23 at 20:03
  • Yes, that's the way it works. There are different ways of getting client apps and Cloud Functions deployments to point to different projects. – Doug Stevenson Jun 29 '23 at 20:20

0 Answers0