How constant is the Firebase Anonymous ID

A user's UID never changes. So after you sign in a user anonymously, the UID will remain the same (even when you call signInAnonymously again), until you call signout, or until the user uninstalls the app.


You should check this out:

Firebase also allows for anonymous auth sessions, which are typically used to persist small amounts of data while waiting for a client to authenticate with a permanent auth method. These anonymous sessions can be configured to last days, weeks, months, even years… until the user logs in with a permanent login method or clears her browser cache. Web apps often use local datastores like sessionStorage or localStorage to accomplish similar tasks.

It is not guaranteed that the ID will always stay unchanged on a given device. Firebase stores the anonymous auth sessions to browser's localStorage. If users open your application in incognito mode / private browsing mode, another browsers, or they clear their browser's localStorage, firebase will issue another user ID.


Here's what I've found using Flutter:

  • if you call FirebaseAuth.signInAnonymously() twice without calling FirebaseAuth.signOut() in between, you get the same uid (from AuthResult.user.uid) as the first call. This is true even if you close the app and call FirebaseAuth.signInAnonymously()
  • if you call FirebaseAuth.signOut() and then call FirebaseAuth.signInAnonymously(), you get a new uid
  • if you uninstall the app and call FirebaseAuth.signInAnonymously(), you get a different uid from the previous install

Is summary, you get a new uid if you call signInAnonymously() after signOut() or after uninstalling the app.


If you login anonymous then your UID will remain unchanged until you logout. Once you logged out, and log in again, you will get a new UID. Or even when the user uninstalls the app, you will get UID again.