Experiment with server side rendering using compose and ktor
Now live on Heroku!
This is a prototype of porting compose as a feature of a Ktor server rather than running it on Android.
The original idea belongs to SwiftWebUI project, rendering HTML page using websocket commands from server.
Works with dev-15 with minor changes.
fun Application.module() {
install(Compose)
routing {
compose {
var state by remember { mutableStateOf(1) }
h1 {
text("Counter value is $state")
}
button(Modifier.onClick { state++ }) {
text("Increment!")
}
}
}
}
Full story on Medium.
You can use deploy
branch with prebuilt artifacts of runtime.
integration
module contains implementation of an on both JS and server side. Ideally, this is the part you could write if this library will be ever published.
The Ktor feature with all the definitions is in the server
module and browser runtime is in the client
one.