KotlinConf 2026 covered UUID adoption across the Kotlin ecosystem — server-side JVM services, Android apps, and Kotlin Multiplatform libraries. The talks built on the RFC 9562 additions and the PostgreSQL 18 uuidv7() function announced the prior year. See UUID in Kotlin for implementation details.
Session highlights
UUID v7 for backend Kotlin services
The primary session walked through replacing sequential integer IDs with UUID v7 in a Ktor REST service:
import io.ktor.server.application.*
import io.ktor.server.routing.*
import io.ktor.server.response.*
import com.github.f4b6a3.uuid.UuidCreator
fun Application.configureRouting() {
routing {
post("/orders") {
val orderId = UuidCreator.getTimeOrderedEpoch()
// persist order with UUID v7 primary key
call.respond(mapOf("id" to orderId.toString()))
}
}
}
Key points from the session: UUID v7 primary keys on PostgreSQL outperform UUID v4 for write-heavy workloads because new rows always append to the B-tree’s rightmost leaf. See UUID v4 vs v7.
Kotlin value classes for type-safe IDs
@JvmInline
value class OrderId(val value: java.util.UUID) {
companion object {
fun new(): OrderId = OrderId(UuidCreator.getTimeOrderedEpoch())
}
override fun toString() = value.toString()
}
@JvmInline
value class CustomerId(val value: java.util.UUID) {
companion object {
fun new(): CustomerId = CustomerId(java.util.UUID.randomUUID())
}
}
// Compile-time safety — can't pass CustomerId where OrderId is expected
fun getOrder(id: OrderId): Order = repository.findById(id)
Kotlin’s @JvmInline value class has zero runtime overhead on the JVM — the UUID value is stored unboxed. See TypeScript UUID Types for the same pattern in TypeScript.
Android Room integration
@Entity(tableName = "orders")
data class OrderEntity(
@PrimaryKey
val id: String = UuidCreator.getTimeOrderedEpoch().toString(),
val status: String,
val createdAt: Long = System.currentTimeMillis(),
)
@Dao
interface OrderDao {
@Insert
suspend fun insert(order: OrderEntity)
// Time-range query using UUID v7 sort order
@Query("SELECT * FROM orders WHERE id >= :lowerBound ORDER BY id ASC LIMIT :limit")
suspend fun page(lowerBound: String, limit: Int): List<OrderEntity>
}
Kotlin Multiplatform UUID
For KMP targets, benasher44/uuid provides UUID v4 across JVM, iOS, and WASM:
// commonMain
import com.benasher44.uuid.uuid4
val id = uuid4() // UUID v4, works on all KMP targets
UUID v7 KMP support requires platform-specific actual implementations to access System.currentTimeMillis() equivalents on each target. The conference session demoed a community library implementing this. See UUID in Mobile Apps.
Further reading
- UUID in Kotlin — v4 and v7 patterns
- UUID in Java and Spring Boot
- UUID in Java — full guide
- UUID in Mobile Apps — iOS and Android
- UUID v4 vs v7 — performance comparison
External references
- uuid-creator — JVM UUID v7 library
- benasher44/uuid — Kotlin Multiplatform UUID
- KotlinConf official site
- RFC 9562 — UUID standard
Frequently asked questions
What UUID libraries were recommended at KotlinConf 2026?
uuid-creator by Fabio Lima was the primary recommendation for UUID v7 on the JVM — UuidCreator.getTimeOrderedEpoch() generates a compliant UUID v7. For Kotlin Multiplatform targets (iOS, WASM), the uuid KMP library (benasher44/uuid) provides a platform-independent UUID v4 implementation; UUID v7 KMP support was listed as a community roadmap item. See UUID in Kotlin.
How does KotlinConf recommend using UUIDs in Android Room?
Store UUID as String with a @TypeConverter — Room has no native UUID column type. A @TypeConverter pair (UUID.fromString / UUID.toString) lets the entity field be typed as java.util.UUID while Room stores a TEXT column. UUID v7 strings sort lexicographically by creation time in SQLite. See UUID in Mobile Apps.