React Native Google Credential

Firebase Auth

Sign in to Firebase Auth with native Google credentials.

Native Google sign-in for Firebase

Firebase Auth can create a session from a Google credential, but React Native Firebase does not ship the Google sign-in UI. Their social auth docs leave the Google OAuth flow to the app, then use GoogleAuthProvider.credential() and signInWithCredential() once an ID token is available.

The Firebase adapter fills that gap with the same platform-native Google credential flow used by the rest of this package:

  • Android can use Credential Manager.
  • iOS can use native Google Sign-In.
  • Web can use Google Identity Services.

The adapter collects a Google ID token, turns it into a Firebase Google credential, and signs in with Firebase Auth.

Provider configuration

In Firebase Console, enable Google:

Authentication -> Sign-in method -> Google

For Android, make sure each app signing certificate fingerprint is registered in Firebase or Google Cloud. For iOS, include the Firebase config file and URL scheme setup required by your app.

Install

Install React Native Firebase before importing its adapter:

npm install @react-native-firebase/app @react-native-firebase/auth

Keep @react-native-firebase/app and @react-native-firebase/auth on the same version. The adapter supports Auth 23.8.8, 24.0.x, 24.1.1, 25.x, and 26.x. Version 24.1.0 is excluded because React Native Firebase replaced it with 24.1.1 to revert an upstream Firebase iOS SDK startup regression. See the React Native Firebase release notes.

Expo native configuration

This package's config plugin installs the Google credential module and writes the iOS Google client configuration. It does not configure React Native Firebase. Add the React Native Firebase config plugins and follow the React Native Firebase Expo installation guide for the exact version installed in your application.

The iOS linkage differs across the supported React Native Firebase releases:

  • React Native Firebase 23, 24, and 25 use the CocoaPods/static-framework setup.
  • React Native Firebase 26 uses Swift Package Manager and dynamic frameworks by default on supported React Native versions.
  • React Native Firebase 26 can opt out of Swift Package Manager, but its CocoaPods/static setup must include the documented disableSPM and static linking configuration.

For the default React Native Firebase 26 setup, include its plugins and dynamic framework configuration alongside this package:

export default {
  plugins: [
    "@react-native-firebase/app",
    "@react-native-firebase/auth",
    [
      "expo-build-properties",
      {
        ios: {
          useFrameworks: "dynamic",
        },
      },
    ],
    [
      "@pricava/react-native-google-credential",
      { iosClientId, iosUrlScheme },
    ],
  ],
};

For React Native Firebase 23, 24, or 25, use "static" instead of "dynamic" and follow that release's CocoaPods installation instructions.

Do not add Firebase pods or use_modular_headers! manually. Let React Native Firebase and expo-build-properties generate the supported native setup.

Plug-and-play integration

Use createFirebaseGoogleAuth for the standard React Native Firebase integration. Pass the Firebase Auth instance directly:

Use this approach when:

  • You want a standard Google sign-in with Firebase Auth.
  • You want Firebase credential creation handled automatically.
  • You use the normal signInWithCredential() flow.
  • You want the shortest setup with React Native Firebase.
import { getAuth } from "@react-native-firebase/auth";
import { createFirebaseGoogleAuth } from "@pricava/react-native-google-credential/adapters/firebase";

const auth = getAuth();

const signInWithGoogle = createFirebaseGoogleAuth({
  auth,
  webClientId,
  iosClientId,
});

const userCredential = await signInWithGoogle();

The adapter creates the Firebase Google credential and calls signInWithCredential() internally.

Expo example

import { useMemo } from "react";
import { Button } from "react-native";
import { getAuth } from "@react-native-firebase/auth";
import { createFirebaseGoogleAuth } from "@pricava/react-native-google-credential/adapters/firebase";

export function GoogleButton() {
  const signInWithGoogle = useMemo(
    () =>
      createFirebaseGoogleAuth({
        auth: getAuth(),
        webClientId: process.env.EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID!,
        iosClientId: process.env.EXPO_PUBLIC_GOOGLE_IOS_CLIENT_ID,
      }),
    [],
  );

  return (
    <Button title="Continue with Google" onPress={() => signInWithGoogle()} />
  );
}

Custom integration

Use createFirebaseGoogleAuthAdapter when you need to control Firebase credential creation or the operation performed with that credential:

Use this approach when:

  • You want to link Google to an existing Firebase user.
  • You need analytics or custom processing around Firebase sign-in.
  • You want to use a different Firebase credential operation.
  • You need control over credential creation and the returned result.
import {
  getAuth,
  GoogleAuthProvider,
  signInWithCredential,
} from "@react-native-firebase/auth";
import { createFirebaseGoogleAuthAdapter } from "@pricava/react-native-google-credential/adapters/firebase";

const auth = getAuth();

const signInWithGoogle = createFirebaseGoogleAuthAdapter({
  credentialOptions: {
    webClientId,
    iosClientId,
  },
  createGoogleCredential: (idToken) => GoogleAuthProvider.credential(idToken),
  signInWithCredential: async (credential) => {
    analytics.track("firebase_google_sign_in_started");

    const userCredential = await signInWithCredential(auth, credential);

    analytics.identify(userCredential.user.uid);
    return userCredential;
  },
});

const userCredential = await signInWithGoogle();

The callback factory can also perform a different Firebase credential operation, such as linking Google to the current user:

const linkGoogleAccount = createFirebaseGoogleAuthAdapter({
  credentialOptions: {
    webClientId,
    iosClientId,
  },
  createGoogleCredential: GoogleAuthProvider.credential,
  signInWithCredential: async (credential) => {
    const user = auth.currentUser;

    if (!user) {
      throw new Error("A Firebase user must be signed in.");
    }

    return user.linkWithCredential(credential);
  },
});

const linkedUser = await linkGoogleAccount();

Firebase receives only the Google ID token-derived credential. Firebase still owns the Firebase user, session, auth state listeners, and token refresh.

On this page