Usage
One call site, every platform. Both create and authenticate take a WebAuthn options
JSON string and return a PasskeyResult.
Register a passkey
val passkeys = rememberPasskeyClient()
when (val result = passkeys.create(registrationOptionsJson)) {
is PasskeyResult.Success -> sendToBackend(result.value.rawJson)
is PasskeyResult.Failure -> handle(result.error.code, result.error.message)
}registrationOptionsJson is the PublicKeyCredentialCreationOptions your server produced.
On success, result.value.rawJson is the attestation response your backend verifies and stores.
Authenticate with a passkey
when (val result = passkeys.authenticate(authenticationOptionsJson)) {
is PasskeyResult.Success -> sendToBackend(result.value.rawJson)
is PasskeyResult.Failure -> handle(result.error.code, result.error.message)
}authenticationOptionsJson is the PublicKeyCredentialRequestOptions (a fresh challenge,
the RP ID, and any allowed credentials). rawJson carries the assertion your backend verifies.
Getting a client without Compose
rememberPasskeyClient() is a Compose convenience. Outside Compose, construct the
platform client directly and give it the UI anchor it needs (the Activity, UIWindow,
NSWindow, or HWND). See Platforms for each target’s anchor.
The SDK only runs the on-device ceremony. A passkey is trustworthy only after your
backend verifies rawJson — never trust the client result alone. See
Server Verification.
Sign-in without a button
Two ways to offer a passkey before the user asks for one. Both are honoured on Android and iOS (the immediate option on macOS too).
Immediate — show the sheet only if a passkey is on this device right now,
otherwise fail silently (Android: NoCredential, iOS / macOS: UserCanceled):
passkeys.authenticate(PasskeyAuthenticationOptions(optionsJson, preferImmediatelyAvailableCredentials = true))Keyboard autofill — list passkeys in the keyboard’s suggestions for the username field. The call suspends until the user picks one, so launch it when the screen opens and cancel it when the screen closes:
AndroidPasskeyClient(activity).authenticateWithAutofill(usernameView, options) // Android 15+
IosPasskeyClient(window).authenticateWithAutofill(options) // field content type: usernameKeeping passkeys in sync (signals)
PasskeySignals tells the passkey provider what your server knows, so deleted
or renamed passkeys stop showing up at sign-in. Signals show no UI and are safe
to ignore when they fail.
val signals: PasskeySignals = AndroidPasskeySignals(context) // Android 15+
signals.unknownCredential(rpId, credentialId) // sign-in failed: passkey deleted server-side
signals.allAcceptedCredentials(rpId, userId, acceptedCredentialIds) // after sign-in
signals.currentUserDetails(rpId, userId, name, displayName) // after a renameSignals on iOS and macOS
Apple’s signal API (ASCredentialDataManager, iOS / macOS 26.2+) is Swift-only, so
implement PasskeySignals in your app. The three system calls are:
let manager = ASCredentialDataManager()
// unknownCredential
try await manager.reportUnknownPublicKeyCredential(
relyingPartyIdentifier: rpId, credentialID: data(credentialId))
// allAcceptedCredentials
try await manager.reportAllAcceptedPublicKeyCredentials(
relyingPartyIdentifier: rpId, userHandle: data(userId),
acceptedCredentialIDs: acceptedCredentialIds.map(data))
// currentUserDetails (Apple takes one name)
try await manager.reportPublicKeyCredentialUpdate(
relyingPartyIdentifier: rpId, userHandle: data(userId), newName: name)
/// Decodes the base64url ids used in WebAuthn JSON.
func data(_ base64Url: String) -> Data {
var base64 = base64Url.replacingOccurrences(of: "-", with: "+").replacingOccurrences(of: "_", with: "/")
base64 += String(repeating: "=", count: (4 - base64.count % 4) % 4)
return Data(base64Encoded: base64) ?? Data()
}Wrap them in a Swift class that conforms to PasskeySignals from your shared framework
and return PasskeyResult from each method.
Web sign-in (Auth Tab and WebView)
PasskeyClient is the native route. Two optional modules cover the other two
ways an app can use passkeys.
passkeys-auth-session — run your existing web sign-in page, or an
OAuth / OIDC provider, in the system authentication browser. The page shows its
own passkey prompt; the app gets the redirect back.
val session: WebAuthSession = AndroidWebAuthSession(activity) // iOS: IosWebAuthSession(window)
when (val result = session.authenticate(
url = "https://example.com/oauth/authorize?...",
redirect = WebAuthRedirect.Https(host = "example.com", path = "/auth/callback"),
)) {
is PasskeyResult.Success -> exchangeCode(result.value) // the full redirect URL
is PasskeyResult.Failure -> handle(result.error)
}| Android | iOS | |
|---|---|---|
| Backed by | Auth Tab (androidx.browser 1.9) | ASWebAuthenticationSession |
WebAuthRedirect.Https | needs Digital Asset Links on the redirect host | iOS 17.4+, needs Associated Domains |
WebAuthRedirect.CustomScheme | no domain setup | no domain setup |
| Build requirement | compileSdk 36, AGP 8.9.1+ | — |
On Android the session needs a browser with Auth Tab support (Chrome 137+). On
any other browser the same intent opens a plain Custom Tab, which cannot hand
the redirect back: the call ends as UserCanceled once the user closes it. It
ends as Interrupted if the activity is destroyed while the browser is open.
passkeys-webview (Android) — let a first-party page inside your own
WebView use passkeys through navigator.credentials:
if (!webView.enablePasskeys()) { /* WebView too old: offer another sign-in path */ }The page’s domain must list the app in its Digital Asset Links. iOS needs no
equivalent: WKWebView supports passkeys for the app’s Associated Domains.
Apple extensions
On Apple targets the SDK supports WebAuthn extensions, gated by OS version:
largeBlob: iOS 17+ / macOS 14+prf: iOS 18+ / macOS 15+
Unsupported OS versions fail with PasskeyException.Unsupported before any UI appears.
Extension outputs are preserved in rawJson.clientExtensionResults.