Skip to content

Commit 11c7fa8

Browse files
committed
docs(app, other): add a note about dynamic initialization on other
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
1 parent 8cbe59f commit 11c7fa8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,32 @@ If you are using the [Expo Tools](https://marketplace.visualstudio.com/items?ite
245245

246246
---
247247

248+
## Other / Web
249+
250+
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).
251+
252+
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.
253+
254+
At some point during your application's bootstrap processes, initialize firebase like this:
255+
256+
```javascript
257+
import { getApp, initializeApp } from '@react-native-firebase/app';
258+
259+
// web requires dynamic initialization on web prior to using firebase
260+
if (Platform.OS === 'web') {
261+
const firebaseConfig = {
262+
// ... config items pasted from firebase console for your web app here
263+
};
264+
265+
initializeApp(firebaseConfig);
266+
}
267+
268+
// ...now throughout your app, use firebase APIs normally, for example:
269+
const firebaseApp = getApp();
270+
```
271+
272+
---
273+
248274
## Miscellaneous
249275

250276
### Android Enabling Multidex

0 commit comments

Comments
 (0)