RefirebaseRefirebase

NativeFirebaseAuth

new

Auth class for React Native/Expo using credential-based sign-in flows.

Google Sign-In

Requires @react-native-google-signin/google-signin. You obtain an idToken from the native SDK and pass it to Refirebase.

Google Sign-In
// 1. Configure Google Sign-In (once, e.g. in app init)
import { GoogleSignin } from '@react-native-google-signin/google-signin';
GoogleSignin.configure({ webClientId: 'YOUR_WEB_CLIENT_ID' });

// 2. Sign in
const { idToken } = await GoogleSignin.signIn();
const { data, error } = await auth.handleGoogleSignIn({ idToken });

if (error) {
  console.error(error.code, error.message);
}

Facebook Login

Requires react-native-fbsdk-next or similar. Pass the accessToken from Facebook's Login SDK.

Facebook Login
import { LoginManager, AccessToken } from 'react-native-fbsdk-next';

await LoginManager.logInWithPermissions(['public_profile', 'email']);
const token = await AccessToken.getCurrentAccessToken();

const { data, error } = await auth.handleFacebookSignIn({
  accessToken: token.accessToken,
});
All methods return { data, error }. The errorincludes a user-friendly message and Firebase code.

Methods

ParamTypeDescription
handleGoogleSignIn({ idToken, accessToken? }) => PromiseSign in with a Google ID token from the native SDK.
handleFacebookSignIn({ accessToken }) => PromiseSign in with a Facebook access token from the native SDK.
handleCredentialSignIn(credential) => PromiseSign in with any Firebase AuthCredential (escape hatch).
handleSignOut() => PromiseSign out the current user.
onAuthStateChanged(callback) => unsubscribeListen for auth state changes.
nativeAuthUnderlying Firebase Auth instance (escape hatch).