For AI agents: the documentation index is at llms.txt. Guide pages have a markdown version at the same path with .md appended, before any query string or fragment.

Kotlin: Listen to database changes

Return real-time data from your table as a Flow.

Parameters

Examples

Listen for changes in multiple rows

val flow: Flow<List<Country>> = supabase.from("countries").selectAsFlow(Country::id)
flow.collect {
    for (country in it) {
        println(country.name)
    }
}

Listen for changes in multiple rows with a filter

val flow: Flow<List<Country>> = supabase.from("countries").selectAsFlow(
    Country::id
) {
    eq("id", 256)
}
flow.collect {
    for (country in it) {
        println(country.name)
    }
}

Listen for changes in a single row

val flow: Flow<Country> = supabase.from("countries").selectSingleValueAsFlow(Country::id) {
    // You can use the same filter methods as in the `select` method, but the result is limited to a single row
    Country::id eq 1
    // or
    eq("id", 1)
}
flow.collect {
    println("My country is $it")
}