Multi-User Applications - React Native SDK
On this page
Add a New User to the Device
The Realm SDK automatically adds users to a device when they log in for the first time on that device. When a user logs in, they immediately become the application's active user.
In the example below, a user with the email joe@example.com
logs in and
becomes the active user. Later, a user with the email
emma@example.com
logs in and becomes the active user.
List All Users on the Device
You can access a list of all user accounts on the device. This list includes all users that have logged in to the client app on a given device.
In the example below, a developer prints out all the logged-in users on the device by looping through Realm.App.allUsers.
Remove a User from the Device
You can remove all information about a user from the device and automatically log the user out.
In the example below, the current user is removed from the device using the Realm.App.removeUser() method.
Change the Active User
You can quickly switch an app's active user to another logged-in user at any time.
In the example below, the active user is initially switched to user1
using the Realm.App.switchUser() method.
Later, the active user is switched to user2
.