Skip to content

Instantly share code, notes, and snippets.

@terrakok
Created July 3, 2026 13:53
Show Gist options
  • Select an option

  • Save terrakok/bb876b257adfdedffdd6fda98457c8ce to your computer and use it in GitHub Desktop.

Select an option

Save terrakok/bb876b257adfdedffdd6fda98457c8ce to your computer and use it in GitHub Desktop.
Compose + Tauri

How to Shrink Your Compose Desktop App by 10x

Screenshot 2026-07-03 at 15-40-24

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.

1: Add the Web WASM Target πŸ˜‚πŸ˜‚πŸ˜‚

If you still didn't! You can use my web wizard to simplify the process.
https://terrakok.github.io/Compose-Multiplatform-Wizard/

2: Compile the WASM Distribution

./gradlew :webApp:wasmJsBrowserDistribution

3: Verify in the Browser

Before moving forward, open the generated distribution in your browser to ensure everything renders and behaves exactly as expected.

4: Install Node.js and Rust

# Install Node.js via Homebrew (macOS) 
brew install node 

# Install Rust 
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

5: Initialize a New Tauri Project

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

6: Remove the Default Frontend Source

rm -r ./tauri-app/src

7: Copy Your Compose WASM Build into the Tauri project

cp -r ./webApp/build/dist/wasmJs/productionExecutable ./tauri-app
mv ./tauri-app/productionExecutable ./tauri-app/src

8: Navigate to Your Tauri Project

cd ./tauri-app

9: Install Package Dependencies

npm install

10: Compile the Final Desktop Binary

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>

Result:

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!

Important Considerations & Next Steps

⚠️ 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!

🀘🀘🀘 JVM-based Compose Desktop rocks! 🀘🀘🀘

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment