@capacitor-firebase/authentication

中文文档
8.6.0发布于 2026/10/31Apache-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 63.6万

Capacitor plugin for Firebase Authentication on Android, iOS, and Web.

原始使用文档
文档目录92 节
  1. Use Cases
  2. Compatibility
  3. Guides
  4. Installation
  5. iOS
  6. Configuration
  7. Examples
  8. Firebase JavaScript SDK
  9. Demo
  10. Starter templates
  11. Usage
  12. Sign up and sign in with email and password
  13. Sign in with a social provider
  14. Sign in with a phone number
  15. Sign in with an email link
  16. Sign in anonymously
  17. Sign in with a custom token or OpenID Connect
  18. Get the current user and ID token
  19. Send and confirm a password reset
  20. Verify the user's email address
  21. Update the user's email or password
  22. Look up sign-in methods for an email
  23. Set the language
  24. Sign out and delete the user
  25. Use the Firebase Emulator
  26. API
  27. applyActionCode(...)
  28. confirmPasswordReset(...)
  29. confirmVerificationCode(...)
  30. createUserWithEmailAndPassword(...)
  31. deleteUser()
  32. fetchSignInMethodsForEmail(...)
  33. getCurrentUser()
  34. getPendingAuthResult()
  35. getIdToken(...)
  36. getIdTokenResult(...)
  37. getRedirectResult()
  38. getTenantId()
  39. isSignInWithEmailLink(...)
  40. linkWithApple(...)
  41. linkWithEmailAndPassword(...)
  42. linkWithEmailLink(...)
  43. linkWithFacebook(...)
  44. linkWithGameCenter(...)
  45. linkWithGithub(...)
  46. linkWithGoogle(...)
  47. linkWithMicrosoft(...)
  48. linkWithOpenIdConnect(...)
  49. linkWithPhoneNumber(...)
  50. linkWithPlayGames(...)
  51. linkWithTwitter(...)
  52. linkWithYahoo(...)
  53. reload()
  54. revokeAccessToken(...)
  55. sendEmailVerification(...)
  56. sendPasswordResetEmail(...)
  57. sendSignInLinkToEmail(...)
  58. setLanguageCode(...)
  59. setPersistence(...)
  60. setTenantId(...)
  61. signInAnonymously()
  62. signInWithApple(...)
  63. signInWithCustomToken(...)
  64. signInWithEmailAndPassword(...)
  65. signInWithEmailLink(...)
  66. signInWithFacebook(...)
  67. signInWithGameCenter(...)
  68. signInWithGithub(...)
  69. signInWithGoogle(...)
  70. signInWithMicrosoft(...)
  71. signInWithOpenIdConnect(...)
  72. signInWithPhoneNumber(...)
  73. signInWithPlayGames(...)
  74. signInWithTwitter(...)
  75. signInWithYahoo(...)
  76. signOut()
  77. unlink(...)
  78. updateEmail(...)
  79. updatePassword(...)
  80. updateProfile(...)
  81. useAppLanguage()
  82. useEmulator(...)
  83. verifyBeforeUpdateEmail(...)
  84. checkAppTrackingTransparencyPermission()
  85. requestAppTrackingTransparencyPermission()
  86. addListener('authStateChange', ...)
  87. addListener('idTokenChange', ...)
  88. addListener('phoneVerificationCompleted', ...)
  89. addListener('phoneVerificationFailed', ...)
  90. addListener('phoneCodeSent', ...)
  91. removeAllListeners()
  92. Interfaces

Capacitor Firebase Authentication Plugin

Unofficial Capacitor plugin for Firebase Authentication.[^1]

Use Cases

The Firebase Authentication plugin is typically used to handle the entire sign-in flow of an app, for example:

  • Social logins: Sign in users natively with Apple, Google, Facebook, Microsoft, GitHub, Twitter, Yahoo, Play Games, or Game Center.
  • Email-based authentication: Register and sign in users with email and password, or send them a passwordless sign-in link.
  • Phone number sign-in: Verify users with an SMS code sent to their phone number.
  • Guest access: Let users try your app with anonymous sign-in and link a permanent account later.
  • Custom backends: Sign in with custom tokens or OpenID Connect and retrieve ID tokens to authenticate requests to your own backend.

Compatibility

Plugin VersionCapacitor VersionStatus
8.x.x>=8.x.xActive support
7.x.x7.x.xDeprecated
6.x.x6.x.xDeprecated
5.x.x5.x.xDeprecated
1.x.x4.x.xDeprecated

Guides

Installation

You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:

npx skills add capawesome-team/skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capacitor-firebase/authentication` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capacitor-firebase/authentication firebase
npx cap sync

Add Firebase to your project if you haven't already (Android / iOS / Web).

On iOS, verify that this function is included in your app's AppDelegate.swift:

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
  return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}

Attention: If you use this plugin on iOS in combination with @capacitor-firebase/messaging, then add the following to your app's AppDelegate.swift:

+ import FirebaseAuth

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
+    if Auth.auth().canHandle(url) {
+      return true
+    }
    return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}

The further installation steps depend on the selected authentication method:

Attention: Please note that this plugin uses third-party SDKs to offer native sign-in. These SDKs can initialize on their own and collect various data. For more information, see Third-Party SDKs.

iOS

Swift Package Manager

Add the following to your capacitor.config.json (or capacitor.config.ts) to avoid a SwiftPM package identity collision:

{
  "experimental": {
    "ios": {
      "spm": {
        "packageOptions": {
          "@capacitor-firebase/authentication": {
            "symlink": true
          }
        }
      }
    }
  }
}

Attention: SPM packageOptions support requires Capacitor CLI 8.4.0+.

Package traits

The GoogleSignIn and Facebook SDKs are optional and are included by default via the Google and Facebook package traits. If you do not use these providers, disable the corresponding trait so that the SDK is not linked into your app:

{
  "experimental": {
    "ios": {
      "spm": {
        "swiftToolsVersion": "6.1",
        "packageTraits": {
          "@capacitor-firebase/authentication": ["Google"]
        }
      }
    }
  }
}

Listing traits explicitly replaces the defaults, so only the traits you list are enabled. The example above keeps GoogleSignIn and excludes the Facebook SDK. Use the Lite trait to exclude both:

{
  "experimental": {
    "ios": {
      "spm": {
        "swiftToolsVersion": "6.1",
        "packageTraits": {
          "@capacitor-firebase/authentication": ["Lite"]
        }
      }
    }
  }
}

These traits are the Swift Package Manager equivalent of the CapacitorFirebaseAuthentication/Google, CapacitorFirebaseAuthentication/Facebook and CapacitorFirebaseAuthentication/Lite CocoaPods subspecs. Calling a sign-in method of a provider whose SDK is excluded rejects with an error.

Attention: SPM trait support requires Capacitor CLI 8.3.0+ and Xcode 16.3+ (Swift 6.1+).

Configuration

These configuration values are available:

PropTypeDescriptionDefaultSince
authDomainstringConfigure the custom auth domain you want to use. Only available for Android and iOS.7.3.0
skipNativeAuthbooleanConfigure whether the plugin should skip the native authentication. Only needed if you want to use the Firebase JavaScript SDK. This configuration option has no effect on Firebase account linking. Note that the plugin may behave differently across the platforms. Only available for Android and iOS.false0.1.0
providersstring[]Configure the providers that should be loaded by the plugin. Possible values: ["apple.com", "facebook.com", "gc.apple.com", "github.com", "google.com", "microsoft.com", "playgames.google.com", "twitter.com", "yahoo.com", "phone"] Only available for Android and iOS.[]0.1.0

Examples

In capacitor.config.json:

{
  "plugins": {
    "FirebaseAuthentication": {
      "authDomain": undefined,
      "skipNativeAuth": false,
      "providers": ["apple.com", "facebook.com"]
    }
  }
}

In capacitor.config.ts:

/// <reference types="@capacitor-firebase/authentication" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    FirebaseAuthentication: {
      authDomain: undefined,
      skipNativeAuth: false,
      providers: ["apple.com", "facebook.com"],
    },
  },
};

export default config;

Firebase JavaScript SDK

Here you can find information on how to use the plugin with the Firebase JS SDK.

Demo

A working example can be found here: robingenz/capacitor-firebase-authentication-demo

Starter templates

The following starter templates are available:

Usage

The following examples show how to sign in with email and password, social providers, a phone number, an email link, anonymously, and custom tokens, as well as how to manage the current user, reset passwords, verify and update email addresses, set the language, sign out, delete the user, and use the Firebase Emulator.

Sign up and sign in with email and password

Create a new user account with email and password and sign the user in with those credentials:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const createUserWithEmailAndPassword = async () => {
  const result = await FirebaseAuthentication.createUserWithEmailAndPassword({
    email: '[email protected]',
    password: '1234',
  });
  return result.user;
};

const signInWithEmailAndPassword = async () => {
  const result = await FirebaseAuthentication.signInWithEmailAndPassword({
    email: '[email protected]',
    password: '1234',
  });
  return result.user;
};

Sign in with a social provider

Sign in users natively with providers such as Apple, Google, Facebook, GitHub, Microsoft, Twitter or Yahoo. Each provider requires the setup steps linked in the Installation section. Game Center sign-in is only available on iOS and Play Games sign-in is only available on Android:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const signInWithApple = async () => {
  const result = await FirebaseAuthentication.signInWithApple();
  return result.user;
};

const signInWithFacebook = async () => {
  const result = await FirebaseAuthentication.signInWithFacebook();
  return result.user;
};

const signInWithGameCenter = async () => {
  const result = await FirebaseAuthentication.signInWithGameCenter();
  return result.user;
};

const signInWithGithub = async () => {
  const result = await FirebaseAuthentication.signInWithGithub();
  return result.user;
};

const signInWithGoogle = async () => {
  const result = await FirebaseAuthentication.signInWithGoogle();
  return result.user;
};

const signInWithMicrosoft = async () => {
  const result = await FirebaseAuthentication.signInWithMicrosoft();
  return result.user;
};

const signInWithPlayGames = async () => {
  const result = await FirebaseAuthentication.signInWithPlayGames();
  return result.user;
};

const signInWithTwitter = async () => {
  const result = await FirebaseAuthentication.signInWithTwitter();
  return result.user;
};

const signInWithYahoo = async () => {
  const result = await FirebaseAuthentication.signInWithYahoo();
  return result.user;
};

Sign in with a phone number

Start the phone number sign-in flow, which sends an SMS code to the user, and confirm the code with confirmVerificationCode(...). Only available on Android and iOS:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const signInWithPhoneNumber = async () => {
  return new Promise(async resolve => {
    // Attach `phoneCodeSent` listener to be notified as soon as the SMS is sent
    await FirebaseAuthentication.addListener('phoneCodeSent', async event => {
      // Ask the user for the SMS code
      const verificationCode = window.prompt(
        'Please enter the verification code that was sent to your mobile device.',
      );
      // Confirm the verification code
      const result = await FirebaseAuthentication.confirmVerificationCode({
        verificationId: event.verificationId,
        verificationCode,
      });
      resolve(result.user);
    });
    // Attach `phoneVerificationCompleted` listener to be notified if phone verification could be finished automatically
    await FirebaseAuthentication.addListener(
      'phoneVerificationCompleted',
      async event => {
        resolve(event.result.user);
      },
    );
    // Start sign in with phone number and send the SMS
    await FirebaseAuthentication.signInWithPhoneNumber({
      phoneNumber: '123456789',
    });
  });
};

Send a passwordless sign-in link to the user's email address and complete the sign-in once the link is opened:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const sendSignInLinkToEmail = async () => {
  const email = '[email protected]';
  await FirebaseAuthentication.sendSignInLinkToEmail({
    email,
    actionCodeSettings: {
      // URL you want to redirect back to. The domain (www.example.com) for this
      // URL must be in the authorized domains list in the Firebase Console.
      url: 'https://www.example.com/finishSignUp?cartId=1234',
      // This must be true.
      handleCodeInApp: true,
      iOS: {
        bundleId: 'com.example.ios',
      },
      android: {
        packageName: 'com.example.android',
        installApp: true,
        minimumVersion: '12',
      },
      dynamicLinkDomain: 'example.page.link',
    },
  });
  // The link was successfully sent. Inform the user.
  // Save the email locally so you don't need to ask the user for it again
  // if they open the link on the same device.
  window.localStorage.setItem('emailForSignIn', email);
};

const signInWithEmailLink = async () => {
  // Get the email if available. This should be available if the user completes
  // the flow on the same device where they started it.
  const emailLink = window.location.href;
  // Confirm the link is a sign-in with email link.
  const { isSignInWithEmailLink } =
    await FirebaseAuthentication.isSignInWithEmailLink({
      emailLink,
    });
  if (!isSignInWithEmailLink) {
    return;
  }
  let email = window.localStorage.getItem('emailForSignIn');
  if (!email) {
    // User opened the link on a different device. To prevent session fixation
    // attacks, ask the user to provide the associated email again.
    email = window.prompt('Please provide your email for confirmation.');
  }
  // The client SDK will parse the code from the link for you.
  const result = await FirebaseAuthentication.signInWithEmailLink({
    email,
    emailLink,
  });
  // Clear email from storage.
  window.localStorage.removeItem('emailForSignIn');
  return result.user;
};

Sign in anonymously

Sign in a user anonymously, for example to let users try your app before creating an account:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const signInAnonymously = async () => {
  const result = await FirebaseAuthentication.signInAnonymously();
  return result.user;
};

Sign in with a custom token or OpenID Connect

Authenticate against your own backend with a custom token or use any OpenID Connect provider:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const signInWithCustomToken = async () => {
  const result = await FirebaseAuthentication.signInWithCustomToken({
    token: '1234',
  });
  return result.user;
};

const signInWithOpenIdConnect = async () => {
  const result = await FirebaseAuthentication.signInWithOpenIdConnect({
    providerId: 'oidc.example.com',
  });
  return result.user;
};

Get the current user and ID token

Retrieve the currently signed-in user, their ID token, or the result of a pending authentication operation. The getPendingAuthResult() method is only available on Android:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const getCurrentUser = async () => {
  const result = await FirebaseAuthentication.getCurrentUser();
  return result.user;
};

const getIdToken = async () => {
  const currentUser = await getCurrentUser();
  if (!currentUser) {
    return;
  }
  const result = await FirebaseAuthentication.getIdToken();
  return result.token;
};

const getPendingAuthResult = async () => {
  const result = await FirebaseAuthentication.getPendingAuthResult();
  return result.user;
};

Send and confirm a password reset

Send a password reset email to the user and confirm the password reset with the received out-of-band code:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const sendPasswordResetEmail = async () => {
  await FirebaseAuthentication.sendPasswordResetEmail({
    email: '[email protected]',
  });
};

const confirmPasswordReset = async () => {
  await FirebaseAuthentication.confirmPasswordReset({
    oobCode: '1234',
    newPassword: '4321',
  });
};

Verify the user's email address

Send a verification email to the currently signed-in user and apply the received out-of-band code:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const sendEmailVerification = async () => {
  const currentUser = await getCurrentUser();
  if (!currentUser) {
    return;
  }
  await FirebaseAuthentication.sendEmailVerification();
};

const applyActionCode = async () => {
  await FirebaseAuthentication.applyActionCode({ oobCode: '1234' });
};

Update the user's email or password

Update the email address or password of the currently signed-in user. With verifyBeforeUpdateEmail(...), the new email address is verified before it is updated:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const updateEmail = async () => {
  const currentUser = await getCurrentUser();
  if (!currentUser) {
    return;
  }
  await FirebaseAuthentication.updateEmail({
    newEmail: '[email protected]',
  });
};

const verifyBeforeUpdateEmail = async () => {
  const currentUser = await getCurrentUser();
  if (!currentUser) {
    return;
  }
  await FirebaseAuthentication.verifyBeforeUpdateEmail({
    newEmail: '[email protected]',
    actionCodeSettings: {
      url: 'https://www.example.com/[email protected]&cartId=123',
      iOS: {
        bundleId: 'com.example.ios'
      },
      android: {
        packageName: 'com.example.android',
        installApp: true,
        minimumVersion: '12'
      },
      handleCodeInApp: true
    }
  });
};

const updatePassword = async () => {
  const currentUser = await getCurrentUser();
  if (!currentUser) {
    return;
  }
  await FirebaseAuthentication.updatePassword({
    newPassword: '4321',
  });
};

Look up sign-in methods for an email

Fetch the sign-in methods that are available for an email address:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const fetchSignInMethodsForEmail = async () => {
  const result = await FirebaseAuthentication.fetchSignInMethodsForEmail({
    email: '[email protected]',
  });
  return result.signInMethods;
};

Set the language

Set the language code to use, or apply the current app language:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const setLanguageCode = async () => {
  await FirebaseAuthentication.setLanguageCode({ languageCode: 'en-US' });
};

const useAppLanguage = async () => {
  await FirebaseAuthentication.useAppLanguage();
};

Sign out and delete the user

Sign out the current user or permanently delete the user account:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const signOut = async () => {
  await FirebaseAuthentication.signOut();
};

const deleteUser = async () => {
  await FirebaseAuthentication.deleteUser();
};

Use the Firebase Emulator

Connect the plugin to a local Firebase Emulator instance during development:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

const useEmulator = async () => {
  await FirebaseAuthentication.useEmulator({
    host: '10.0.2.2',
    port: 9099,
  });
};

API

applyActionCode(...)

applyActionCode(options: ApplyActionCodeOptions) => Promise<void>

Applies a verification code sent to the user by email.

ParamType
optionsApplyActionCodeOptions

Since: 0.2.2


confirmPasswordReset(...)

confirmPasswordReset(options: ConfirmPasswordResetOptions) => Promise<void>

Completes the password reset process.

ParamType
optionsConfirmPasswordResetOptions

Since: 0.2.2


confirmVerificationCode(...)

confirmVerificationCode(options: ConfirmVerificationCodeOptions) => Promise<SignInResult>

Finishes the phone number verification process.

ParamType
optionsConfirmVerificationCodeOptions

Returns: Promise<SignInResult>

Since: 5.0.0


createUserWithEmailAndPassword(...)

createUserWithEmailAndPassword(options: CreateUserWithEmailAndPasswordOptions) => Promise<SignInResult>

Creates a new user account with email and password. If the new account was created, the user is signed in automatically.

ParamType
optionsCreateUserWithEmailAndPasswordOptions

Returns: Promise<SignInResult>

Since: 0.2.2


deleteUser()

deleteUser() => Promise<void>

Deletes and signs out the user.

Since: 1.3.0


fetchSignInMethodsForEmail(...)

fetchSignInMethodsForEmail(options: FetchSignInMethodsForEmailOptions) => Promise<FetchSignInMethodsForEmailResult>

Fetches the sign-in methods for an email address.

ParamType
optionsFetchSignInMethodsForEmailOptions

Returns: Promise<FetchSignInMethodsForEmailResult>

Since: 6.0.0


getCurrentUser()

getCurrentUser() => Promise<GetCurrentUserResult>

Fetches the currently signed-in user.

Returns: Promise<GetCurrentUserResult>

Since: 0.1.0


getPendingAuthResult()

getPendingAuthResult() => Promise<SignInResult>

Returns the SignInResult if your app launched a web sign-in flow and the OS cleans up the app while in the background.

Only available for Android.

Returns: Promise<SignInResult>

Since: 6.0.0


getIdToken(...)

getIdToken(options?: GetIdTokenOptions | undefined) => Promise<GetIdTokenResult>

Fetches the Firebase Auth ID Token for the currently signed-in user.

ParamType
optionsGetIdTokenOptions

Returns: Promise<GetIdTokenResult>

Since: 0.1.0


getIdTokenResult(...)

getIdTokenResult(options?: GetIdTokenResultOptions | undefined) => Promise<GetIdTokenResultResult>

Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service.

ParamType
optionsGetIdTokenResultOptions

Returns: Promise<GetIdTokenResultResult>

Since: 7.4.0


getRedirectResult()

getRedirectResult() => Promise<SignInResult>

Returns the SignInResult from the redirect-based sign-in flow.

If sign-in was unsuccessful, fails with an error. If no redirect operation was called, returns a SignInResult with a null user.

Only available for Web.

Returns: Promise<SignInResult>

Since: 1.3.0


getTenantId()

getTenantId() => Promise<GetTenantIdResult>

Get the tenant id.

Returns: Promise<GetTenantIdResult>

Since: 1.1.0


isSignInWithEmailLink(options: IsSignInWithEmailLinkOptions) => Promise<IsSignInWithEmailLinkResult>

Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink.

ParamType
optionsIsSignInWithEmailLinkOptions

Returns: Promise<IsSignInWithEmailLinkResult>

Since: 1.1.0


linkWithApple(...)

linkWithApple(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with Apple authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithEmailAndPassword(...)

linkWithEmailAndPassword(options: LinkWithEmailAndPasswordOptions) => Promise<LinkResult>

Links the user account with Email authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsLinkWithEmailAndPasswordOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithEmailLink(options: LinkWithEmailLinkOptions) => Promise<LinkResult>

Links the user account with Email authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsLinkWithEmailLinkOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithFacebook(...)

linkWithFacebook(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with Facebook authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithGameCenter(...)

linkWithGameCenter(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with Game Center authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

Only available for iOS.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.3.0


linkWithGithub(...)

linkWithGithub(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with GitHub authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithGoogle(...)

linkWithGoogle(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with Google authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithMicrosoft(...)

linkWithMicrosoft(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with Microsoft authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithOpenIdConnect(...)

linkWithOpenIdConnect(options: LinkWithOpenIdConnectOptions) => Promise<LinkResult>

Links the user account with an OpenID Connect provider.

ParamType
optionsSignInWithOpenIdConnectOptions

Returns: Promise<SignInResult>

Since: 6.1.0


linkWithPhoneNumber(...)

linkWithPhoneNumber(options: LinkWithPhoneNumberOptions) => Promise<void>

Links the user account with Phone Number authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

Use the phoneVerificationCompleted listener to be notified when the verification is completed. Use the phoneVerificationFailed listener to be notified when the verification is failed. Use the phoneCodeSent listener to get the verification id.

ParamType
optionsSignInWithPhoneNumberOptions

Since: 1.1.0


linkWithPlayGames(...)

linkWithPlayGames(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with Play Games authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

Only available for Android.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithTwitter(...)

linkWithTwitter(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with Twitter authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.1.0


linkWithYahoo(...)

linkWithYahoo(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>

Links the user account with Yahoo authentication provider.

The user must be logged in on the native layer. The skipNativeAuth configuration option has no effect here.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 1.1.0


reload()

reload() => Promise<void>

Reloads user account data, if signed in.

Since: 1.3.0


revokeAccessToken(...)

revokeAccessToken(options: RevokeAccessTokenOptions) => Promise<void>

Revokes the given access token. Currently only supports Apple OAuth access tokens.

ParamType
optionsRevokeAccessTokenOptions

Since: 6.1.0


sendEmailVerification(...)

sendEmailVerification(options?: SendEmailVerificationOptions | undefined) => Promise<void>

Sends a verification email to the currently signed in user.

ParamType
optionsSendEmailVerificationOptions

Since: 0.2.2


sendPasswordResetEmail(...)

sendPasswordResetEmail(options: SendPasswordResetEmailOptions) => Promise<void>

Sends a password reset email.

ParamType
optionsSendPasswordResetEmailOptions

Since: 0.2.2


sendSignInLinkToEmail(...)

sendSignInLinkToEmail(options: SendSignInLinkToEmailOptions) => Promise<void>

Sends a sign-in email link to the user with the specified email.

To complete sign in with the email link, call signInWithEmailLink with the email address and the email link supplied in the email sent to the user.

ParamType
optionsSendSignInLinkToEmailOptions

Since: 1.1.0


setLanguageCode(...)

setLanguageCode(options: SetLanguageCodeOptions) => Promise<void>

Sets the user-facing language code for auth operations.

ParamType
optionsSetLanguageCodeOptions

Since: 0.1.0


setPersistence(...)

setPersistence(options: SetPersistenceOptions) => Promise<void>

Sets the type of persistence for the currently saved auth session.

Only available for Web.

ParamType
optionsSetPersistenceOptions

Since: 5.2.0


setTenantId(...)

setTenantId(options: SetTenantIdOptions) => Promise<void>

Sets the tenant id.

ParamType
optionsSetTenantIdOptions

Since: 1.1.0


signInAnonymously()

signInAnonymously() => Promise<SignInResult>

Signs in as an anonymous user.

Returns: Promise<SignInResult>

Since: 1.1.0


signInWithApple(...)

signInWithApple(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>

Starts the Apple sign-in flow.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signInWithCustomToken(...)

signInWithCustomToken(options: SignInWithCustomTokenOptions) => Promise<SignInResult>

Starts the Custom Token sign-in flow.

This method cannot be used in combination with skipNativeAuth on Android and iOS. In this case you have to use the signInWithCustomToken interface of the Firebase JS SDK directly.

ParamType
optionsSignInWithCustomTokenOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signInWithEmailAndPassword(...)

signInWithEmailAndPassword(options: SignInWithEmailAndPasswordOptions) => Promise<SignInResult>

Starts the sign-in flow using an email and password.

ParamType
optionsSignInWithEmailAndPasswordOptions

Returns: Promise<SignInResult>

Since: 0.2.2


signInWithEmailLink(options: SignInWithEmailLinkOptions) => Promise<SignInResult>

Signs in using an email and sign-in email link.

ParamType
optionsSignInWithEmailLinkOptions

Returns: Promise<SignInResult>

Since: 1.1.0


signInWithFacebook(...)

signInWithFacebook(options?: SignInWithFacebookOptions | undefined) => Promise<SignInResult>

Starts the Facebook sign-in flow.

ParamType
optionsSignInWithFacebookOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signInWithGameCenter(...)

signInWithGameCenter(options?: SignInWithOAuthOptions | SignInOptions | undefined) => Promise<SignInResult>

Starts the Game Center sign-in flow.

Only available for iOS.

ParamType
optionsSignInWithOAuthOptions | SignInOptions

Returns: Promise<SignInResult>

Since: 1.3.0


signInWithGithub(...)

signInWithGithub(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>

Starts the GitHub sign-in flow.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signInWithGoogle(...)

signInWithGoogle(options?: SignInWithGoogleOptions | undefined) => Promise<SignInResult>

Starts the Google sign-in flow.

ParamType
optionsSignInWithGoogleOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signInWithMicrosoft(...)

signInWithMicrosoft(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>

Starts the Microsoft sign-in flow.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signInWithOpenIdConnect(...)

signInWithOpenIdConnect(options: SignInWithOpenIdConnectOptions) => Promise<SignInResult>

Starts the OpenID Connect sign-in flow.

ParamType
optionsSignInWithOpenIdConnectOptions

Returns: Promise<SignInResult>

Since: 6.1.0


signInWithPhoneNumber(...)

signInWithPhoneNumber(options: SignInWithPhoneNumberOptions) => Promise<void>

Starts the sign-in flow using a phone number.

Use the phoneVerificationCompleted listener to be notified when the verification is completed. Use the phoneVerificationFailed listener to be notified when the verification is failed. Use the phoneCodeSent listener to get the verification id.

Only available for Android and iOS.

ParamType
optionsSignInWithPhoneNumberOptions

Since: 0.1.0


signInWithPlayGames(...)

signInWithPlayGames(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>

Starts the Play Games sign-in flow.

Only available for Android.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signInWithTwitter(...)

signInWithTwitter(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>

Starts the Twitter sign-in flow.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signInWithYahoo(...)

signInWithYahoo(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>

Starts the Yahoo sign-in flow.

ParamType
optionsSignInWithOAuthOptions

Returns: Promise<SignInResult>

Since: 0.1.0


signOut()

signOut() => Promise<void>

Starts the sign-out flow.

Since: 0.1.0


unlink(options: UnlinkOptions) => Promise<UnlinkResult>

Unlinks a provider from a user account.

ParamType
optionsUnlinkOptions

Returns: Promise<UnlinkResult>

Since: 1.1.0


updateEmail(...)

updateEmail(options: UpdateEmailOptions) => Promise<void>

Updates the email address of the currently signed in user.

ParamType
optionsUpdateEmailOptions

Since: 0.1.0


updatePassword(...)

updatePassword(options: UpdatePasswordOptions) => Promise<void>

Updates the password of the currently signed in user.

ParamType
optionsUpdatePasswordOptions

Since: 0.1.0


updateProfile(...)

updateProfile(options: UpdateProfileOptions) => Promise<void>

Updates a user's profile data.

ParamType
optionsUpdateProfileOptions

Since: 1.3.0


useAppLanguage()

useAppLanguage() => Promise<void>

Sets the user-facing language code to be the default app language.

Since: 0.1.0


useEmulator(...)

useEmulator(options: UseEmulatorOptions) => Promise<void>

Instrument your app to talk to the Authentication emulator.

ParamType
optionsUseEmulatorOptions

Since: 0.2.0


verifyBeforeUpdateEmail(...)

verifyBeforeUpdateEmail(options: VerifyBeforeUpdateEmailOptions) => Promise<void>

Verifies the new email address before updating the email address of the currently signed in user.

ParamType
optionsVerifyBeforeUpdateEmailOptions

Since: 6.3.0


checkAppTrackingTransparencyPermission()

checkAppTrackingTransparencyPermission() => Promise<CheckAppTrackingTransparencyPermissionResult>

Checks the current status of app tracking transparency.

Only available on iOS.

Returns: Promise<CheckAppTrackingTransparencyPermissionResult>

Since: 7.2.0


requestAppTrackingTransparencyPermission()

requestAppTrackingTransparencyPermission() => Promise<RequestAppTrackingTransparencyPermissionResult>

Opens the system dialog to authorize app tracking transparency.

Attention: The user may have disabled the tracking request in the device settings, see Apple's documentation.

Only available on iOS.

Returns: Promise<CheckAppTrackingTransparencyPermissionResult>

Since: 7.2.0


addListener('authStateChange', ...)

addListener(eventName: 'authStateChange', listenerFunc: AuthStateChangeListener) => Promise<PluginListenerHandle>

Listen for the user's sign-in state changes.

Attention: This listener is not triggered when the skipNativeAuth is used. Use the Firebase JavaScript SDK instead.

ParamType
eventName'authStateChange'
listenerFuncAuthStateChangeListener

Returns: Promise<PluginListenerHandle>

Since: 0.1.0


addListener('idTokenChange', ...)

addListener(eventName: 'idTokenChange', listenerFunc: IdTokenChangeListener) => Promise<PluginListenerHandle>

Listen to ID token changes for the currently signed-in user.

Attention: This listener is not triggered when the skipNativeAuth is used. Use the Firebase JavaScript SDK instead.

ParamType
eventName'idTokenChange'
listenerFuncIdTokenChangeListener

Returns: Promise<PluginListenerHandle>

Since: 6.3.0


addListener('phoneVerificationCompleted', ...)

addListener(eventName: 'phoneVerificationCompleted', listenerFunc: PhoneVerificationCompletedListener) => Promise<PluginListenerHandle>

Listen for a completed phone verification.

This listener only fires in two situations:

  1. Instant verification: In some cases the phone number can be instantly verified without needing to send or enter a verification code.
  2. Auto-retrieval: On some devices Google Play services can automatically detect the incoming verification SMS and perform verification without user action.

Only available for Android.

ParamType
eventName'phoneVerificationCompleted'
listenerFuncPhoneVerificationCompletedListener

Returns: Promise<PluginListenerHandle>

Since: 1.3.0


addListener('phoneVerificationFailed', ...)

addListener(eventName: 'phoneVerificationFailed', listenerFunc: PhoneVerificationFailedListener) => Promise<PluginListenerHandle>

Listen for a failed phone verification.

ParamType
eventName'phoneVerificationFailed'
listenerFuncPhoneVerificationFailedListener

Returns: Promise<PluginListenerHandle>

Since: 1.3.0


addListener('phoneCodeSent', ...)

addListener(eventName: 'phoneCodeSent', listenerFunc: PhoneCodeSentListener) => Promise<PluginListenerHandle>

Listen for a phone verification code.

ParamType
eventName'phoneCodeSent'
listenerFuncPhoneCodeSentListener

Returns: Promise<PluginListenerHandle>

Since: 1.3.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 0.1.0


Interfaces

ApplyActionCodeOptions

PropTypeDescriptionSince
oobCodestringA verification code sent to the user.0.2.2

ConfirmPasswordResetOptions

PropTypeDescriptionSince
oobCodestringA verification code sent to the user.0.2.2
newPasswordstringThe new password.

版本与发布记录

@capacitor-firebase/authentication 共发布 98 个版本,首次发布于 2022/03/20;过去 12 个月发布了 15 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.6.0latest2026/10/319 天前
8.5.22026/09/171 个月前
8.5.12026/09/022 个月前
8.5.02026/08/312 个月前
8.4.02026/08/122 个月前
8.3.02026/06/045 个月前

其他发布通道:dev → 8.0.0-dev.a9a3525.1766035511。

关于 @capacitor-firebase/authentication 的常见问题

@capacitor-firebase/authentication 是什么?

Capacitor plugin for Firebase Authentication on Android, iOS, and Web.

如何安装 @capacitor-firebase/authentication?

在项目目录运行 npm install @capacitor-firebase/authentication,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capacitor-firebase/authentication 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capacitor-firebase/authentication 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capacitor-firebase/authentication 可以商用吗?

@capacitor-firebase/authentication 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@capacitor-firebase/authentication 的下载量有多少?

根据 npm 官方下载统计,@capacitor-firebase/authentication 在 2026/10/09 – 2026/11/07 这 30 天内被下载 635,517 次,日均约 21,184 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capacitor-firebase/authentication 还在维护吗?

最新版本 8.6.0 发布于 2026/10/31(9 天前);至今共发布 98 个版本,其中过去 12 个月发布了 15 个;首次发布于 2022/03/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。