Extends gotrue-kt with Native Auth composables for Compose Multiplatform
Supported targets:
Target | JVM | Android | JS | iOS | tvOS | watchOS | macOS | Windows | Linux |
---|---|---|---|---|---|---|---|---|---|
☑️ | ✅ | ☑️ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
Note: iOS support is experimental and needs feedback
☑️ = Has no support for neither Google nor Apple Native Auth, relies on gotrue-kt for OAuth.
In-depth Kotlin targets
iOS: iosArm64, iosSimulatorArm64, iosX64
JS: Browser, NodeJS
tvOS: tvosArm64, tvosX64, tvosSimulatorArm64
watchOS: watchosArm64, watchosX64, watchosSimulatorArm64
MacOS: macosX64, macosArm64
Windows: mingwX64
Linux: linuxX64
dependencies {
implementation("io.github.jan-tennert.supabase:compose-auth:VERSION")
}
Install the plugin in your SupabaseClient. See the documentation for more information
val supabase = createSupabaseClient(
supabaseUrl = "https://id.supabase.co",
supabaseKey = "apikey"
) {
//...
install(Auth) {
//your config
}
install(ComposeAuth) {
googleNativeLogin(serverClientId = "google-client-id")
appleNativeLogin()
}
}
Currently, Compose Auth only supports Native Auth for Android with Google (via Google OneTap and Credential Manager for Android 14+) and iOS with Apple, other variations such as JS and JVM rely on fallback which by default is GoTrue-kt OAuth flow.
To learn how you can use this plugin in your compose project, visit Compose Multiplatform
The composable can be accessed trough composeAuth
property from supabase
val action = supabase.composeAuth.rememberSignInWithGoogle(
onResult = { result -> //optional error handling
when (result) {
is NativeSignInResult.Success -> {}
is NativeSignInResult.ClosedByUser -> {}
is NativeSignInResult.Error -> {}
is NativeSignInResult.NetworkError -> {}
}
},
fallback = { // optional: add custom error handling, not required by default
}
)
Button(
onClick = { action.startFlow() }
) {
Text("Google Login")
}
Here is a small guide on how to use Native Google Auth on Android:
- Create a project in your Google Cloud Developer Console
- Create OAuth credentials for a Web application, and use your Supabase callback url as redirect url. (https://ID.supabase.co/auth/v1/callback)
- Put in the Web OAuth in your Supabase Auth Settings for Google in the Dashboard
- Create OAuth credentials for an Android app, and put in your package name and SHA-1 certificate (which you can get by using
gradlew signingReport
) - Put the Android OAuth client id to the authorized client ids in the Supabase Dashboard
- Use the Web OAuth client id in the Compose Auth plugin