---
title: Social Authentication
description: >-
  Federated sign-in with Apple (OAuthProvider, AppleFullPersonName,
  revokeToken), Facebook, Google, GitHub, Microsoft and Twitter, signInWithPopup
  / signInWithRedirect / linkWithPopup / linkWithRedirect /
  reauthenticateWithPopup / reauthenticateWithRedirect, plus linking providers
  and removing a linked provider with unlink().
next: /auth/phone-auth
previous: /auth/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` and `@react-native-firebase/auth` installed and native config completed per [Authentication usage](/auth/usage) / [Getting Started](/). From v26, New Architecture is required for packages with a native bridge.
- Enable each social provider you use under [Firebase Console → Authentication → Sign-in method](https://console.firebase.google.com/project/_/authentication/providers).
- Install and configure the community OAuth library for that provider (Apple, Facebook, Google, GitHub, Twitter). Fences that import one of those third-party packages show the end-to-end flow; install the package in your app to run them. Fences that only import `@react-native-firebase/auth` show the Firebase side with the provider token as an argument.

Example Expo Router screen: https://github.com/invertase/react-native-firebase/blob/main/test-expo/app/auth/social.tsx (connects to the Auth emulator).

React Native Firebase supports integrating with social platforms. Obtaining the provider credential is left to your app because OAuth flows differ. After you have a provider token, exchange it with the matching `*AuthProvider.credential()` and `signInWithCredential()` (or Microsoft's redirect helpers).

# Social providers

## Apple

Starting April 2020, apps that offer third-party login on the App Store must also offer Sign in with Apple when applicable. See [Apple's announcement](https://developer.apple.com/news/?id=09122019b). Apple Sign-In is not required for Android devices.

Install [`react-native-apple-authentication`](https://github.com/invertase/react-native-apple-authentication) and complete its [prerequisites](https://github.com/invertase/react-native-apple-authentication#prerequisites-to-using-this-library) and [Apple Developer setup](https://github.com/invertase/react-native-apple-authentication/blob/main/docs/INITIAL_SETUP.md). Enable the **Apple** provider in the Firebase Console.

Use `OAuthProvider('apple.com')` (matches firebase-js-sdk).

Credential exchange with optional `AppleFullPersonName` (Apple only shares the full name on first authorization; iOS forwards non-empty name fields so Firebase can store `displayName`; Android ignores `fullName`, call `updateProfile` after sign-in instead):

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

async function signInWithAppleViaOAuthProvider(identityToken, nonce, fullName) {
  const provider = new OAuthProvider('apple.com');
  /** @type {import('@react-native-firebase/auth').AppleFullPersonName | undefined} */
  const appleFullName = fullName;
  const appleCredential = provider.credential({
    idToken: identityToken,
    rawNonce: nonce,
    fullName: appleFullName,
  });
  return signInWithCredential(getAuth(), appleCredential);
}

await signInWithAppleViaOAuthProvider('APPLE_IDENTITY_TOKEN', 'NONCE', {
  givenName: 'Jane',
  familyName: 'Appleseed',
});
```

End-to-end UI + `react-native-apple-authentication` (install that package in your app):

```js
// codeblock-ignore: @invertase/react-native-apple-authentication is a third-party package; install it in your app
import React from 'react';
import { AppleButton, appleAuth } from '@invertase/react-native-apple-authentication';
import { OAuthProvider, getAuth, signInWithCredential } from '@react-native-firebase/auth';

async function onAppleButtonPress() {
  const appleAuthRequestResponse = await appleAuth.performRequest({
    requestedOperation: appleAuth.Operation.LOGIN,
    // As per the FAQ of react-native-apple-authentication, the name should come first.
    // See: https://github.com/invertase/react-native-apple-authentication#faqs
    requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL],
  });

  if (!appleAuthRequestResponse.identityToken) {
    throw new Error('Apple Sign-In failed - no identity token returned');
  }

  const { identityToken, nonce, fullName } = appleAuthRequestResponse;
  const provider = new OAuthProvider('apple.com');
  const appleCredential = provider.credential({
    idToken: identityToken,
    rawNonce: nonce,
    fullName,
  });
  return signInWithCredential(getAuth(), appleCredential);
}

function AppleSignIn() {
  return (
    <AppleButton
      buttonStyle={AppleButton.Style.WHITE}
      buttonType={AppleButton.Type.SIGN_IN}
      style={{
        width: 160,
        height: 45,
      }}
      onPress={() => onAppleButtonPress().then(() => console.log('Apple sign-in complete!'))}
    />
  );
}
```

Upon successful sign-in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners receive the signed-in user.

Apple also requires that the app revoke the Sign in with Apple token when the user deletes their account. Use `revokeToken`. It is supported on iOS via the native `revokeTokenWithAuthorizationCode` bridge. On Android and Web the bridge resolves without performing revocation (no-op). It is distinct from web-only `revokeAccessToken`, which revokes OAuth access tokens on Web and always throws on React Native Firebase.

```js
// codeblock-ignore: @invertase/react-native-apple-authentication is a third-party package; install it in your app
import { getAuth, revokeToken } from '@react-native-firebase/auth';
import { appleAuth } from '@invertase/react-native-apple-authentication';

async function revokeSignInWithAppleToken() {
  const { authorizationCode } = await appleAuth.performRequest({
    requestedOperation: appleAuth.Operation.REFRESH,
  });

  if (!authorizationCode) {
    throw new Error('Apple Revocation failed - no authorizationCode returned');
  }

  return revokeToken(getAuth(), authorizationCode);
}
```

## Facebook

Use the community library [`react-native-fbsdk-next`](https://github.com/thebergamo/react-native-fbsdk-next). Install it, [configure Android and iOS](https://developers.facebook.com/docs/android/getting-started/), and set up your [Facebook Developer account](https://github.com/thebergamo/react-native-fbsdk-next#3-configure-projects). Enable the **Facebook** provider in the Firebase Console.

Firebase credential exchange once you have a Facebook access token:

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

async function signInWithFacebookAccessToken(accessToken) {
  const facebookCredential = FacebookAuthProvider.credential(accessToken);
  return signInWithCredential(getAuth(), facebookCredential);
}

await signInWithFacebookAccessToken('FACEBOOK_ACCESS_TOKEN');
```

End-to-end classic Facebook Login:

```js
// codeblock-ignore: react-native-fbsdk-next is a third-party package; install it in your app
import React from 'react';
import { Button } from 'react-native';
import { LoginManager, AccessToken } from 'react-native-fbsdk-next';
import { FacebookAuthProvider, getAuth, signInWithCredential } from '@react-native-firebase/auth';

async function onFacebookButtonPress() {
  const result = await LoginManager.logInWithPermissions(['public_profile', 'email']);

  if (result.isCancelled) {
    throw new Error('User cancelled the login process');
  }

  const data = await AccessToken.getCurrentAccessToken();
  if (!data) {
    throw new Error('Something went wrong obtaining access token');
  }

  const facebookCredential = FacebookAuthProvider.credential(data.accessToken);
  return signInWithCredential(getAuth(), facebookCredential);
}

function FacebookSignIn() {
  return (
    <Button
      title="Facebook Sign-In"
      onPress={() => onFacebookButtonPress().then(() => console.log('Signed in with Facebook!'))}
    />
  );
}
```

### Facebook Limited Login (iOS only)

Limited Login needs a new, unpredictable nonce for every login attempt. A fixed or reused nonce lets a captured token be replayed. Hermes has no built-in secure random source, so the sample uses [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values) to provide `crypto.getRandomValues`. Import it once, before any code that generates a nonce (for example at the top of your app entry file).

```js
// codeblock-ignore: react-native-fbsdk-next, react-native-sha256 and react-native-get-random-values are third-party packages; install them in your app
// Load the polyfill before anything calls crypto.getRandomValues. Your app entry file is the safest place.
import 'react-native-get-random-values';
import { FacebookAuthProvider, getAuth, signInWithCredential } from '@react-native-firebase/auth';
import { LoginManager, AuthenticationToken } from 'react-native-fbsdk-next';
import { sha256 } from 'react-native-sha256';

// Generate a new nonce for every login attempt. Never hardcode or reuse it.
function generateNonce(byteLength = 32) {
  const bytes = new Uint8Array(byteLength);
  crypto.getRandomValues(bytes);
  return Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
}

async function onFacebookLimitedLoginButtonPress() {
  const nonce = generateNonce();
  const nonceSha256 = await sha256(nonce);
  const result = await LoginManager.logInWithPermissions(
    ['public_profile', 'email'],
    'limited',
    nonceSha256,
  );

  if (result.isCancelled) {
    throw new Error('User cancelled the login process');
  }

  const data = await AuthenticationToken.getAuthenticationTokenIOS();
  if (!data) {
    throw new Error('Something went wrong obtaining authentication token');
  }

  // Firebase validates the hash against the nonce.
  const facebookCredential = FacebookAuthProvider.credential(data.authenticationToken, nonce);
  return signInWithCredential(getAuth(), facebookCredential);
}
```

Upon successful sign-in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners receive the signed-in user.

## Google

Firebase does not ship a Google sign-in UI. Install a community library to obtain a Google **ID token**, then pass it to `GoogleAuthProvider.credential()` and `signInWithCredential()`.

Enable the **Google** sign-in provider in the Firebase Console.

On **Android**, Google recommends [Credential Manager](https://developer.android.com/identity/sign-in/credential-manager-siwg-implementation) for Sign in with Google. Two maintained React Native libraries can provide that flow:

{/* prettier-ignore */}
| Library | Credential Manager (Android) | Cost | Notes |
| --- | --- | --- | --- |
| [`react-native-nitro-google-signin`](https://www.npmjs.com/package/react-native-nitro-google-signin) | Yes | Free (MIT) | Universal / One Tap-style API via [Nitro Modules](https://nitro.margelo.com); requires `react-native-nitro-modules` |
| [`@react-native-google-signin/google-signin`](https://github.com/react-native-google-signin/google-signin) | Yes with [Universal Sign-In](https://react-native-google-signin.github.io/docs/install); **no** on the free public `GoogleSignin` API | Paid for Credential Manager; free for legacy Android SDK | Universal Sign-In uses `GoogleOneTapSignIn`; the free public build is documented below |

The sections below show Firebase integration for each approach. For native setup (OAuth clients, SHA-1, Expo config plugins), follow that library's documentation.

Firebase credential exchange once you have a Google ID token:

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

async function signInWithGoogleIdToken(idToken) {
  const googleCredential = GoogleAuthProvider.credential(idToken);
  return signInWithCredential(getAuth(), googleCredential);
}

await signInWithGoogleIdToken('GOOGLE_ID_TOKEN');
```

### react-native-nitro-google-signin

[`react-native-nitro-google-signin`](https://www.npmjs.com/package/react-native-nitro-google-signin) is an MIT-licensed option that uses **Credential Manager** on Android and the Google Sign-In SDK on iOS.

```bash
yarn add react-native-nitro-google-signin react-native-nitro-modules
```

Then follow the [installation](https://react-native-nitro-google-sign-in.github.io/docs/getting-started/installation) and [Google Cloud setup](https://react-native-nitro-google-sign-in.github.io/docs/setup/google-cloud) guides. For Expo, use a [development build](https://docs.expo.dev/develop/development-builds/introduction/) and the [Expo config plugin](https://react-native-nitro-google-sign-in.github.io/docs/setup/expo) — it does not run in Expo Go.

#### Using Google Sign-In with Firebase

```js
// codeblock-ignore: react-native-nitro-google-signin is a third-party package; install it in your app
import React from 'react';
import { Button } from 'react-native';
import { GoogleAuthProvider, getAuth, signInWithCredential } from '@react-native-firebase/auth';
import {
  GoogleOneTapSignIn,
  isNoSavedCredentialFoundResponse,
  isSuccessResponse,
} from 'react-native-nitro-google-signin';

GoogleOneTapSignIn.configure({ webClientId: 'autoDetect' });

async function onGoogleButtonPress() {
  await GoogleOneTapSignIn.checkPlayServices();

  let response = await GoogleOneTapSignIn.signIn();

  if (isNoSavedCredentialFoundResponse(response)) {
    response = await GoogleOneTapSignIn.createAccount();
  }
  if (isNoSavedCredentialFoundResponse(response)) {
    response = await GoogleOneTapSignIn.presentExplicitSignIn();
  }

  if (!isSuccessResponse(response)) {
    throw new Error('Google Sign-In was cancelled or failed');
  }

  const idToken = response.data?.idToken;
  if (!idToken) {
    throw new Error('No ID token found');
  }

  const googleCredential = GoogleAuthProvider.credential(idToken);
  return signInWithCredential(getAuth(), googleCredential);
}

function GoogleSignIn() {
  return (
    <Button
      title="Google Sign-In"
      onPress={() => onGoogleButtonPress().then(() => console.log('Signed in with Google!'))}
    />
  );
}
```

Upon successful sign-in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners receive the signed-in user.

The sample calls `checkPlayServices()` before signing in. If you test on an Android emulator, use an image that includes Google Play services.

Full API details: [react-native-nitro-google-signin documentation](https://react-native-nitro-google-sign-in.github.io/).

### @react-native-google-signin/google-signin

The [`@react-native-google-signin/google-signin`](https://github.com/react-native-google-signin/google-signin) package offers two tiers:

- **Universal Sign-In** ([paid](https://universal-sign-in.com/#pricing)): Cross-platform One Tap-style API (`GoogleOneTapSignIn`) with **Credential Manager** on Android. Licensed builds are installed from the package maintainer's registry — see [their installation guide](https://react-native-google-signin.github.io/docs/install).
- **Public (free) version**: `GoogleSignin` API for Android and iOS using the **legacy** Android Google Sign-In SDK. Google has deprecated that stack; it does not use Credential Manager. The examples below use this free API.

#### Configure an Expo project

For Expo projects, follow [the setup instructions for Expo](https://react-native-google-signin.github.io/docs/category/setting-up) from `@react-native-google-signin/google-signin`.

#### Configure a React Native (non-Expo) project

For bare React Native projects, most configuration is already in place when using Google Sign-In with React Native Firebase's configuration. Ensure your machine's SHA-1 key is configured for Android (see [Getting Started](/)).

#### Using Google Sign-In

The examples below use the version 16 API of `@react-native-google-signin/google-signin` (16.x). Install it in your app:

```bash
yarn add @react-native-google-signin/google-signin
```

Initialize the Google SDK with any required scopes and the `webClientId` from `android/app/google-services.json` as the `client/oauth_client/client_id` property (the id ends with `.apps.googleusercontent.com`). Pick the `client_id` with `client_type: 3`.

`GoogleSignin.signIn()` resolves with a response object. Use `isSuccessResponse` to check it, then read the ID token from `response.data.idToken`. A canceled sign-in resolves with `type: 'cancelled'` instead of throwing.

```js
// codeblock-ignore: @react-native-google-signin/google-signin is a third-party package; install it in your app
// Google Sign-In v16 API (@react-native-google-signin/google-signin 16.x)
import React from 'react';
import { Button } from 'react-native';
import { GoogleSignin, isSuccessResponse } from '@react-native-google-signin/google-signin';
import { GoogleAuthProvider, getAuth, signInWithCredential } from '@react-native-firebase/auth';

GoogleSignin.configure({
  webClientId: 'YOUR_WEB_CLIENT_ID.apps.googleusercontent.com',
});

async function onGoogleButtonPress() {
  await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true });
  const response = await GoogleSignin.signIn();

  if (!isSuccessResponse(response)) {
    throw new Error('Google Sign-In was canceled');
  }

  const idToken = response.data.idToken;
  if (!idToken) {
    throw new Error('No ID token found');
  }

  const googleCredential = GoogleAuthProvider.credential(idToken);
  return signInWithCredential(getAuth(), googleCredential);
}

function GoogleSignIn() {
  return (
    <Button
      title="Google Sign-In"
      onPress={() => onGoogleButtonPress().then(() => console.log('Signed in with Google!'))}
    />
  );
}
```

Upon successful sign-in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners receive the signed-in user.

The sample calls `hasPlayServices()` before signing in. If you test on an Android emulator, use an image that includes Google Play services.

> If you need Credential Manager on Android without a paid license, use [`react-native-nitro-google-signin`](/auth/social-auth#react-native-nitro-google-signin) instead of upgrading to Universal Sign-In.

## GitHub

Obtain a GitHub OAuth access token with a community OAuth client (for example [`react-native-app-auth`](https://github.com/FormidableLabs/react-native-app-auth)), then exchange it with `GithubAuthProvider.credential` and `signInWithCredential`. Enable the **GitHub** provider in the Firebase Console and register the Firebase OAuth redirect URL on the GitHub app.

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

async function signInWithGithubAccessToken(accessToken) {
  const githubCredential = GithubAuthProvider.credential(accessToken);
  return signInWithCredential(getAuth(), githubCredential);
}

await signInWithGithubAccessToken('GITHUB_ACCESS_TOKEN');
```

Upon successful sign-in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners receive the signed-in user.

## Microsoft

Per the [Firebase documentation](https://firebase.google.com/docs/auth/android/microsoft-oauth#expandable-1), do not handle the Sign-In flow by obtaining an access token from a library such as `react-native-app-auth` and then calling `signInWithCredential`.
Use the native Sign-In flow from the Firebase SDK instead.

Follow the prerequisites and setup instructions: [Android](https://firebase.google.com/docs/auth/android/microsoft-oauth#before_you_begin), [iOS](https://firebase.google.com/docs/auth/ios/microsoft-oauth#before_you_begin).
For iOS, also complete step 1 of [Handle sign-in flow](https://firebase.google.com/docs/auth/ios/microsoft-oauth#handle_the_sign-in_flow_with_the_firebase_sdk) (custom URL scheme in Xcode).

Then trigger Microsoft sign-in with `signInWithPopup` or `signInWithRedirect`. The underlying implementation is the same and will not behave exactly like the firebase-js-sdk web implementations, but provides drop-in compatibility when your project also has a web target.

```jsx
import React from 'react';
import { Button } from 'react-native';
import { OAuthProvider, getAuth, signInWithRedirect } from '@react-native-firebase/auth';

async function onMicrosoftButtonPress() {
  const provider = new OAuthProvider('microsoft.com');
  provider.addScope('offline_access');
  provider.setCustomParameters({
    prompt: 'consent',
    // Optional "tenant" parameter for optional use of Azure AD tenant.
    // e.g., specific ID - 9aaa9999-9999-999a-a9aa-9999aa9aa99a or domain - example.com
    // defaults to "common" for tenant-independent tokens.
    tenant: 'tenant_name_or_id',
  });

  // OAuthProvider satisfies AuthProvider at runtime; cast for the docs type harness.
  return signInWithRedirect(getAuth(), /** @type {any} */ (provider));
}

function MicrosoftSignIn() {
  return (
    <Button
      title="Microsoft Sign-In"
      onPress={() => onMicrosoftButtonPress().then(() => console.log('Signed in with Microsoft!'))}
    />
  );
}
```

Upon successful sign-in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners receive the signed-in user.

### Popup and redirect helpers

On iOS and Android, `signInWithPopup` and `signInWithRedirect` start the same native provider flow, and `linkWithPopup` and `linkWithRedirect` start it for the signed-in user. All four resolve with a `UserCredential` when the native flow completes. They do not follow the browser redirect contract, so there is no pending result to collect later (`getRedirectResult` throws).

```js
import {
  OAuthProvider,
  getAuth,
  linkWithPopup,
  linkWithRedirect,
  signInWithPopup,
} from '@react-native-firebase/auth';

function createMicrosoftProvider() {
  const provider = new OAuthProvider('microsoft.com');
  provider.addScope('offline_access');
  // OAuthProvider satisfies AuthProvider at runtime; cast for the docs type harness.
  return /** @type {any} */ (provider);
}

async function signInWithMicrosoftPopup() {
  return signInWithPopup(getAuth(), createMicrosoftProvider());
}

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

  if (useRedirect) {
    return linkWithRedirect(user, createMicrosoftProvider());
  }
  return linkWithPopup(user, createMicrosoftProvider());
}

await signInWithMicrosoftPopup();
await linkMicrosoftToCurrentUser(false);
await linkMicrosoftToCurrentUser(true);
```

### Re-authenticate with a provider

`reauthenticateWithPopup(user, provider)` and `reauthenticateWithRedirect(user, provider)` run the native provider flow for the signed-in user, as a recent sign-in for sensitive operations. `reauthenticateWithPopup` resolves with a `UserCredential`. `reauthenticateWithRedirect` resolves with `void` once the native flow completes, unlike the firebase-js-sdk signature. Both reject when no user is signed in. Pass an `OAuthProvider` (the native bridge reads its provider ID, scopes and custom parameters).

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

function createMicrosoftProvider() {
  const provider = new OAuthProvider('microsoft.com');
  provider.addScope('offline_access');
  // OAuthProvider satisfies AuthProvider at runtime; cast for the docs type harness.
  return /** @type {any} */ (provider);
}

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

  return reauthenticateWithPopup(user, createMicrosoftProvider());
}

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

  await reauthenticateWithRedirect(user, createMicrosoftProvider());
}

await reauthenticateWithMicrosoftPopup();
await reauthenticateWithMicrosoftRedirect();
```

## Twitter

Using [`@react-native-twitter-signin/twitter-signin`](https://github.com/react-native-twitter-signin/twitter-signin), sign in with Twitter and build a Firebase credential. Install the library and complete its [prerequisites](https://github.com/react-native-twitter-signin/twitter-signin#prerequisites). Enable the **Twitter** provider in the Firebase Console.

The library exposes a native module. Initialize it with your Twitter consumer key and secret, then call `logIn`:

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

const { RNTwitterSignIn } = NativeModules;

async function initTwitterSdk() {
  await RNTwitterSignIn.init('TWITTER_CONSUMER_KEY', 'TWITTER_CONSUMER_SECRET');
  console.log('Twitter SDK initialized');
}

async function onTwitterButtonPress() {
  const { authToken, authTokenSecret } = await RNTwitterSignIn.logIn();
  const twitterCredential = TwitterAuthProvider.credential(authToken, authTokenSecret);
  return signInWithCredential(getAuth(), twitterCredential);
}

await initTwitterSdk();
await onTwitterButtonPress();
```

UI trigger:

```jsx
import React from 'react';
import { Button, NativeModules } from 'react-native';
import { TwitterAuthProvider, getAuth, signInWithCredential } from '@react-native-firebase/auth';

const { RNTwitterSignIn } = NativeModules;

async function onTwitterButtonPress() {
  const { authToken, authTokenSecret } = await RNTwitterSignIn.logIn();
  const twitterCredential = TwitterAuthProvider.credential(authToken, authTokenSecret);
  return signInWithCredential(getAuth(), twitterCredential);
}

function TwitterSignIn() {
  return (
    <Button
      title="Twitter Sign-In"
      onPress={() => onTwitterButtonPress().then(() => console.log('Signed in with Twitter!'))}
    />
  );
}
```

Upon successful sign-in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners receive the signed-in user.

## Link Multiple Auth Providers to a Firebase Account

[From the official documentation:](https://firebase.google.com/docs/auth/web/google-signin#expandable-1)

> If you enabled the **One account per email address** setting in the Firebase console, when a user tries to sign in a to a provider (such as Google) with an email that already exists for another Firebase user's provider (such as Facebook), the error `auth/account-exists-with-different-credential` is thrown along with an `AuthCredential` object (Google ID token). To complete the sign in to the intended provider, the user has to sign first to the existing provider (Facebook) and then link to the former `AuthCredential` (Google ID token).

To provide users with an additional login method, link their social account (or email and password) with their Firebase account.
This works for any social provider that uses `signInWithCredential()`.
Replace `signInWithCredential` with modular `linkWithCredential(user, credential)` on the signed-in user. Ensure `getAuth().currentUser` is not null before linking.

Firebase-only linking once you have a Google ID token:

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

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

  const googleCredential = GoogleAuthProvider.credential(idToken);
  return linkWithCredential(user, googleCredential);
}

await linkGoogleIdTokenToCurrentUser('GOOGLE_ID_TOKEN');
```

With [`react-native-nitro-google-signin`](https://www.npmjs.com/package/react-native-nitro-google-signin):

```js
// codeblock-ignore: react-native-nitro-google-signin is a third-party package; install it in your app
import { GoogleAuthProvider, getAuth, linkWithCredential } from '@react-native-firebase/auth';
import {
  GoogleOneTapSignIn,
  isNoSavedCredentialFoundResponse,
  isSuccessResponse,
} from 'react-native-nitro-google-signin';

async function onGoogleLinkButtonPress() {
  await GoogleOneTapSignIn.checkPlayServices();

  let response = await GoogleOneTapSignIn.signIn();
  if (isNoSavedCredentialFoundResponse(response)) {
    response = await GoogleOneTapSignIn.presentExplicitSignIn();
  }
  if (!isSuccessResponse(response) || !response.data?.idToken) {
    throw new Error('Google Sign-In failed');
  }

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

  const googleCredential = GoogleAuthProvider.credential(response.data.idToken);
  return linkWithCredential(user, googleCredential);
}
```

With the free `@react-native-google-signin/google-signin` (`GoogleSignin`) API:

```js
// codeblock-ignore: @react-native-google-signin/google-signin is a third-party package; install it in your app
// Google Sign-In v16 API (@react-native-google-signin/google-signin 16.x)
import { GoogleAuthProvider, getAuth, linkWithCredential } from '@react-native-firebase/auth';
import { GoogleSignin, isSuccessResponse } from '@react-native-google-signin/google-signin';

async function onGoogleLinkButtonPress() {
  await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true });
  const response = await GoogleSignin.signIn();

  if (!isSuccessResponse(response)) {
    throw new Error('Google Sign-In was canceled');
  }

  const idToken = response.data.idToken;
  if (!idToken) {
    throw new Error('No ID token found');
  }

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

  const googleCredential = GoogleAuthProvider.credential(idToken);
  return linkWithCredential(user, googleCredential);
}
```

## Remove a linked provider

Pass a provider ID from `user.providerData` to `unlink`. After you call `unlink`, signing in again with that provider creates a **new** Firebase user rather than restoring the previous link.

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

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

  return unlink(user, 'google.com');
}

await unlinkGoogleFromCurrentUser();
```
