Subscriptions object is null on realm flexible sync


I am trying out flexible sync for react native and am having some trouble in my initial setup. I have hooked up everything on the Realm UI and have a schema for the user table. The trouble is when I try to write to this realm, I get Cannot write to class user when no flexible sync subscription has been created. Didn’t my initialSubscriptions set up the subscription? Also note that realm.subscriptions is null for some reason.


      const config: Realm.Configuration = {
        sync: {
          error: (e, r) => console.log(e, r),
          flexible: true,
          initialSubscriptions: {
            update: realm => {
                // This is a named subscription, so will replace any existing subscription with the same name
                {name: 'LoggedInUserData'},
            rerunOnStartup: true,
        } as FlexibleSyncConfiguration,
        .then(e => {
          realmRef.current = e;
        .catch(er => console.error(er));

Having the same issue: using initialSubscriptions does somehow not avoid the error * Cannot write to class user when no flexible sync subscription has been created*
I did solve this by adding adding an explicit subs.append( ... ) but in my opinion the initial subscription should suffice. Maybe this is a bug?

G’Day @Luke_Walz and @David_Kessler,

@Luke_Walz I hope you were able to get past this error. If not, you may need to modify the section of your code

update: realm => {

to this

update: (subs, realm) => {

You can find out more on Bootstraping with Initial Subscriptions.

I hope provided information is helpful.

Please let me know if you have more questions.

Cheers, :performing_arts:

1 Like