How do you open up a synchronized realm when offline


How do you open up a synchronized realm from a client when the client is offline ?

I am assuming that this is possible. Here are the steps I am trying:

  1. Authenticate with the realm object server
  2. If there is a network error then see if there is one logged in user available (Realm.Sync.User.current)
  3. Use Realm.Sync.User.current to create a config and open the synchronized realm.

I am getting a warning when I try this:

‘user’ property will be overridden by 4e285fb22a299d38f808badba6cf7e94

Are there any other steps that I am missing ?

Here is my config code. This works fine when the client is online and I use a user returned back to me from Realm.Sync.User.login(…) but does not work if i try to use Realm.Sync.User.current.

const config = user.createConfiguration({
  sync: {
    url: "realm://",
    error: err => console.log("################ SYNC ERROR:" + err)
  schema: [Todo]
}); ...




Ok, I figured it out. I was trying to open a realm asynchronously instead of synchronously.


Instead of this:

const realm = new Realm(config);

I was getting no objects because I was offline when I opened the realm asynchronously. It won’t return the realm until it is synched even though I may have local objects. Opening it synchronously gave me access to my local objects even though I was offline and the realm wasn’t in a synched state. This is what I wanted.