A small Android app and Ktor server demonstrating server-generated Remote Compose documents.
:android-appis a Compose screen with a bottom action button and a Remote Compose player.:serveris a Ktor CIO server that serves a raw Remote Compose document atGET /remote-compose.:remote-documentsis shared JVM code for the clock, weather, note, and message documents. Keeping the writer here lets the server and Android Studio previews render the exact same documents.
Each request to /remote-compose cycles through the four documents. The weather values and time are static sample data.
flowchart LR
subgraph Runtime
App[Android app<br/>Button + RemoteComposePlayer]
Server[Ktor server<br/>GET /remote-compose]
Documents[Shared remote-documents module<br/>Builds four Remote Compose layouts]
App -->|GET request| Server
Server -->|Generate next document| Documents
Documents -->|Remote Compose bytes| Server
Server -->|application/octet-stream| App
end
subgraph Android Studio previews
Preview[Android app previews]
Player[RemoteComposePlayer]
Preview -->|Create sample document| Documents
Documents -->|Remote Compose bytes| Player
end
The recording shows the Android app cycling through the four server-generated widgets:
Use JDK 25 with Android SDK platform 37 installed. The shared document and server modules use a JDK 25 toolchain. The shared document module emits Java 17 bytecode so it remains consumable by Android's D8 compiler; the server uses the JDK 25 default bytecode target.
./gradlew :server:runLeave the server running while using the app. For an Android emulator, create a reverse port forward so the app's 127.0.0.1:8080 request reaches the development machine:
adb reverse tcp:8080 tcp:8080The app connects to http://127.0.0.1:8080/remote-compose by default. For a physical device on the same network, change REMOTE_COMPOSE_URL in android-app/build.gradle.kts to the development machine's LAN address and ensure port 8080 is reachable.
The Android Studio preview panel includes a preview for each document. Preview generation runs the shared JVM writer in the Android module and then renders its bytes with the Remote Compose player.
