Recipe: Sample UI for Login

Author: Ian Ward
Language: Swift
Date: September 1, 2017

The LoginKit can be pulled into your app to prompt the user for credentials and then use those credentials to open a synced Realm. User credentials are required to open a synced realm although they could be hardcoded into your app if your app does not require users to log in.

Example Code


// Create the object
let loginController = LoginViewController(style: .lightTranslucent) // init() also defaults to lightTranslucent

// Configure any of the inputs before presenting it
loginController.serverURL = "localhost"

// Set a closure that will be called on successful login
loginController.loginSuccessfulHandler = { user in
	// Provides the successfully authenticated SyncUser object


  • Light & dark themes for light apps like Realm Draw, and dark apps like Realm Tasks.
  • Fully adaptive to both smartphone, and tablet screen sizes.
  • Easy swapping between ‘log in’ and ‘sign up’ modes.
  • Optional settings to hide the server URL and ‘remember me’ form fields.
  • The ability to remember username and passwords on subsequent app launches.

Get Realm LoginKit

  • Xcode 8.0 and up
  • iOS 9.0 and up

Looking for the Objective-C version? Find it here.