React Native Firebase
    Preparing search index...

    The Firebase Authentication service is available for the default app or a given app.

    Get the auth instance for the default app:

    const authForDefaultApp = firebase.auth();
    

    Get the auth instance for a secondary app:

    const otherApp = firebase.app('otherApp');
    const authForOtherApp = firebase.auth(otherApp);

    TODO

    missing updateCurrentUser

    Hierarchy (View Summary)

    Index

    Accessors

    • get config(): Map<any, any>

      Gets the config used to initialize this auth instance. This is to match Firebase JS SDK behavior. It returns an empty map as the config is not available in the native SDK.

      Returns Map<any, any>

    Constructors

    Methods

    • Applies a verification code sent to the user by email or other out-of-band mechanism.

      await firebase.auth().applyActionCode('ABCD');
      

      Parameters

      • code: string

        A verification code sent to the user.

      Returns Promise<void>

      auth/expired-action-code Thrown if the action code has expired.

      auth/invalid-action-code Thrown if the action code is invalid. This can happen if the code is malformed or has already been used.

      auth/user-disabled Thrown if the user corresponding to the given action code has been disabled.

      auth/user-not-found Thrown if there is no user corresponding to the action code. This may have happened if the user was deleted between when the action code was issued and when this method was called.

    • Checks a verification code sent to the user by email or other out-of-band mechanism.

      const actionCodeInfo = await firebase.auth().checkActionCode('ABCD');
      console.log('Action code operation: ', actionCodeInfo.operation);

      Parameters

      • code: string

        A verification code sent to the user.

      Returns Promise<ActionCodeInfo>

      auth/expired-action-code Thrown if the action code has expired.

      auth/invalid-action-code Thrown if the action code is invalid. This can happen if the code is malformed or has already been used.

      auth/user-disabled Thrown if the user corresponding to the given action code has been disabled.

      auth/user-not-found Thrown if there is no user corresponding to the action code. This may have happened if the user was deleted between when the action code was issued and when this method was called.

    • Completes the password reset process with the confirmation code and new password, via sendPasswordResetEmail.

      await firebase.auth().confirmPasswordReset('ABCD', '1234567');
      

      Parameters

      • code: string

        The code from the password reset email.

      • newPassword: string

        The new password.

      Returns Promise<void>

      auth/expired-action-code Thrown if the password reset code has expired.

      auth/invalid-action-code Thrown if the password reset code is invalid. This can happen if the code is malformed or has already been used.

      auth/user-disabled Thrown if the user corresponding to the given password reset code has been disabled.

      auth/user-not-found Thrown if there is no user corresponding to the password reset code. This may have happened if the user was deleted between when the code was issued and when this method was called.

      auth/weak-password Thrown if the new password is not strong enough.

    • Creates a new user with an email and password.

      This method also signs the user in once the account has been created.

      const userCredential = await firebase.auth().createUserWithEmailAndPassword('[email protected]', '123456');
      

      Parameters

      • email: string

        The users email address.

      • password: string

        The users password.

      Returns Promise<UserCredential>

      auth/email-already-in-use Thrown if there already exists an account with the given email address.

      auth/invalid-email Thrown if the email address is not valid.

      auth/operation-not-allowed Thrown if email/password accounts are not enabled. Enable email/password accounts in the Firebase Console, under the Auth tab.

      auth/weak-password Thrown if the password is not strong enough.

    • Returns a list of authentication methods that can be used to sign in a given user (identified by its main email address).

      ⚠️ Note: If "Email Enumeration Protection" is enabled in your Firebase Authentication settings (which is the default), this method may return an empty array even if the email is registered, especially when called from an unauthenticated context.

      This is a security measure to prevent leaking account existence via email enumeration attacks. Do not use the result of this method to directly inform the user whether an email is registered.

      const methods = await firebase.auth().fetchSignInMethodsForEmail('[email protected]');

      if (methods.length > 0) {
      // Likely a registered user — offer sign-in
      } else {
      // Could be unregistered OR email enumeration protection is active — offer registration
      }

      Parameters

      • email: string

        The user's email address.

      Returns Promise<string[]>

      auth/invalid-email Thrown if the email address is not valid.

    • Returns the custom auth domain for the auth instance.

      Returns Promise<string>

    • Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink. Note that android and other platforms require apiKey link parameter for signInWithEmailLink

      const valid = await firebase.auth().isSignInWithEmailLink(link);
      

      Parameters

      • emailLink: string

        The email link to verify prior to using signInWithEmailLink

      Returns Promise<boolean>

    • Listen for changes in the users auth state (logging in and out). This method returns a unsubscribe function to stop listening to events. Always ensure you unsubscribe from the listener when no longer needed to prevent updates to components no longer in use.

      const unsubscribe = firebase.auth().onAuthStateChanged((user) => {
      if (user) {
      // Signed in
      } else {
      // Signed out
      }
      });

      // Unsubscribe from further state changes
      unsubscribe();

      Parameters

      Returns () => void

    • Listen for changes in ID token. ID token can be verified (if desired) using the admin SDK or a 3rd party JWT library This method returns a unsubscribe function to stop listening to events. Always ensure you unsubscribe from the listener when no longer needed to prevent updates to components no longer in use.

      const unsubscribe = firebase.auth().onIdTokenChanged((user) => {
      if (user) {
      // User is signed in or token was refreshed.
      }
      });

      // Unsubscribe from further state changes
      unsubscribe();

      Parameters

      Returns () => void

    • Adds a listener to observe changes to the User object. This is a superset of everything from onAuthStateChanged, onIdTokenChanged and user changes. The goal of this method is to provide easier listening to all user changes, such as when credentials are linked and unlinked, without manually having to call User#reload.

      const unsubscribe = firebase.auth().onUserChanged((user) => {
      if (user) {
      // User is signed in or token was refreshed.
      }
      });

      // Unsubscribe from further state changes
      unsubscribe();

      This is an experimental feature and is only part of React Native Firebase.

      Parameters

      Returns () => void

    • Revokes a user's Sign in with Apple token.

      // Generate an Apple ID authorizationCode for the currently logged in user (ie, with @invertase/react-native-apple-authentication)
      const { authorizationCode } = await appleAuth.performRequest({ requestedOperation: appleAuth.Operation.REFRESH });
      // Revoke the token
      await firebase.auth().revokeToken(authorizationCode);

      Parameters

      • authorizationCode: string

        A generated authorization code from Sign in with Apple.

      Returns Promise<void>

    • Sends a password reset email to the given email address. Unlike the web SDK, the email will contain a password reset link rather than a code.

      await firebase.auth().sendPasswordResetEmail('[email protected]');
      

      Parameters

      • email: string

        The users email address.

      • OptionalactionCodeSettings: ActionCodeSettings

        Additional settings to be set before sending the reset email.

      Returns Promise<void>

      auth/invalid-email Thrown if the email address is not valid.

      auth/missing-android-pkg-name An Android package name must be provided if the Android app is required to be installed.

      auth/missing-continue-uri A continue URL must be provided in the request.

      auth/missing-ios-bundle-id An iOS Bundle ID must be provided if an App Store ID is provided.

      auth/invalid-continue-uri The continue URL provided in the request is invalid.

      auth/unauthorized-continue-uri The domain of the continue URL is not whitelisted. Whitelist the domain in the Firebase console.

      auth/user-not-found Thrown if there is no user corresponding to the email address.

    • Sends a sign in link to the user.

      await firebase.auth().sendSignInLinkToEmail('[email protected]');
      

      Parameters

      • email: string

        The users email address.

      • OptionalactionCodeSettings: ActionCodeSettings

        The action code settings. The action code settings which provides Firebase with instructions on how to construct the email link. This includes the sign in completion URL or the deep link for mobile redirects, the mobile apps to use when the sign-in link is opened on an Android or iOS device. Mobile app redirects will only be applicable if the developer configures and accepts the Firebase Dynamic Links terms of condition. The Android package name and iOS bundle ID will be respected only if they are configured in the same Firebase Auth project used.

      Returns Promise<void>

      auth/argument-error Thrown if handleCodeInApp is false.

      auth/invalid-email Thrown if the email address is not valid.

      auth/missing-android-pkg-name An Android package name must be provided if the Android app is required to be installed.

      auth/missing-continue-uri A continue URL must be provided in the request.

      auth/missing-ios-bundle-id An iOS Bundle ID must be provided if an App Store ID is provided.

      auth/invalid-continue-uri The continue URL provided in the request is invalid.

      auth/unauthorized-continue-uri The domain of the continue URL is not whitelisted. Whitelist the domain in the Firebase console.

    • Sets the language code.

      // Set language to French
      await firebase.auth().setLanguageCode('fr');

      Parameters

      • languageCode: string | null

      Returns Promise<void>

    • Sets the tenant id.

      await firebase.auth().setTenantId('tenant-123');
      

      Parameters

      • tenantId: string

        the tenantID current app bind to.

      Returns Promise<void>

      auth/invalid-tenant-id if the tenant id is invalid for some reason

    • Sign in a user anonymously. If the user has already signed in, that user will be returned.

      const userCredential = await firebase.auth().signInAnonymously();
      

      Returns Promise<UserCredential>

      auth/operation-not-allowed Thrown if anonymous accounts are not enabled. Enable anonymous accounts in the Firebase Console, under the Auth tab.

    • Signs the user in with a generated credential.

      // Generate a Firebase credential
      const credential = firebase.auth.FacebookAuthProvider.credential('access token from Facebook');
      // Sign the user in with the credential
      const userCredential = await firebase.auth().signInWithCredential(credential);

      Parameters

      • credential: AuthCredential

        A generated AuthCredential, for example from social auth.

      Returns Promise<UserCredential>

      auth/account-exists-with-different-credential Thrown if there already exists an account with the email address asserted by the credential.

      auth/invalid-credential Thrown if the credential is malformed or has expired.

      auth/operation-not-allowed Thrown if the type of account corresponding to the credential is not enabled. Enable the account type in the Firebase Console, under the Auth tab.

      auth/user-disabled Thrown if the user corresponding to the given credential has been disabled.

      auth/user-not-found Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and there is no user corresponding to the given email.

      auth/wrong-password Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and the password is invalid for the given email, or if the account corresponding to the email does not have a password set.

      auth/invalid-verification-code Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.

      auth/invalid-verification-id Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.

    • Signs a user in with a custom token.

      // Create a custom token via the Firebase Admin SDK.
      const token = await firebase.auth().createCustomToken(uid, customClaims);
      ...
      // Use the token on the device to sign in.
      const userCredential = await firebase.auth().signInWithCustomToken(token);

      Parameters

      • customToken: string

        A custom token generated from the Firebase Admin SDK.

      Returns Promise<UserCredential>

      auth/custom-token-mismatch Thrown if the custom token is for a different Firebase App.

      auth/invalid-custom-token Thrown if the custom token format is incorrect.

    • Signs a user in with an email and password.

      ⚠️ Note: If "Email Enumeration Protection" is enabled in your Firebase Authentication settings (enabled by default), Firebase may return a generic auth/invalid-login-credentials error instead of more specific ones like auth/user-not-found or auth/wrong-password. This behavior is intended to prevent leaking information about whether an account with the given email exists.

      To receive detailed error codes, you must disable "Email Enumeration Protection", which may increase security risks if not properly handled on the frontend.

      const userCredential = await firebase.auth().signInWithEmailAndPassword('[email protected]', '123456');
      

      Parameters

      • email: string

        The user's email address.

      • password: string

        The user's password.

      Returns Promise<UserCredential>

      auth/invalid-email Thrown if the email address is not valid.

      auth/user-disabled Thrown if the user corresponding to the given email has been disabled.

      auth/user-not-found Thrown if there is no user corresponding to the given email. (May be suppressed if email enumeration protection is enabled.)

      auth/wrong-password Thrown if the password is invalid or missing. (May be suppressed if email enumeration protection is enabled.)

    • Signs the user in with an email link.

      const userCredential = await firebase.auth().signInWithEmailLink('[email protected]', link);
      

      Parameters

      • email: string

        The users email to sign in with.

      • emailLink: string

        An email link.

      Returns Promise<UserCredential>

      auth/expired-action-code Thrown if OTP in email link expires.

      auth/invalid-email Thrown if the email address is not valid.

      auth/user-disabled Thrown if the user corresponding to the given email has been disabled.

    • Signs in the user using their phone number.

      // Force a new message to be sent
      const result = await firebase.auth().signInWithPhoneNumber('#4423456789', true);

      Parameters

      • phoneNumber: string

        The devices phone number.

      • OptionalforceResend: boolean

        Forces a new message to be sent if it was already recently sent.

      Returns Promise<ConfirmationResult>

      auth/invalid-phone-number Thrown if the phone number has an invalid format.

      auth/missing-phone-number Thrown if the phone number is missing.

      auth/quota-exceeded Thrown if the SMS quota for the Firebase project has been exceeded.

      auth/user-disabled Thrown if the user corresponding to the given phone number has been disabled.

      auth/operation-not-allowed Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.

    • Signs the user in with a specified provider. This is a web-compatible API along with signInWithRedirect. They both share the same call to the underlying native SDK signInWithProvider method.

      // create a new OAuthProvider
      const provider = firebase.auth.OAuthProvider('microsoft.com');
      // Sign the user in with the provider
      const userCredential = await firebase.auth().signInWithPopup(provider);

      Parameters

      Returns Promise<UserCredential>

      auth/account-exists-with-different-credential Thrown if there already exists an account with the email address asserted by the credential.

      auth/invalid-credential Thrown if the credential is malformed or has expired.

      auth/operation-not-allowed Thrown if the type of account corresponding to the credential is not enabled. Enable the account type in the Firebase Console, under the Auth tab.

      auth/user-disabled Thrown if the user corresponding to the given credential has been disabled.

      auth/user-not-found Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and there is no user corresponding to the given email.

      auth/wrong-password Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and the password is invalid for the given email, or if the account corresponding to the email does not have a password set.

      auth/invalid-verification-code Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.

      auth/invalid-verification-id Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.

    • Signs the user in with a federated OAuth provider supported by Firebase (Microsoft, Yahoo).

      From Firebase Docs: Unlike other OAuth providers supported by Firebase such as Google, Facebook, and Twitter, where sign-in can directly be achieved with OAuth access token based credentials, Firebase Auth does not support the same capability for providers such as Microsoft due to the inability of the Firebase Auth server to verify the audience of Microsoft OAuth access tokens.

      // Generate an OAuth instance
      const provider = new firebase.auth.OAuthProvider('microsoft.com');
      // Optionally add scopes to the OAuth instance
      provider.addScope('mail.read');
      // Optionally add custom parameters to the OAuth instance
      provider.setCustomParameters({
      prompt: 'consent',
      });
      // Sign in using the OAuth provider
      const userCredential = await firebase.auth().signInWithProvider(provider);

      Parameters

      • provider: AuthProvider

        A generated AuthProvider, for example from social auth.

      Returns Promise<UserCredential>

      auth/account-exists-with-different-credential Thrown if there already exists an account with the email address asserted by the credential.

      auth/invalid-credential Thrown if the credential is malformed or has expired.

      auth/operation-not-allowed Thrown if the type of account corresponding to the credential is not enabled. Enable the account type in the Firebase Console, under the Auth tab.

      auth/user-disabled Thrown if the user corresponding to the given credential has been disabled.

      auth/user-not-found Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and there is no user corresponding to the given email.

      auth/wrong-password Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and the password is invalid for the given email, or if the account corresponding to the email does not have a password set.

      auth/invalid-verification-code Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.

      auth/invalid-verification-id Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.

    • Signs the user in with a specified provider. This is a web-compatible API along with signInWithPopup. They both share the same call to the underlying native SDK signInWithProvider method.

      // create a new OAuthProvider
      const provider = firebase.auth.OAuthProvider('microsoft.com');
      // Sign the user in with the provider
      const userCredential = await firebase.auth().signInWithRedirect(provider);

      Parameters

      Returns Promise<UserCredential>

      auth/account-exists-with-different-credential Thrown if there already exists an account with the email address asserted by the credential.

      auth/invalid-credential Thrown if the credential is malformed or has expired.

      auth/operation-not-allowed Thrown if the type of account corresponding to the credential is not enabled. Enable the account type in the Firebase Console, under the Auth tab.

      auth/user-disabled Thrown if the user corresponding to the given credential has been disabled.

      auth/user-not-found Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and there is no user corresponding to the given email.

      auth/wrong-password Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and the password is invalid for the given email, or if the account corresponding to the email does not have a password set.

      auth/invalid-verification-code Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.

      auth/invalid-verification-id Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.

    • Modify this Auth instance to communicate with the Firebase Auth emulator. This must be called synchronously immediately following the first call to firebase.auth(). Do not use with production credentials as emulator traffic is not encrypted.

      Note: on android, hosts 'localhost' and '127.0.0.1' are automatically remapped to '10.0.2.2' (the "host" computer IP address for android emulators) to make the standard development experience easy. If you want to use the emulator on a real android device, you will need to specify the actual host computer IP address.

      Parameters

      • url: string

      Returns void

    • Switch userAccessGroup and current user to the given accessGroup and the user stored in it. Sign in a user with any sign in method, and the same current user is available in all apps in the access group.

      Set the useAccessGroup argument to null to stop sharing the auth state (default behaviour), the user state will no longer be available to any other apps.

      Parameters

      • userAccessGroup: string

        A string of the keychain id i.e. "TEAMID.com.example.group1"

      Returns Promise<null>

      ios

      auth/keychain-error Thrown if you attempt to access an inaccessible keychain

    • Checks a password reset code sent to the user by email or other out-of-band mechanism. TODO salakar: confirm return behavior (Returns the user's email address if valid.)

      const verifiedEmail = await firebase.auth().verifyPasswordResetCode('ABCD');
      

      Parameters

      • code: string

        A password reset code.

      Returns Promise<string>

      The user's email address if valid

      auth/expired-action-code Thrown if the password reset code has expired.

      auth/invalid-action-code Thrown if the password reset code is invalid. This can happen if the code is malformed or has already been used.

      auth/user-disabled Thrown if the user corresponding to the given password reset code has been disabled.

      auth/user-not-found Thrown if there is no user corresponding to the password reset code. This may have happened if the user was deleted between when the code was issued and when this method was called.

    • Returns a PhoneAuthListener to listen to phone verification events, on the final completion event a PhoneAuthCredential can be generated for authentication purposes.

      firebase.auth().verifyPhoneNumber('+4423456789', )
      .on('state_changed', (phoneAuthSnapshot) => {
      console.log('Snapshot state: ', phoneAuthSnapshot.state);
      });

      Parameters

      • phoneNumber: string

        The phone number identifier supplied by the user. Its format is normalized on the server, so it can be in any format here. (e.g. +16505550101).

      • OptionalautoVerifyTimeoutOrForceResend: number | boolean

        If a number, sets in seconds how to to wait until auto verification times out. If boolean, sets the forceResend parameter.

      • OptionalforceResend: boolean

        If true, resend the verification message even if it was recently sent.

      Returns PhoneAuthListener

    Properties

    The current FirebaseApp instance for this Firebase service.

    currentUser: User | null

    Returns the currently signed-in user (or null if no user signed in). See the User interface documentation for detailed usage.

    const user = firebase.auth().currentUser;
    

    It is recommended to use onAuthStateChanged to track whether the user is currently signed in.

    languageCode: string

    Returns the current language code.

    const language = firebase.auth().languageCode;
    
    settings: AuthSettings

    Returns the current AuthSettings.

    tenantId: string | null

    Returns the current tenant Id or null if it has never been set

    const tenantId = firebase.auth().tenantId;