Anonymous accounts

Register an account with no personal information from the user:

signInAnonymously(auth)

The generated credentials are stored in the browser: users cannot access their account from other devices, and cannot recover it if they lose the credentials (browser wipe).

Auth-triggered Cloud Functions only partially support anonymous accounts:

  • The v1 auth functions such as onCreate() correctly trigger.
  • The v2 auth blocking functions such as beforeUserCreated() don't trigger (as of writing)

check if the account is anonymous

On the client, we check the isAnonymous prop from currentUser:

auth.currentUser?.isAnonymous

In auth-triggered Cloud Functions, we read providerData (from the UserRecord which resembles the client SDK's User).

export const onRegisterNonBlocking = auth.user().onCreate(async (userRecord) => {
    userRecord.providerData.length === 0 // empty array for anonymous accounts
})

convert to a non-anonymous account (client SDK)

We link the account to another provider. Since the user already exists (auth.currentUser), we provide it to the linking function. We link to an email provider or to an identity provider:

// email
const emailCred = EmailAuthProvider.credential(email, password)
await linkWithCredential(auth.currentUser, emailCred)

// Google account with popup
const gProvider = new GoogleAuthProvider()
await linkWithPopup(auth.currentUser, gProvider)
earlymorning logo

Anonymous accounts

Register an account with no personal information from the user:

signInAnonymously(auth)

The generated credentials are stored in the browser: users cannot access their account from other devices, and cannot recover it if they lose the credentials (browser wipe).

Auth-triggered Cloud Functions only partially support anonymous accounts:

  • The v1 auth functions such as onCreate() correctly trigger.
  • The v2 auth blocking functions such as beforeUserCreated() don't trigger (as of writing)

check if the account is anonymous

On the client, we check the isAnonymous prop from currentUser:

auth.currentUser?.isAnonymous

In auth-triggered Cloud Functions, we read providerData (from the UserRecord which resembles the client SDK's User).

export const onRegisterNonBlocking = auth.user().onCreate(async (userRecord) => {
    userRecord.providerData.length === 0 // empty array for anonymous accounts
})

convert to a non-anonymous account (client SDK)

We link the account to another provider. Since the user already exists (auth.currentUser), we provide it to the linking function. We link to an email provider or to an identity provider:

// email
const emailCred = EmailAuthProvider.credential(email, password)
await linkWithCredential(auth.currentUser, emailCred)

// Google account with popup
const gProvider = new GoogleAuthProvider()
await linkWithPopup(auth.currentUser, gProvider)