Mobile & Core SDK

Android Sdk Quickstart

Android SDK Quickstart

Integrate AuthSetu into your Android application using our Kotlin-first SDK with Jetpack Compose support.

1. Initialization

Initialize the AuthSetuClient in your Application class or at the start of your main activity.

kotlin
// In your Application class or MainActivity
AuthSetuClient.initialize(
    context = this,
    publishableKey = "pk_test_your_key",
    baseUrl = "https://api.authsetu.com/" // Optional
)

2. Using UI Components

AuthSetu provides pre-built Jetpack Compose components for common authentication flows.

Sign In

kotlin
@Composable
fun LoginScreen() {
    AuthSetuProvider { // Wraps the client context
        SignIn(
            onSuccess = { authResponse ->
                // Handle successful login (e.g., navigate to home)
                println("Logged in as: ${authResponse.user.email}")
            },
            onError = { errorMessage ->
                // Show error message to user
                println("Error: $errorMessage")
            }
        )
    }
}

Sign Up

kotlin
@Composable
fun RegistrationScreen() {
    AuthSetuProvider {
        SignUp(
            onSuccess = { authResponse ->
                println("Account created for: ${authResponse.user.email}")
            },
            onError = { errorMessage ->
                println("Error: $errorMessage")
            }
        )
    }
}

3. Session Management

Access the current user's session data anywhere in your app.

kotlin
val client = AuthSetuClient.getInstance()
val currentUser = client.sessionManager.user
val isLoggedIn = client.sessionManager.accessToken != null

if (isLoggedIn) {
    println("Welcome back, ${currentUser?.email}")
}


Was this page helpful?