Extends gotrue-kt with Native Auth composables for Compose Multiplatform
Supported targets:
| Target | JVM | Android | JS | Wasm | iOS |
|---|---|---|---|---|---|
| Status | ✅ | ✅ | ✅ | ✅ | ✅ |
Native Google Auth is only supported on Android and iOS* and Native Apple Auth is only supported on iOS. Other targets or combinations rely on
auth-ktfor OAuth.
* starting with version3.3.0
In-depth Kotlin targets
JS: Browser
Wasm: wasm-js
iOS: iosArm64, iosSimulatorArm64, iosX64
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 the Credential Manager) 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 -> {}
}
},
onIdToken = ComposeAuth.LINK_IDENTITY_CALLBACK, // optional: if you want to link an identity to an existing account rather than signing in
fallback = { // optional: override custom fallback handling, not required by default
}
)
Button(
onClick = { action.startFlow() } //optional: you can also pass in extra data for the user like a name. A nonce is automatically generated, but you can also pass in a custom nonce
) {
Text("Google Login")
}You can also provide a custom onIdToken value, if you want to handle the signing-in yourself.
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
Before start, make sure your iOS app works well first, it would be easier to isolate the issue from this step to resolve
- Create a project in your Google Cloud Developer Console
- Create OAuth credentials for a Web application, iOS version
- Put in Client ID of Web OAuth, Apple OAuth in your Supabase Auth Settings for Google in the Dashboard
- Set up XCode 26
Add Client ID and Reversed Client ID (Retrieved from iOS OAuth details on Google Console). Your
Info.plistwill look like this:
<dict>
<key>CFBundleIdentifier</key>
<string>io.github.jan.supabase.ios</string>
<key>GIDClientID</key>
<string>YOUR_CLIENT_ID</string>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR_REVERSED_CLIENT_ID</string>
</array>
</dict>
</array>
</dict>-
Download
exportedNativeBridgeat/ComposeAuth/exportedNativeBridgein this repository In XCode, add it as dependency Step 1: Right click on the left tool bar > Select Add dependencies
Step 2: From opened dialog > Add local

Step 3: Continue Add package
Step 4: Add GoogleSignIn 9.0.0 or the one compatible with your project as below:

-
Build your app. It should work now.