Kotlin
Native rendering for Jetpack Compose and Compose Multiplatform.
The Kotlin renderer takes a Joy DOM JSON document and renders it as Jetpack Compose composables. The same packages target Android (Compose) and desktop (Compose Multiplatform).
Status: pre-release
The Kotlin renderer is split into multiple Gradle modules under kotlin/ and is not yet published
to Maven Central. Use it locally by linking the module into your project.
Concept
The Compose integration accepts a Spec and emits the composable subtree inline:
import androidx.compose.runtime.Composable
import dev.joydom.render.compose.JoyDom
import dev.joydom.spec.Spec
@Composable
fun InvoiceScreen(spec: Spec) {
JoyDom(spec = spec)
}JoyDom walks the JSON tree, resolves the style cascade, and renders each node into the equivalent Compose primitive (Row / Column for flex containers, Text for text nodes, Image for img nodes).
Custom components
Register custom node handlers by kebab-case type:
JoyDom(
spec = spec,
components = mapOf(
"contact-button" to { node, children, style ->
Button(onClick = {}, modifier = Modifier.joyDomStyle(style)) {
children()
}
}
)
)The exact registration API will be confirmed when the package is published.
Loading documents
Decode JSON via kotlinx.serialization:
import kotlinx.serialization.json.Json
import dev.joydom.spec.Spec
val spec = Json.decodeFromString<Spec>(jsonString)The serialization module's Spec model maps 1:1 to the JSON Schema published by @joy-dom/spec, so documents are portable across renderers.
Module map
| Module | Purpose |
|---|---|
kotlin/dom-serialization | Spec data classes + kotlinx.serialization integration. |
kotlin/dom-layout | Flex layout primitives. |
kotlin/dom-render | Renderer-agnostic node walker and style cascade. |
kotlin/dom-render-compose | Compose UI bindings (JoyDom composable). |
kotlin/dom-dsl | Optional Kotlin DSL for building Spec objects programmatically. |
kotlin/dom-converter | Utilities for converting between representations. |
Local development
cd kotlin
./gradlew buildSample apps live under kotlin/sample-desktop (Compose Multiplatform) and kotlin/sample-render-host (Android).
Where next
- Specification - properties and breakpoints.