Snapshottable: A Compose Kotlin Compiler Plugin
Generate compose snapshot state from class specifications
TJ Dahunsi
May 17 2026 ยท 1 min
Snapshottable is a Kotlin compiler plugin that generates mutable, snapshot-backed state holders from immutable data definitions.
In Jetpack Compose, the UI layer requires snapshot state, its the only way it can be invalidated and subsequently recomposed. Most state production pipelines however produce immutable state wrapped in observable types like StateFlow. This immmutable state may be serializable and so often require backing fields in thier constructors. Reconciling the two usually means hand-writing a parallel mutable class for every state model. You wire each property to mutableStateOf, keep a copy-like bulk update method in sync, and write conversions back and forth. It is tedious, error-prone boilerplate that grows with every field you add.
Snapshottable removes that work. You define your state once as a clean immutable interface plus a @SnapshotSpec data class, and the plugin generates the Compose-snapshot-backed mutable counterpart, a copy-style bulk update, and two-way conversions between the two representations. You keep the immutable spec for serialization and rememberSaveable, and the mutable version comes for free at runtime. There's no boilerplate, and no drift between the two.
For a deeper look at the problem space and why snapshot state belongs in the UI layer, I cover the details in the blog post below:
.