Skip to main content
Docs

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

What did you think of this content?

Last updated on

GitHubEdit on GitHub