Skip to main content

Firebase authentication

Not yet available (2.4.x)

The Firebase provider is not enabled yet. Only Google is live right now — calling auth.signIn() with this provider throws AuthErrorCode.PROVIDER_NOT_ENABLED. The page below documents its intended shape for when it is re-enabled. (This package is Firebase-agnostic — to use Firebase today, sign in with the Google provider and hand the id token to signInWithCredential yourself; see the Google provider.) See the provider overview.

The Firebase provider signs users in with the Firebase JS SDK. It initializes a Firebase app from your config and dispatches sign-in to a sub-method (Google, Facebook, GitHub, Microsoft, Apple, email/password, or anonymous), defaulting to the defaultMethod you configure.

When you need a backend

No backend is required for the browser sign-in — Firebase Authentication handles the flow. Use the Firebase Admin SDK on a server only if you need to verify Firebase ID tokens or manage users server-side.

Configuration

import { auth } from 'capacitor-auth-manager';

auth.configure({
providers: {
firebase: {
apiKey: 'YOUR_FIREBASE_API_KEY',
authDomain: 'your-app.firebaseapp.com',
projectId: 'your-app',
appId: 'YOUR_FIREBASE_APP_ID',
defaultMethod: 'google',
},
},
});

Options

From the FirebaseAuthOptions interface in src/definitions.ts:

OptionTypeRequiredPurpose
apiKeystringYesFirebase web API key.
authDomainstringYesFirebase auth domain.
projectIdstringYesFirebase project ID.
appIdstringYesFirebase app ID.
storageBucketstringNoFirebase storage bucket.
messagingSenderIdstringNoCloud Messaging sender ID.
measurementIdstringNoAnalytics measurement ID.
tenantIdstringNoIdentity Platform tenant ID.
persistence'local' | 'session' | 'none'NoFirebase Auth state persistence.
enableMultiTabSupportbooleanNoEnable multi-tab persistence support.
defaultMethod'google' | 'facebook' | 'github' | 'microsoft' | 'apple' | 'email' | 'anonymous'NoFallback sub-method when signIn is called without an explicit method and no email/password credentials. Defaults to 'google'.

Sign in

// Uses defaultMethod (e.g. 'google')
await auth.signIn('firebase');

// Email/password sub-method via credentials
await auth.signIn({
provider: 'firebase',
credentials: { email: 'user@example.com', password: 'secure-password' },
});

Notes & caveats

  • When email and password credentials are supplied, the provider uses the email sub-method; otherwise it uses defaultMethod (default 'google').
  • OAuth sub-methods use Firebase's signInWithPopup, so a blocked popup prevents completion.
  • The library does not verify Firebase ID-token signatures itself; use the Firebase Admin SDK server-side to verify tokens you trust for authorization.