Guide
How to use Social Login in Capacitor
Using @capgo/capacitor-social-login
All social logins in one plugin for Web, iOS, and Android. It supports Google, Apple, Facebook, Twitter/X, and generic OAuth2/OIDC providers such as GitHub, Microsoft Entra ID, Auth0, Okta, and Keycloak.
Install
npm install @capgo/capacitor-social-login
npx cap sync
What This Plugin Exposes
initialize- Initialize the plugin.login- Login with the selected provider.logout- Logout.isLoggedIn- IsLoggedIn.
Example Usage
initialize
Initialize the plugin.
import { SocialLogin } from '@capgo/capacitor-social-login';
await SocialLogin.initialize({ telegram: { botId: '123456789' } });
login
Login with the selected provider.
import { SocialLogin } from '@capgo/capacitor-social-login';
const result = await SocialLogin.login({
provider: 'facebook',
options: { permissions: ['permission'] },
});
// The result holds sensitive values: use it without logging it.
logout
Logout.
import { SocialLogin } from '@capgo/capacitor-social-login';
await SocialLogin.logout({} as {
provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'oauth2';
providerId?: string;
});
isLoggedIn
IsLoggedIn.
import { SocialLogin } from '@capgo/capacitor-social-login';
const result = await SocialLogin.isLoggedIn({ provider: 'apple' });
console.log(result);
Full Reference
- GitHub: https://github.com/Cap-go/capacitor-social-login/
- Docs: /docs/plugins/social-login/
Keep going from Using @capgo/capacitor-social-login
If you are using Using @capgo/capacitor-social-login to plan authentication and account flows, connect it with @capgo/capacitor-social-login for the implementation detail in @capgo/capacitor-social-login, Getting Started for the implementation detail in Getting Started, @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, and Two-factor authentication for the implementation detail in Two-factor authentication.