Persisting anonymous users

My application has a flow in which a user does not need an account, but can link an account in the future to sync between devices. The way I am going about this right now is logging in the user to a synced realm with anonymous credentials and then linking google/apple credentials down the line when they authenticate. From the documentation, it seems as though anonymous user data may be deleted, which is a problem since there is a case for my app where users remain anonymous forever without authenticating. Is there a better way to handle this flow? Perhaps starting the user on a non-synced realm and then manually migrating to a synced realm once they authenticate? Or sending an arbitrary JWT as a workaround?

Anonymous user data is deleted after some period of inactivity (I believe it’s 30 days). If your app needs to support a scenario where the user will be offline for more than 30 days, then perhaps using a JWT would be the best approach. Also feel free to file a feature request to expose controls to configure the retention period for anonymous users - I can see that being useful for almost everyone who would want to use sync + anonymous auth.

2 Likes