Fast Compose: Run Jetpack Compose code instantly without compiling

2026-11-06来源 dev.to OpenSourceEnglish
Fast Compose: Run Jetpack Compose code instantly without compiling

Jetpack Compose normally requires the Kotlin compiler, the Compose compiler plugin, and a build before you can see your UI.

Hot reload tools can skip app restarts, but they still rely on compilation. And none of that runs directly in a web page.

I built Fast Compose, an interpreter that executes Jetpack Compose code without the Kotlin compiler.

Here's how it works:

  • A hand-written Kotlin parser (pure Kotlin Multiplatform, with no compiler dependency) converts source code into a syntax tree.
  • An interpreter walks that tree and executes it inside a real Compose composition.
  • When the code calls Text(...), a binding invokes the actual Compose Text composable.
  • State, recomposition, and effects are handled by the real Compose runtime.

The playground above runs the engine compiled to Kotlin/Wasm. https://fast-compose.github.io/playground/

The same engine also powers:

  • An Android Studio plugin that updates previews as you type.
  • A CLI for executing Compose code.
  • A script tag for embedding interactive Compose components in any HTML page.

Current limitations:
Around 61% of Compose composables have bindings. Unsupported composables use stand-ins. Type checking happens at runtime, so this is a rapid preview and experimentation tool, not a replacement for the Kotlin compiler.

Source code: https://github.com/fast-compose/fast-compose

I'd love to hear your thoughts, especially on the interpreter architecture and potential use cases. Happy to answer technical questions!

原文:https://www.a8q9.cn/en/article/fast-compose-run-jetpack-compose-code-instantly-without-compiling-56df97.html

相关文章