0

I am, following this answer, setting up the firebase emulator using react-fire with the following code

const preloadSDKs = (firebaseApp: firebase.app.App) => {
    return Promise.all([
        preloadFirestore({
            firebaseApp,
            setup: firestore => {

                return firestore().useEmulator('localhost', 8080);
            }
        }),
    ]);
};

interface IAppProps {
}

const App: React.FunctionComponent<IAppProps> = (props) => {

    const firebaseApp = useFirebaseApp();



    preloadSDKs(firebaseApp).then(() => Promise.resolve());

However, I am a bit confused as to how I can add some condidtional code that makes sure I use the emulator in development, and use my cloud firestore in production build.

Can anyone help me configure this?

Boris Grunwald
  • 2,602
  • 3
  • 20
  • 36
  • What do you use to indicate in which environment you are in? I guess this question is more related to preparing the dev environment than the emulator itself, I would recommend you to follow this [step by step guide](https://blog.logrocket.com/using-firebase-emulator-suite-and-react-for-local-first-development/). – Ralemos Jun 17 '21 at 12:31
  • I just check if window.locaction.host === 'localhost' – Boris Grunwald Jun 17 '21 at 14:47

0 Answers0