FirebaseUI Auth is a library built on top of the Firebase Authentication SDK that provides drop-in UI flows for use in your app.
Caution: Version 10.x is currently a beta release. This means that the functionality might change in backward-incompatible ways or have limited support. A beta release is not subject to any SLA or deprecation policy.
The recommended sign-in flow uses Compose screens. For apps that still use Activities, see the Existing Activity-based apps section.
FirebaseUI Auth provides the following benefits:
- Credential Manager integration for faster sign-in on Android.
- Material 3 UI that can inherit your app theme.
- Multiple authentication providers, including email/password, phone, Google, Facebook, Apple, GitHub, Microsoft, Yahoo, Twitter, anonymous auth, and custom OAuth.
- Multi-factor authentication support, including SMS and TOTP.
- Built-in flows for account management, account linking, and anonymous user upgrade.
- If you haven't already, add Firebase to your Android project.
- In the Firebase console, enable the sign-in methods you want to support.
- Add FirebaseUI Auth to your app module
Add FirebaseUI Auth to your app module:
dependencies {
// Check Maven Central for the latest version:
// https://central.sonatype.com/artifact/com.firebaseui/firebase-ui-auth/versions
implementation("com.firebaseui:firebase-ui-auth:10.0.0-beta02")
// Required only if Facebook login support is required
// Find the latest Facebook SDK releases here: https://goo.gl/Ce5L94
implementation("com.facebook.android:facebook-android-sdk:8.x")
}Some providers need additional setup before you can sign users in:
- Sign in with Google
- Facebook Login
- Sign in with Apple
- Sign in with Twitter
- Sign in with Github
- Sign in with Microsoft
- Sign in with Yahoo
Apple, GitHub, Microsoft, Yahoo, Twitter and custom OAuth providers are configured in Firebase Authentication. Most of them do not require extra Android-specific resources.
Choose the providers you want inside authUIConfiguration:
val configuration = authUIConfiguration {
context = applicationContext
providers {
provider(AuthProvider.Email())
provider(
AuthProvider.Phone(
defaultCountryCode = "US",
)
)
provider(
AuthProvider.Google(
scopes = listOf("email"),
serverClientId = null,
)
)
provider(AuthProvider.Facebook())
}
}Email link sign-in now lives in the email provider configuration:
val configuration = authUIConfiguration {
context = applicationContext
providers {
provider(
AuthProvider.Email(
isEmailLinkSignInEnabled = true,
emailLinkActionCodeSettings = actionCodeSettings {
url = "https://example.com/auth"
handleCodeInApp = true
setAndroidPackageName(
"com.example.app",
true,
null,
)
},
)
)
}
}For the full deep-link handling flow, see auth/README.md.
Create an AuthUIConfiguration, then show FirebaseAuthScreen.
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val authUI = FirebaseAuthUI.getInstance()
setContent {
MyAppTheme {
val configuration = authUIConfiguration {
context = applicationContext
theme = AuthUITheme.fromMaterialTheme()
providers {
provider(AuthProvider.Email())
provider(
AuthProvider.Google(
scopes = listOf("email"),
serverClientId = null,
)
)
}
}
if (authUI.isSignedIn()) {
HomeScreen()
} else {
FirebaseAuthScreen(
configuration = configuration,
authUI = authUI,
onSignInSuccess = { result ->
// User signed in successfully
},
onSignInFailure = { exception ->
// Sign in failed
},
onSignInCancelled = {
finish()
},
)
}
}
}
}
}This gives you a complete authentication flow with:
- Password Authentication.
- Google Sign-In.
- Password reset.
- Material 3 styling.
- Credential Manager support.
- Error handling through direct callbacks.
FirebaseUI Auth provides convenience methods for sign-out and account deletion:
lifecycleScope.launch {
FirebaseAuthUI.getInstance().signOut(applicationContext)
}lifecycleScope.launch {
FirebaseAuthUI.getInstance().delete(applicationContext)
}FirebaseUI Auth is customizable, and the simplest way to get started is to set a theme directly in authUIConfiguration:
val configuration = authUIConfiguration {
context = applicationContext
providers {
provider(AuthProvider.Email())
provider(AuthProvider.Google(scopes = listOf("email"), serverClientId = null))
}
theme = AuthUITheme.Adaptive
}You can also:
- Use
AuthUITheme.Default,AuthUITheme.DefaultDark, orAuthUITheme.Adaptive. - Inherit your app theme with
AuthUITheme.fromMaterialTheme(). - Customize the default theme with
.copy(). - Build a fully custom
AuthUITheme. - Set a logo, Terms of Service URL, and Privacy Policy URL in
authUIConfiguration.
For full theming and customization details, including theme precedence, provider button styling, and custom themes, see auth/README.md.
If your app still uses Activities and the Activity Result API, you can keep an Activity-based launch flow by using AuthFlowController:
private val authLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult(),
) { result ->
if (result.resultCode == RESULT_OK) {
val user = FirebaseAuth.getInstance().currentUser
// ...
} else {
// User cancelled or sign-in failed
}
}
val configuration = authUIConfiguration {
context = applicationContext
providers {
provider(AuthProvider.Email())
provider(
AuthProvider.Google(
scopes = listOf("email"),
serverClientId = null,
)
)
}
}
val controller = FirebaseAuthUI.getInstance().createAuthFlow(configuration)
authLauncher.launch(controller.createIntent(this))