Cranpose
Build desktop, mobile and web apps with Rust functions. Cranpose follows the Jetpack Compose model: a function describes the screen, state changes update the screen, and modifiers control layout, input and appearance.
The same UI code runs on Linux, macOS, Windows, Android, Wear OS, iOS and the web. The experimental watchOS host uses the software renderer. Cranpose also places Rust screens inside Android Compose and UIKit apps.
Run a counter
Create a desktop app:
Replace src/main.rs with this example, then run cargo run:
use *;
#
#
#
rememberMutableStateOf retains the count across recomposition. The button
callback changes the count. A read through count.get() subscribes the text to
state updates. State handles are Copy, so the callbacks share one state value.
try_run starts the desktop event loop and returns a launch error on failure.
Choose a project structure
For a complete app, start from the project template. The template includes screens, view models, navigation and platform hosts. The IDE plugin creates the same project through File → New Project → Cranpose.
Use cranpose::prelude::* for common app imports and cranpose::liquid::prelude::*
for Liquid controls. The app guide
connects UI state, flows, view models, device services and platform builds.
Select a platform
Select a host and renderer in Cargo features. Desktop uses Vulkan, Metal or DirectX through WGPU. Android and web also support GL/GLES.
| Target | Features | Host setup |
|---|---|---|
| Linux, macOS, Windows | desktop, renderer-wgpu |
AppLauncher::try_run |
| Linux with one display backend | desktop-x11 or desktop-wayland, plus renderer-wgpu |
Select the session backend |
| Android and Wear OS | android, renderer-wgpu |
android_main! and the Android Gradle plugin |
| iOS | ios, renderer-wgpu |
Xcode host and iOS entry point |
| Web | web, renderer-wgpu |
Wasm entry point and browser canvas |
| watchOS, experimental | watchos |
SwiftUI host and software renderer |
The platform guide links the target-specific setup. The Android plugin guide describes Cargo packages, services, permissions and ABI selection.
The default feature embeds a font. default-features = false lets an app select
its own font data. renderer-pixels selects software output for custom hosts.
renderer-wgpu-gles adds the GL/GLES backend to WGPU.
Add app features
| Task | Start here |
|---|---|
| Arrange controls and text | UI widgets |
| Retain screen state | State guide |
| Build a long list or custom layout | Layout guide |
| Add glass controls and themes | Liquid UI |
| Animate a value | Animation |
| Collect flows and retain view models | Coroflow integration |
| Navigate between screens | Navigation |
| Use files, clipboard, network or purchases | Device services |
| Declare permissions and hardware | Capabilities |
| Embed a Rust screen in a native app | Native integration |
Optional features select extra backends: audio, audio-desktop, media,
camera-desktop, storekit, playbilling and webview. robot adds app test
support. The
feature list records each
dependency choice.
Cranpose is pre-alpha. Public APIs can change between releases. Review the release notes when an app updates its dependency.