REALM Offline Login

we are exploring React Native + Realm option. We are planning to use SYNC feature. Here is scenario i am trying to solve:

  1. User is in NETWORK
  2. User login into the app
  3. User able to view data on screen. Data is synced.
  4. User logout from the app
  5. User goes out of NETWORK
  6. User needs to access offline data
  7. User CANT login in offline mode, so user cant access app

any suggestions ?


If you leave out 4. (User logout from the app), the user will be able to access data offline (6.)

Hi @Kenneth_Geisshirt we see possibility that user will logout from app, when in the network. And when user goes out of network, and user needs to access app/offline data, user wont be able to login to access app/offline data. what do you recommend ?

I know this is an old thread, but just for the record, Realm caches de user when you log in for the first time.

Sou, you can do something like this (React Native version):

const app = new Realm.App(appConfig);

const credentials = Realm.Credentials.jwt(accessToken);

try {
  // Try to login, but ignore the error to allow continue offline.
  await app.logIn(credentials);
} catch (err) {

if (app.currentUser) {
  // Ensure that exists a cached or logged user
  throw new Error('Realm login failed: current user not found');

const realm = await{
      schema: config.schema,
      schemaVersion: config.schemaVersion,
      sync: {
        user: app.currentUser,
        partitionValue: config.partition,

// Done!!!