Standard Compose Multiplatform desktop applications bundle the JVM and Skiko, which can easily push your final installer size past 70MBβ100MB.
If you want a sleek, ultra-lightweight desktop app without ditching your Kotlin Compose codebase, there is a brilliant hack: compile your app to WebAssembly (WASM) and wrap it inside Tauri. Tauri leverages the system's native WebView and a lightweight Rust backend, dropping your app's footprint down to just a few megabytes.
Here is your step-by-step guide to making your Compose app 10x lighter.
If you still didn't! You can use my web wizard to simplify the process.
https://terrakok.github.io/Compose-Multiplatform-Wizard/
./gradlew :webApp:wasmJsBrowserDistribution
Before moving forward, open the generated distribution in your browser to ensure everything renders and behaves exactly as expected.
# Install Node.js via Homebrew (macOS)
brew install node
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
npm create tauri-app@latest
During the interactive setup, select the following options to create a minimal container (since Compose will handle 100% of the UI):
β Project name Β· tauri-app
β Identifier Β· dev.compose.tauri
β Choose which language to use for your frontend Β· TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)
β Choose your package manager Β· npm
β Choose your UI template Β· Vanilla
β Choose your UI flavor Β· JavaScript
rm -r ./tauri-app/src
cp -r ./webApp/build/dist/wasmJs/productionExecutable ./tauri-app
mv ./tauri-app/productionExecutable ./tauri-app/src
cd ./tauri-app
npm install
npm run tauri build
Fixing External Link Opening in Your Compose-Tauri App
Open tauri project's index.html and add this script inside the <head> tag before the Compose/Kotlin scripts are loaded:
<script>
(function() {
const originalOpen = window.open;
window.open = function(url, target, features) {
if (url && (url.startsWith('http://') || url.startsWith('https://'))) {
if (window.__TAURI__ && window.__TAURI__.core) {
window.__TAURI__.core.invoke('plugin:opener|open_url', { url: url });
return null;
}
}
return originalOpen.apply(this, arguments);
};
})();
</script>Once the compilation finishes, check your src-tauri/target/release/bundle/ directory. You will find a production desktop installer that is a fraction of the size of your original JVM-based distribution, fully powered by your Kotlin Compose code!
β οΈ Keep in mind: While this is a brilliant hack for shrinking your app size, it isn't a seamless, "drop-in" solution for building production-grade desktop apps without some extra effort. To fully unlock all desktop capabilities, you will need to familiarize yourself with the Tauri documentation.
That being said, Tauri is an incredibly powerful framework with an extensive ecosystem. Choosing this path opens up a lot of flexibility:
- Deep System Integration: You can invoke native system functions directly from Rust code. Tauri then automatically exposes these via JavaScript bindings, which you can easily interface with and call straight from your Kotlin/WASM code.
- Rich Plugin Ecosystem: Tauri provides official, production-ready plugins for essential desktop features out of the box, allowing you to:
- Minimize your app to the system tray.
- Enforce single-instance window behavior.
- Gain secure access to the native file system.
- Manage notifications, global shortcuts, and more.
The Verdict: Bridging Compose with Tauri does require learning a bit of the Tauri way, but an ultra-lightweight installer makes it absolutely worth a try!
While the Tauri + WASM approach is a fantastic option for web-friendly distribution, JVM-based Compose Desktop apps still hold immense potential. If you prefer to stay entirely within the standard ecosystem, there are several powerful optimization avenues available right nowβand even better updates on the horizon:
- Size Optimization via ProGuard: You can drastically reduce the final binary size of your native desktop app by configuring aggressive ProGuard optimization and shrinking rules to strip away unused code.
- Instant Launch Times: Leveraging advanced performance techniques, such as Ahead-of-Time (AOT) caches, can significantly accelerate your application's initial startup speed.
- Smoother UX and Resizing: Our team is actively working on a massive overhaul to fix window resizing behavior, aiming to drastically eliminate UI stuttering and flickering when scaling the window.
The Bottom Line: Whether you choose the ultra-lightweight Tauri route or stick with a heavily optimized native desktop build, Compose Multiplatform gives you the flexibility to build exactly the way you want.