Skip to content

Commit

Permalink
docs(app, other): add a note about dynamic initialization on other
Browse files Browse the repository at this point in the history
this was confusing to users because the install notes are very specific
about how to do initialization with the firebase config on the native platforms,
but there was no mention of the completely different style needed for "other" / web
  • Loading branch information
mikehardy committed Nov 20, 2024
1 parent 8cbe59f commit 11c7fa8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,32 @@ If you are using the [Expo Tools](https://marketplace.visualstudio.com/items?ite

---

## Other / Web

If you are using the firebase-js-sdk fallback support for [web or "other" platforms](platforms#other-platforms) then you must initialize Firebase dynamically by calling [`initializeApp`](/reference/app#initializeApp).

However, you only want to do this for the web platform. For non-web / native apps the "default" firebase app instance will already be configured by the native google-services.json / GoogleServices-Info.plist files as mentioned above.

At some point during your application's bootstrap processes, initialize firebase like this:

```javascript
import { getApp, initializeApp } from '@react-native-firebase/app';

// web requires dynamic initialization on web prior to using firebase
if (Platform.OS === 'web') {
const firebaseConfig = {
// ... config items pasted from firebase console for your web app here
};

initializeApp(firebaseConfig);
}

// ...now throughout your app, use firebase APIs normally, for example:
const firebaseApp = getApp();
```

---

## Miscellaneous

### Android Enabling Multidex
Expand Down

0 comments on commit 11c7fa8

Please sign in to comment.