---
title: Authentication
description: >-
  Core Authentication: getAuth(), initializeAuth(), connectAuthEmulator(),
  listeners (onAuthStateChanged, onIdTokenChanged, beforeAuthStateChanged),
  anonymous and email/password sign-in, custom tokens, validatePassword(),
  fetchSignInMethodsForEmail(), manage users (updateProfile, updateEmail,
  verifyBeforeUpdateEmail, password reset, delete, reauthenticate, unlink(),
  updateCurrentUser()), ActionCodeSettings for email links, email action codes,
  setLanguageCode(), useUserAccessGroup(), getCustomAuthDomain(),
  getAdditionalUserInfo(), auth constants, ID tokens, signOut(), and web-only
  helpers that throw.
next: /auth/social-auth
previous: /app-distribution/usage
---
> ## Documentation Index
> Fetch the complete documentation index at: https://rnfirebase.io/llms.txt
> Use this file to discover all available pages before exploring further.

## Prerequisites

- `@react-native-firebase/app` installed and native config completed per [Getting Started](/) (Android `google-services.json`, iOS `GoogleService-Info.plist`, Expo config plugin, or React Native CLI setup). From v26, New Architecture is required for packages with a native bridge.
- Install Auth: `npm install --save @react-native-firebase/auth` or `yarn add @react-native-firebase/auth`, then rebuild native apps (`cd ios && pod install` on iOS).
- Enable the sign-in providers you use under [Firebase Console → Authentication → Sign-in method](https://console.firebase.google.com/project/_/authentication/providers).

Example Expo Router screen: https://github.com/invertase/react-native-firebase/blob/main/test-expo/app/auth/index.tsx (connects to the Auth emulator and has one control per function on this page). Related screens in the same folder cover [social providers](/auth/social-auth), [phone](/auth/phone-auth), [email link](/auth/email-link-auth) and [multi-factor](/auth/multi-factor-auth) flows.

# Installation

```bash
# Install & setup the app module
yarn add @react-native-firebase/app

# Install the authentication module
yarn add @react-native-firebase/auth

# If you're developing your app using iOS, run this command
cd ios/ && pod install
```

# Platform support and New Architecture

{/* prettier-ignore */}
| | |
| --- | --- |
| **Platforms** | Android, iOS (native Firebase SDK) |
| **New Architecture** | **Required** from v26. See [Migrating to v26](/migrating-to-v26#new-architecture-requirement). |

**Platform notes:** Several firebase-js-sdk web helpers throw on React Native (`setPersistence`, `getRedirectResult`, `revokeAccessToken`, `useDeviceLanguage`, `linkWithPhoneNumber`, `reauthenticateWithPhoneNumber`); see [Web-only helpers that throw](#web-only-helpers-that-throw). `initializeAuth` accepts the firebase-js-sdk dependency argument but ignores it. React Native Firebase also exports RN-only helpers such as `SDK_VERSION`, `setLanguageCode`, `useUserAccessGroup`, `getCustomAuthDomain`, `verifyPhoneNumber`, and related phone-listener types. Each is explained in the section that uses it (phone helpers live on [Phone Authentication](/auth/phone-auth)). See [Migrating to v26, Platform behavior differences](/migrating-to-v26#platform-behavior-differences).

# What does it do

Firebase Authentication provides backend services & easy-to-use SDKs to authenticate users to your app. It supports
authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.

<YouTube id="8sGY55yxicA" />

Firebase Authentication integrates tightly with other Firebase services, and it leverages industry standards like OAuth
2.0 and OpenID Connect, so it can be easily integrated with your custom backend.

# Usage

## Emulator

Use `connectAuthEmulator` before any Auth calls when talking to the Local Emulator Suite (the Authentication emulator listens on port `9099` by default). Pass a full URL. On Android emulators, use `10.0.2.2` instead of `localhost` / `127.0.0.1` so the guest can reach the host machine.

```js
import { Platform } from 'react-native';
import { connectAuthEmulator, getAuth } from '@react-native-firebase/auth';

const host = Platform.OS === 'android' ? '10.0.2.2' : '127.0.0.1';
connectAuthEmulator(getAuth(), `http://${host}:9099`);
```

## Initialize Auth

`initializeAuth(app, deps?)` exists for firebase-js-sdk parity. The optional `deps` argument (persistence, popup/redirect resolver, error map) is ignored because the native iOS and Android SDKs manage persistence. The call returns the same Auth instance as `getAuth(app)`, so it configures nothing extra. Prefer `getAuth()` unless code shared with a web app already calls `initializeAuth`.

```js
import { getApp } from '@react-native-firebase/app';
import { getAuth, initializeAuth } from '@react-native-firebase/auth';

const app = getApp();
const auth = initializeAuth(app);

console.log('Same Auth instance as getAuth:', auth === getAuth(app));
```

## Listening to authentication state

In most scenarios using Authentication, you will want to know whether your users are signed-in or signed-out
of your application. The module provides a method called `onAuthStateChanged` which allows you to subscribe to the users
authentication state, and receive an event whenever that state changes.

It is important to remember the `onAuthStateChanged` listener is asynchronous and will trigger an initial state once
a connection with Firebase has been established. Therefore it is important to setup an "initializing" state which blocks
render of our main application whilst the connection is established:

```jsx
import React, { useState, useEffect } from 'react';
import { View, Text } from 'react-native';
import { getAuth, onAuthStateChanged } from '@react-native-firebase/auth';

function App() {
  // Set an initializing state whilst Firebase connects
  const [initializing, setInitializing] = useState(true);
  const [user, setUser] = useState(
    /** @type {import('@react-native-firebase/auth').User | null} */ (null),
  );

  // Handle user state changes
  function handleAuthStateChanged(nextUser) {
    setUser(nextUser);
    if (initializing) {
      setInitializing(false);
    }
  }

  useEffect(() => {
    const subscriber = onAuthStateChanged(getAuth(), handleAuthStateChanged);
    return subscriber; // unsubscribe on unmount
  }, []);

  if (initializing) return null;

  if (!user) {
    return (
      <View>
        <Text>Login</Text>
      </View>
    );
  }

  return (
    <View>
      <Text>Welcome {user.email}</Text>
    </View>
  );
}
```

If the `user` returned within the handler is `null` we assume the user is signed-out, otherwise they are
signed-in and a [`User`](https://reference.rnfirebase.io/_react-native-firebase/auth/User.html) interface is returned.

The `onAuthStateChanged` method also returns an unsubscriber function which allows us to stop listening for events whenever
the hook is no longer in use.

`AuthListenerCallback` is the exported callback type for that listener (`(user: User | null) => void`). `CallbackOrObserver` is the exported union that also accepts an observer-shaped `{ next }` object. firebase-js-sdk keeps those shapes inline on `onAuthStateChanged` / `onIdTokenChanged` rather than exporting the aliases.

```js
import { getAuth, onAuthStateChanged } from '@react-native-firebase/auth';

/** @type {import('@react-native-firebase/auth').AuthListenerCallback} */
function handleUser(user) {
  console.log('uid', user?.uid ?? null);
}

/** @type {import('@react-native-firebase/auth').CallbackOrObserver<import('@react-native-firebase/auth').AuthListenerCallback>} */
const observer = { next: handleUser };

const unsubscribeFn = onAuthStateChanged(getAuth(), handleUser);
const unsubscribeObserver = onAuthStateChanged(getAuth(), observer);
unsubscribeFn();
unsubscribeObserver();
```

### ID token changes

`onIdTokenChanged` fires when the signed-in user's ID token changes (refresh, sign-in, sign-out). Use the same `AuthListenerCallback` / `CallbackOrObserver` shapes as `onAuthStateChanged`.

```js
import { getAuth, onIdTokenChanged } from '@react-native-firebase/auth';

const unsubscribe = onIdTokenChanged(getAuth(), user => {
  console.log('ID token user:', user?.uid ?? null);
});

unsubscribe();
```

### Before auth state changes

`beforeAuthStateChanged(auth, callback, onAbort?)` registers a callback that runs, and is awaited, before `onAuthStateChanged` listeners are notified of a sign-in or sign-out. The callback receives the pending `User` or `null`. If the callback throws or rejects, `onAbort` runs and that state change is not delivered to `onAuthStateChanged` listeners. Throwing does not undo the sign-in or sign-out that already happened in the native SDK. The function returns an unsubscribe function. It only gates auth state events; `onIdTokenChanged` listeners are not affected.

```js
import { beforeAuthStateChanged, getAuth } from '@react-native-firebase/auth';

const unsubscribe = beforeAuthStateChanged(
  getAuth(),
  async user => {
    console.log('About to publish auth state for', user?.uid ?? null);
  },
  () => {
    console.log('A beforeAuthStateChanged callback threw, listeners were not notified');
  },
);

unsubscribe();
```

## Persisting authentication state

On web based applications, the Firebase Web SDK takes advantage of features such as cookies and local storage to persist
the users authenticated state across sessions. The native Firebase SDKs also provide this functionality using device native SDKs,
ensuring that a users previous authentication state between app sessions is persisted.

The user is able to clear their state by deleting the apps data/cache from the device settings.

`setPersistence` always throws on React Native Firebase, so there is no persistence type to choose. See [Web-only helpers that throw](#web-only-helpers-that-throw).

## Anonymous sign-in

Some applications don't require authentication, which make it tricky to identify what users are doing throughout your app.
If connecting with external APIs, it is also useful to add an extra layer of security by ensuring the users request is
from the app. This can be achieved with the `signInAnonymously` method, which creates a new anonymous user which is persisted,
allowing you to integrate with other services such as Analytics by providing a user ID.

Ensure the "Anonymous" sign-in provider is enabled on the [Firebase Console](https://console.firebase.google.com/project/_/authentication/providers).

```js
import { getAuth, signInAnonymously } from '@react-native-firebase/auth';

signInAnonymously(getAuth())
  .then(() => {
    console.log('User signed in anonymously');
  })
  .catch(error => {
    if (error.code === 'auth/operation-not-allowed') {
      console.log('Enable anonymous in your firebase console.');
    }

    console.error(error);
  });
```

Once successfully signed in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners will trigger an event
with the [`User`](https://reference.rnfirebase.io/_react-native-firebase/auth/User.html) details.

In case any errors occur, the module provides support for identifying what specifically went wrong by attaching a code
to the error. For a full list of error codes available, view the [Firebase documentation](https://firebase.google.com/docs/reference/js/auth.md#autherrorcodes).

### Upgrade an anonymous account

When an anonymous user later signs up, link email/password (or another provider credential) so they keep the same Firebase uid:

```js
import { EmailAuthProvider, getAuth, linkWithCredential } from '@react-native-firebase/auth';

async function linkEmailPasswordToCurrentUser(email, password) {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  const credential = EmailAuthProvider.credential(email, password);
  return linkWithCredential(user, credential);
}

await linkEmailPasswordToCurrentUser('jane.doe@example.com', 'SuperSecretPassword!');
```

## Email/Password sign-in

Email/password sign in is a common method for user sign in on applications. This requires the user to provide an email
address and secure password. Users can both register and sign in using a method called `createUserWithEmailAndPassword`
or sign in to an existing account with `signInWithEmailAndPassword`.

Ensure the "Email/Password" sign-in provider is enabled on the [Firebase Console](https://console.firebase.google.com/project/_/authentication/providers).

The `createUserWithEmailAndPassword` performs two operations; first creating the user if they do not already exist, and
then signing them in.

```js
import { getAuth, createUserWithEmailAndPassword } from '@react-native-firebase/auth';

createUserWithEmailAndPassword(getAuth(), 'jane.doe@example.com', 'SuperSecretPassword!')
  .then(() => {
    console.log('User account created & signed in!');
  })
  .catch(error => {
    if (error.code === 'auth/email-already-in-use') {
      console.log('That email address is already in use!');
    }

    if (error.code === 'auth/invalid-email') {
      console.log('That email address is invalid!');
    }

    console.error(error);
  });
```

Sign in an existing account:

```js
import { getAuth, signInWithEmailAndPassword } from '@react-native-firebase/auth';

signInWithEmailAndPassword(getAuth(), 'jane.doe@example.com', 'SuperSecretPassword!')
  .then(userCredential => {
    console.log('Signed in:', userCredential.user.email);
  })
  .catch(error => {
    console.error(error.code, error.message);
  });
```

Once successfully created and/or signed in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners will trigger an event
with the [`User`](https://reference.rnfirebase.io/_react-native-firebase/auth/User.html) details.

In case any errors occur, the module provides support for identifying what specifically went wrong by attaching a code
to the error. For a full list of error codes available, view the [Firebase documentation](https://firebase.google.com/docs/reference/js/auth.md#autherrorcodes).

### Validate a password against project policy

When the project has a password policy configured in the Firebase Console (Authentication → Settings → Password policy), call `validatePassword` on the client before sign-up:

```js
import { getAuth, validatePassword } from '@react-native-firebase/auth';

async function checkPasswordMeetsPolicy(password) {
  const status = await validatePassword(getAuth(), password);
  if (!status.isValid) {
    console.log('Password does not meet project policy', status);
  }
  return status;
}

await checkPasswordMeetsPolicy('SuperSecretPassword!');
```

### Look up sign-in methods for an email

`fetchSignInMethodsForEmail` resolves with the sign-in method IDs (for example `password` or `google.com`) registered for an email address. Do not rely on it for identifier-first sign-in screens when email enumeration protection is enabled for the project. See [Email enumeration protection](/auth/email-link-auth#5-email-enumeration-protection).

```js
import { fetchSignInMethodsForEmail, getAuth } from '@react-native-firebase/auth';

async function logSignInMethods(email) {
  const methods = await fetchSignInMethodsForEmail(getAuth(), email);
  console.log('Sign-in methods:', methods);
  return methods;
}

await logSignInMethods('jane.doe@example.com');
```

## Custom auth tokens

If your backend mints Firebase custom tokens (Admin SDK), exchange them with `signInWithCustomToken`:

```js
import { getAuth, signInWithCustomToken } from '@react-native-firebase/auth';

async function signInWithBackendCustomToken(customToken) {
  return signInWithCustomToken(getAuth(), customToken);
}

await signInWithBackendCustomToken('CUSTOM_TOKEN_FROM_YOUR_SERVER');
```

## Manage users

### Current user and profile

Prefer an auth state observer for a stable current user. You can also read `getAuth().currentUser` (it may be `null` while Auth is still initializing).

```js
import { getAuth } from '@react-native-firebase/auth';

function logCurrentUserProfile() {
  const user = getAuth().currentUser;
  if (!user) {
    console.log('No user is signed in');
    return;
  }

  console.log({
    displayName: user.displayName,
    email: user.email,
    photoURL: user.photoURL,
    emailVerified: user.emailVerified,
    uid: user.uid,
  });

  user.providerData.forEach(profile => {
    console.log(profile.providerId, profile.uid, profile.email);
  });
}

logCurrentUserProfile();
```

### Update profile

`updateProfile` accepts an `UpdateProfile` options object (`displayName` / `photoURL`). React Native Firebase exports that alias; firebase-js-sdk declares the shape inline on `updateProfile`.

```js
import { getAuth, updateProfile } from '@react-native-firebase/auth';

async function updateSignedInUserProfile() {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  /** @type {import('@react-native-firebase/auth').UpdateProfile} */
  const profile = {
    displayName: 'Jane Q. User',
    photoURL: 'https://example.com/jane-q-user/profile.jpg',
  };

  await updateProfile(user, profile);
}

await updateSignedInUserProfile();
```

### Update email and send verification

Some security-sensitive updates require a recent sign-in. See [Re-authenticate](/auth/usage#re-authenticate).

```js
import { getAuth, updateEmail, sendEmailVerification } from '@react-native-firebase/auth';

async function changeEmailAndSendVerification(newEmail) {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  await updateEmail(user, newEmail);
  await sendEmailVerification(user);
}

await changeEmailAndSendVerification('user@example.com');
```

`sendEmailVerification(user, actionCodeSettings?)` also accepts [`ActionCodeSettings`](#email-action-link-settings) to control the link in the email.

### Verify and update email

`verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings?)` sends a verification email to `newEmail`. It does not change the account email on its own: the address changes once the user follows the link in that email, and `reload(user)` then refreshes the cached profile. Use it instead of `updateEmail` when the new address must be confirmed before it replaces the current one. It requires a signed-in user and may need a recent sign-in; see [Re-authenticate](/auth/usage#re-authenticate). The optional third argument is the same [`ActionCodeSettings`](#email-action-link-settings) object used by `sendEmailVerification`.

```js
import { getAuth, reload, verifyBeforeUpdateEmail } from '@react-native-firebase/auth';

async function requestEmailChange(newEmail) {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  await verifyBeforeUpdateEmail(user, newEmail);
}

async function refreshAfterUserFollowedLink() {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  await reload(user);
  // Read currentUser again: reload replaces auth.currentUser with a new User object.
  console.log('Email after reload:', getAuth().currentUser?.email);
}

await requestEmailChange('new.address@example.com');
await refreshAfterUserFollowedLink();
```

### Update password and send password reset

```js
import { getAuth, updatePassword, sendPasswordResetEmail } from '@react-native-firebase/auth';

async function changePassword(newPassword) {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  await updatePassword(user, newPassword);
}

async function sendResetEmail(email) {
  await sendPasswordResetEmail(getAuth(), email);
}

await changePassword('AnotherSecurePassword!');
await sendResetEmail('jane.doe@example.com');
```

`sendPasswordResetEmail(auth, email, actionCodeSettings?)` also accepts [`ActionCodeSettings`](#email-action-link-settings).

### Email action link settings

`sendEmailVerification`, `sendPasswordResetEmail`, and `verifyBeforeUpdateEmail` accept an optional `ActionCodeSettings` object that controls where the link in the email leads. Without it, Firebase sends the default link. The email-link sign-in helper `sendSignInLinkToEmail` takes the same object but requires it; see [Email Link Authentication](/auth/email-link-auth) for the App Links / Universal Links setup that `handleCodeInApp` depends on.

{/* prettier-ignore */}
| Field | Type | Notes |
| --- | --- | --- |
| `url` | `string` (required) | Continue URL. Its domain must be listed under Authentication → Settings → **Authorized domains** in the Firebase Console. |
| `handleCodeInApp` | `boolean` | Set `true` to have the link opened in your app instead of a web page first. |
| `iOS.bundleId` | `string` | Bundle ID of the iOS app that should handle the link. Required when `iOS` is set. |
| `android.packageName` | `string` | Package name of the Android app that should handle the link. Required when `android` is set. |
| `android.installApp` | `boolean` | Offer to install the Android app when it is missing. |
| `android.minimumVersion` | `string` | Minimum Android app version that can handle the link. |
| `linkDomain` | `string` | Custom Firebase Hosting link domain. Omit it unless the project uses a custom Hosting link domain. |
| `dynamicLinkDomain` | `string` | Declared on the type but not forwarded by the iOS or Android bridge. Omit it. |

`sendEmailVerification` and `verifyBeforeUpdateEmail` validate the object before calling the native SDK and throw an `Error` when `url` is not a string, when `iOS.bundleId` or `android.packageName` is not a string while the parent object is set, when `handleCodeInApp` or `android.installApp` is not a boolean, or when `android.minimumVersion` or `linkDomain` is not a string.

```js
import {
  getAuth,
  sendEmailVerification,
  sendPasswordResetEmail,
  verifyBeforeUpdateEmail,
} from '@react-native-firebase/auth';

/** @type {import('@react-native-firebase/auth').ActionCodeSettings} */
const actionCodeSettings = {
  url: 'https://YOUR_PROJECT_ID.firebaseapp.com/finishAction',
  handleCodeInApp: true,
  iOS: {
    bundleId: 'com.yourcompany.yourapp',
  },
  android: {
    packageName: 'com.yourcompany.yourapp',
    installApp: true,
    minimumVersion: '12',
  },
};

async function sendVerificationWithSettings() {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  await sendEmailVerification(user, actionCodeSettings);
}

async function sendPasswordResetWithSettings(email) {
  await sendPasswordResetEmail(getAuth(), email, actionCodeSettings);
}

async function requestEmailChangeWithSettings(newEmail) {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  await verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings);
}

await sendVerificationWithSettings();
await sendPasswordResetWithSettings('jane.doe@example.com');
await requestEmailChangeWithSettings('new.address@example.com');
```

### Reload, delete, and remove a provider

```js
import { getAuth, reload, deleteUser, unlink } from '@react-native-firebase/auth';

async function reloadCurrentUser() {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }
  await reload(user);
}

async function deleteCurrentUser() {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }
  await deleteUser(user);
}

async function unlinkProvider(providerId) {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }
  return unlink(user, providerId);
}

await reloadCurrentUser();
await unlinkProvider('google.com');
await deleteCurrentUser();
```

### Re-authenticate

```js
import {
  EmailAuthProvider,
  getAuth,
  reauthenticateWithCredential,
} from '@react-native-firebase/auth';

async function reauthenticateWithEmailPassword(email, password) {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  const credential = EmailAuthProvider.credential(email, password);
  return reauthenticateWithCredential(user, credential);
}

await reauthenticateWithEmailPassword('jane.doe@example.com', 'SuperSecretPassword!');
```

For OAuth providers that use a native sign-in flow, `reauthenticateWithPopup` and `reauthenticateWithRedirect` re-authenticate with a provider instead of a credential; see [Re-authenticate with a provider](/auth/social-auth#re-authenticate-with-a-provider).

### Update the current user

`updateCurrentUser(auth, user)` returns a promise. Passing `null` signs out, the same as `signOut(auth)`. Passing a `User` only works with a user object created by the same Auth instance (the same Firebase app); any other value rejects with an error. It cannot sign in an account that was not already signed in through that Auth instance; use a sign-in method to switch accounts.

```js
import { getAuth, updateCurrentUser } from '@react-native-firebase/auth';

async function reapplyCurrentUser() {
  const auth = getAuth();
  const user = auth.currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  await updateCurrentUser(auth, user);
}

async function signOutWithUpdateCurrentUser() {
  await updateCurrentUser(getAuth(), null);
}

await reapplyCurrentUser();
await signOutWithUpdateCurrentUser();
```

## Language code

`setLanguageCode` sets `auth.languageCode` for localized email templates and related Auth UI strings. It is an RN Firebase modular helper; firebase-js-sdk apps typically assign `auth.languageCode` or call `useDeviceLanguage()` (the latter throws on React Native).

```js
import { getAuth, setLanguageCode } from '@react-native-firebase/auth';

await setLanguageCode(getAuth(), 'it');
```

## iOS user access group

`useUserAccessGroup` shares Auth credentials across apps in an iOS App Group. **iOS native only**; calling it on other platforms can throw.

```js
import { Platform } from 'react-native';
import { getAuth, useUserAccessGroup } from '@react-native-firebase/auth';

async function shareAuthAcrossIosApps(appGroup) {
  if (Platform.OS !== 'ios') {
    throw new Error('useUserAccessGroup is iOS only');
  }
  await useUserAccessGroup(getAuth(), appGroup);
}

await shareAuthAcrossIosApps('group.com.example.shared');
```

## Custom auth domain

`getCustomAuthDomain` returns the native custom auth domain configured for the Firebase app on iOS/Android. On Web the call rejects with `auth/unsupported`.

```js
import { getAuth, getCustomAuthDomain } from '@react-native-firebase/auth';

async function logCustomAuthDomain() {
  const domain = await getCustomAuthDomain(getAuth());
  console.log('Custom auth domain:', domain);
}

await logCustomAuthDomain();
```

## Additional user info

After a credential-based sign-in, `getAdditionalUserInfo` returns profile metadata. On React Native the result is typed as `AdditionalUserInfoNative`: firebase-js-sdk `AdditionalUserInfo` core fields plus an index signature for extra native bridge keys.

```js
import {
  getAuth,
  getAdditionalUserInfo,
  signInWithEmailAndPassword,
} from '@react-native-firebase/auth';

async function signInAndLogAdditionalInfo(email, password) {
  const userCredential = await signInWithEmailAndPassword(getAuth(), email, password);
  // Typed as AdditionalUserInfoNative on React Native (core fields + native bridge keys).
  const info = getAdditionalUserInfo(userCredential);
  console.log(info?.isNewUser, info?.providerId, info?.profile);
  return info;
}

await signInAndLogAdditionalInfo('jane.doe@example.com', 'SuperSecretPassword!');
```

## Constants

The package exports string constants you can compare against instead of repeating literals:

- `ProviderId`: `FACEBOOK`, `GITHUB`, `GOOGLE`, `PASSWORD`, `PHONE`, `TWITTER`
- `SignInMethod`: `EMAIL_LINK`, `EMAIL_PASSWORD`, `FACEBOOK`, `GITHUB`, `GOOGLE`, `PHONE`, `TWITTER`
- `OperationType`: `LINK`, `REAUTHENTICATE`, `SIGN_IN`
- `FactorId`: `PHONE`, `TOTP`
- `ActionCodeOperation`: `EMAIL_SIGNIN`, `PASSWORD_RESET`, `RECOVER_EMAIL`, `REVERT_SECOND_FACTOR_ADDITION`, `VERIFY_AND_CHANGE_EMAIL`, `VERIFY_EMAIL`

```js
import {
  ActionCodeOperation,
  FactorId,
  OperationType,
  ProviderId,
  SignInMethod,
  fetchSignInMethodsForEmail,
  getAuth,
  parseActionCodeURL,
  signInWithEmailAndPassword,
} from '@react-native-firebase/auth';

async function describeSignIn(email, password) {
  const userCredential = await signInWithEmailAndPassword(getAuth(), email, password);
  console.log('Sign-in operation:', userCredential.operationType === OperationType.SIGN_IN);
  console.log(
    'Has password provider:',
    userCredential.user.providerData.some(info => info.providerId === ProviderId.PASSWORD),
  );

  const methods = await fetchSignInMethodsForEmail(getAuth(), email);
  console.log('Email link enabled for this address:', methods.includes(SignInMethod.EMAIL_LINK));
}

function isEmailChangeLink(link) {
  const parsed = parseActionCodeURL(link);
  return parsed?.operation === ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL;
}

function isTotpHint(hint) {
  return hint.factorId === FactorId.TOTP;
}

await describeSignIn('jane.doe@example.com', 'SuperSecretPassword!');
console.log(
  isEmailChangeLink(
    'https://example.com/usermgmt?mode=verifyAndChangeEmail&oobCode=ABC123&apiKey=YOUR_API_KEY',
  ),
);
console.log(isTotpHint({ factorId: 'totp' }));
```

## Auth errors

Native bridge failures use `NativeFirebaseAuthError`, which extends the shared React Native Firebase error shape with `userInfo.authCredential` and `userInfo.resolver` (for multi-factor). Prefer checking `error.code` strings from the [Auth error reference](https://firebase.google.com/docs/reference/js/auth.md#autherrorcodes).

```js
import { getAuth, signInWithEmailAndPassword } from '@react-native-firebase/auth';

async function signInCatchingNativeAuthError(email, password) {
  try {
    await signInWithEmailAndPassword(getAuth(), email, password);
  } catch (error) {
    /** @type {import('@react-native-firebase/auth').NativeFirebaseAuthError} */
    const authError = error;
    console.log(authError.code, authError.userInfo?.authCredential);
  }
}

await signInCatchingNativeAuthError('jane.doe@example.com', 'wrong-password');
```

## Email action codes

Custom email action handlers (password reset, email verification, recover email) parse `mode` / `oobCode` from the link, then call the modular helpers. `parseActionCodeURL` extracts those fields from a full link string when you handle the URL in-app. It returns an `ActionCodeURL` with `apiKey`, `code`, `continueUrl`, `languageCode`, `operation` (an `ActionCodeOperation` value) and `tenantId`, or `null` when the link is missing `apiKey`, `oobCode`, or a supported `mode`.

```js
import {
  applyActionCode,
  checkActionCode,
  confirmPasswordReset,
  getAuth,
  parseActionCodeURL,
  verifyPasswordResetCode,
} from '@react-native-firebase/auth';

async function handlePasswordResetFromLink(link, newPassword) {
  const parsed = parseActionCodeURL(link);
  if (!parsed?.code) {
    throw new Error('Not an Auth action link');
  }

  const email = await verifyPasswordResetCode(getAuth(), parsed.code);
  await confirmPasswordReset(getAuth(), parsed.code, newPassword);
  return email;
}

async function handleVerifyOrRecoverEmail(oobCode) {
  const info = await checkActionCode(getAuth(), oobCode);
  await applyActionCode(getAuth(), oobCode);
  return info;
}

await handlePasswordResetFromLink(
  'https://example.com/usermgmt?mode=resetPassword&oobCode=ABC123&apiKey=YOUR_API_KEY',
  'AnotherSecurePassword!',
);
await handleVerifyOrRecoverEmail('ABC123');
```

## Authenticate with backend server

The user's token should be used for authentication with your backend systems. The token is fetched with the [getIdToken](https://reference.rnfirebase.io/_react-native-firebase/auth/getIdToken.html) method. As mentioned in the [Firebase documentation](https://firebase.google.com/docs/auth/web/manage-users#get_a_users_profile), the uid should not be used for authentication.

```js
import { getAuth, getIdToken, getIdTokenResult } from '@react-native-firebase/auth';

async function fetchBackendWithIdToken() {
  const user = getAuth().currentUser;
  if (!user) {
    throw new Error('No user is signed in');
  }

  const idToken = await getIdToken(user);
  const tokenResult = await getIdTokenResult(user);
  console.log('claims', tokenResult.claims);

  const response = await fetch('https://example.com/api/protected', {
    headers: {
      Authorization: `Bearer ${idToken}`,
    },
  });
  return response.json();
}

await fetchBackendWithIdToken();
```

## Signing out

If you'd like to sign the user out of their authentication state, call the `signOut` method:

```js
import { getAuth, signOut } from '@react-native-firebase/auth';

signOut(getAuth()).then(() => console.log('User signed out!'));
```

Once successfully signed out, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners will trigger an event
with the `user` parameter being a `null` value.

Additionally, calling `revokeAccess()` on your Google sign-in library forgets the user on the device (for example `GoogleOneTapSignIn.revokeAccess()` from [`react-native-nitro-google-signin`](https://www.npmjs.com/package/react-native-nitro-google-signin), or `GoogleSignin.revokeAccess()` from `@react-native-google-signin/google-signin`). The next sign-in will show the account picker again. Without it, the last account may be reused automatically.

## Web-only helpers that throw

These firebase-js-sdk helpers are exported for API parity. Each one throws an `Error` synchronously on React Native Firebase instead of returning a rejected promise, so wrap the call in `try` / `catch` if shared code may reach it.

{/* prettier-ignore */}
| Function | Instead |
| --- | --- |
| `setPersistence` | Nothing to configure; the native SDKs persist the signed-in user. |
| `getRedirectResult` | `signInWithRedirect` resolves with the `UserCredential` directly. |
| `revokeAccessToken` | `revokeToken` for Sign in with Apple; see [Apple](/auth/social-auth#apple). |
| `useDeviceLanguage` | `setLanguageCode`; see [Language code](#language-code). |
| `linkWithPhoneNumber` | `verifyPhoneNumber`, `PhoneAuthProvider.credential`, then `linkWithCredential`; see [Phone Authentication](/auth/phone-auth). |
| `reauthenticateWithPhoneNumber` | `verifyPhoneNumber`, `PhoneAuthProvider.credential`, then `reauthenticateWithCredential`; see [Phone Authentication](/auth/phone-auth). |

## Other sign-in methods

Firebase also supports authenticating with external providers. To learn more, view the documentation for your authentication
method:

- [Apple Sign-In](/auth/social-auth#apple).
- [Facebook Sign-In](/auth/social-auth#facebook).
- [Twitter Sign-In](/auth/social-auth#twitter).
- [Google Sign-In](/auth/social-auth#google).
- [GitHub Sign-In](/auth/social-auth#github).
- [Microsoft Sign-In](/auth/social-auth#microsoft).
- [Phone Number Sign-In](/auth/phone-auth).
- [Email Link Sign-In](/auth/email-link-auth) (passwordless App Links / Universal Links).
- [OpenID Connect](/auth/oidc-auth).
- [Multi-factor Auth](/auth/multi-factor-auth).

## Package version

`SDK_VERSION` is the React Native Firebase Auth package version string exported from `@react-native-firebase/auth`. The firebase-js-sdk does not export `SDK_VERSION` from `@firebase/auth`.

```js
import { SDK_VERSION } from '@react-native-firebase/auth';

console.log('Auth package version:', SDK_VERSION);
```
