Skip to content

Commit

Permalink
docs: update usage of secondary app (#3430)
Browse files Browse the repository at this point in the history
I struggled a lot with simply switching the database URL within the [DEFAULT] app instance during run time.
I documented my solution in this ticket: #3049

This PR shall reflect my findings with switching app instances.
  • Loading branch information
lisabaut authored May 5, 2020
1 parent b684c92 commit 6d54d8c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docs/app/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,26 @@ console.log(firebase.apps);

## Switching app instance

You can switch app instances at any time whilst developing by calling the `app` method:
You can switch app instances at any time whilst developing by calling the `app` method with the name of the secondary app:

```js
import firebase from '@react-native-firebase/app';
import '@react-native-firebase/auth';

// Example using auth
firebase.app('SECONDARY_APP').auth().currentUser;
```

The `firebase` instance is also exported on modules for added convenience, for example:

Or pass the secondary app instance you created above directly to the desired module, for example:
```js
import auth, { firebase } from '@react-native-firebase/auth';
import firebase from '@react-native-firebase/app';
import auth from '@react-native-firebase/auth';

// create secondary app as described above
const secondaryApp = await firebase.initalizeApp(credentials, config);

// Example using auth with passing the secondary app instance
auth(secondaryApp).currentUser;
```

## Deleting instances
Expand Down

0 comments on commit 6d54d8c

Please sign in to comment.