---
title: Leveraging Jetpack Compose
description: Shows a basic example of how to integrate the DaVinci module with Jetpack Compose by using a ViewModel to manage the UI state.
component: orchsdks
page_id: orchsdks:davinci:usage/android/04-leveraging-jetpack-compose
canonical_url: https://developer.pingidentity.com/orchsdks/davinci/usage/android/04-leveraging-jetpack-compose.html
revdate: Fri, 9 Jan 2026 17:23:51 +0000
keywords: ["DaVinci", "Android", "Jetpack Compose", "ViewModel", "Integration"]
---

# Leveraging Jetpack Compose

[icon: circle-check, set=far]PingOne [icon: android, set=fab]Android

The following shows how you could use the DaVinci module with Jetpack Compose:

ViewModel

```kotlin
// Define State that listen by the View
var state = MutableStateFlow<Node>(Empty)

//Start the DaVinci flow
val next = daVinci.start()

// Update the state
state.update {
    next
}

fun next(node: ContinueNode) {
    viewModelScope.launch {
        val next = node.next()
        state.update {
            next
        }
    }
}
```

View

```kotlin
when (val node = state.node) {
    is ContinueNode -> {}
    is ErrorNode -> {}
    is FailureNode -> {}
    is SuccessNode -> {}
}
```
