Docs Menu

Work with Users - Swift SDKicons/link.png

When you use MongoDB Realm to back your client Realm app, you get access to a user object. Use client SDK methods with this user object to conveniently:

  • Log users in and out
  • Create and update custom user data
  • Read user metadata from social login providers

Use one or more authentication providers to log users in and out of your client app. You can:

  • Log users in with an existing social account, such as Apple, Facebook, or Google.
  • Create new user accounts with Realm email/password management, or your own custom function or custom JWT user management.
  • Enable anonymous users to let users access your Realm app without persisting user data.

When you have a logged-in user, SDK methods enable you to:

Realm caches credentials on the device upon successful login in a sync_metadata.realm file. You can bypass the login flow and access the cached user to open a realm or call a function upon subsequent app opens.

You can associate custom data with a user object, such as a preferred language or local timezone, and read it from your client application. A user object has a customData property that you can use to access custom user data.

To create and update custom user data, you must access your MongoDB data source directly. Realm does not offer a SDK method to create or update this custom user data; it's a read-only property.

Some authentication providers enable developers to access user metadata, such as full name or email address. When you configure these metadata fields on the MongoDB Realm application, you can read this medata from your client app. A user object has a profile property that you can use to access user metadata.

Give Feedback
MongoDB logo
© 2021 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.