Clerk
Clerk is the main entry point for the SDK. After you configure the SDK, you can access it in two ways:
Access user state
Use Clerk.userFlow to reactively observe the current user:
import com.clerk.api.Clerk
// In a ViewModel or Composable
val user by Clerk.userFlow.collectAsState(initial = null)
if (user != null) {
Text("Welcome, ${user.firstName}")
} else {
Text("Please sign in")
}Access the Clerk instance
Access authentication methods through the global Clerk object:
import com.clerk.api.Clerk
// Sign in
Clerk.auth.signInWithPassword {
identifier = "user@email.com"
password = "secretpassword"
}
// Sign out
Clerk.auth.signOut()Feedback
Last updated on
Edit on GitHub