Realm App: don't store anonymous users! / delete anonymous users after log out

My Realm App gets SPAMMED with anonymous users because apparently, MongoDB creates a new Realm App User every time someone logs in anonymously. I don’t want it to store the anonymous users at all! OR at least delete it when the user closes the app. How can I do this?

I already looked at this thread but it’s not a great solution since it happens only every x minutes and needs TONS of computation time.
I’d like the app to just not store any anonymous user at all.

Hi @SirSwagon_N_A ,

The behaviour is exactly as designed: anonymous logins create new users, that, most of the times, would need to have limited persistence (and app.currentUser, instead of login(), will re-connect the same anonymous user without creating a new one), but are automatically deleted by the system at some point (at this time, 90 days).

What’s the use case for having anonymous users that don’t persist any data outside the single session? If you don’t need any persistence whatsoever, wouldn’t, for example, a local, in-memory realm serve you better?


Hi, thanks so much for the quick answer.
My reason is very simple: I need users to be able to see the data (READ ONLY). It’s like a “guest” mode where they can look around the app, as guests. As far as I know this can only be accomplished by allowing anonymous login. Or maybe there is another solution to make data publicly readable?

You could define an API Key user for all guests, and give it the read-only access you want for them to have.

The permissions would be needed also for anonymous users, anyway, if you don’t want everyone to be able to modify data in the DB…


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.