Build Windows apps with Kotlin, XAML and native WinUI 3 controls.
Kotlin/WinRT projects Windows Runtime APIs into Kotlin. Share application code and XAML between Kotlin/Native mingwX64 and Kotlin/JVM, and use Gradle to generate API bindings, compile XAML and package your app. The project uses Windows App SDK 2.5.1.
The source tree also includes a UWP Windows.UI.Xaml application path, with separate AppContainer hosting and Windows SDK XAML compilation. It is under integration validation and currently requires a local UWP compiler package; the WinUI setup below retains its existing defaults.
The Kotlin WinUI Gallery runs the same Kotlin/XAML application on both targets. See examples and downloads.
- Windows x64, with JDK 25 and the Gradle 9.4.0 wrapper.
- Visual Studio / Build Tools with Desktop development with C++ and Windows SDK 10.0.26100.0.
- Windows Developer Mode for AppX development runs.
- Kotlin 2.4.0 or 2.4.20 when creating an application.
The Gradle toolkit provisions WinApp CLI and the Kotlin-aware XAML compiler, restores NuGet packages and stages the native runtime files. Build from an ordinary terminal; the toolkit discovers the installed C++ build tools.
Clone the repository and launch the Native application with AppX identity:
git clone --recursive https://github.com/compose-fluent/kotlin-winrt.git
cd kotlin-winrt
.\gradlew.bat :winui-gallery:runWinAppPackageMingwX64MainDebugExecutable --args=Home --detachTo run the JVM target instead:
.\gradlew.bat :winui-gallery:runWinAppPackageWinuiJvmMain --args=Home --detachRun one target at a time. AppX development tasks register a .dev package and launch the application with package identity, including ms-appx:/// resource access. They do not require signing an MSIX. Use these runWinAppPackage... tasks as the default development entry point.
Use a Kotlin Multiplatform project with both mingwX64 and JVM targets:
hello-winrt/
settings.gradle.kts
app/ # Shared Kotlin/XAML sources, manifest and icons
winrt-projections/ # Shared generated Windows SDK and WinUI APIs
The Windows toolkit is published through Maven Central. While Gradle Plugin Portal approval is pending, resolve its plugin ID explicitly in settings.gradle.kts:
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal() // Kotlin and other plugins
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "io.github.compose-fluent.windows-toolkit") {
useModule(
"io.github.compose-fluent:windows-toolkit-gradle-plugin:${requested.version}"
)
}
}
}
}
dependencyResolutionManagement {
repositories { mavenCentral() }
}
rootProject.name = "hello-winrt"
include(":app", ":winrt-projections")Follow the WinUI quick start for the complete Gradle files, manifest setup and Application.start entry point. It uses toolkit 0.1.0, Windows App SDK 2.5.1, and a shared winuiMain source set.
Place MainWindow.xaml beside MainWindow.kt under app/src/winuiMain/kotlin/sample/hello/:
<Window x:Class="sample.hello.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hello Kotlin">
<StackPanel Spacing="12" Padding="24">
<TextBlock x:Name="Greeting" Text="Hello from Kotlin WinRT" />
<Button Content="Say hello" Click="onHelloClick" />
</StackPanel>
</Window>package sample.hello
import microsoft.ui.xaml.RoutedEventArgs
import microsoft.ui.xaml.Window
class MainWindow : Window() {
private fun onHelloClick(sender: Any?, args: RoutedEventArgs) {
Greeting.text = "Hello from Kotlin code-behind"
}
}The compiler generates typed named-element access and initializes the XAML component after construction. Gradle compiles the shared sources for both targets.
Once the application setup is complete, run either target with AppX identity:
.\gradlew.bat :app:runWinAppPackageMingwX64MainDebugExecutable --detach
.\gradlew.bat :app:runWinAppPackageJvmMain --detach- Call WinRT APIs through generated Kotlin bindings, including the implemented activation, delegates, collections and async surfaces.
- Write WinUI layouts with Kotlin code-behind, named controls, events, compiled bindings, resources and templates.
- Generate projections from Windows SDK, NuGet or local WinMD files, or consume prebuilt projections. The prebuilt Windows App SDK coordinate is
io.github.compose-fluent:winrt-projections-windows-app-sdk:2.5.1. - Build JVM launchers and Native executables, author WinRT components, and create/sign MSIX packages through Gradle.
The implementation follows Microsoft's CsWinRT and C++/WinRT projection model. See CHANGELOG.md for the initial release's scope.
The Kotlin WinUI Gallery contains 122 routes and 355 example documents, with interactive controls and a XAML/Kotlin source viewer. Layouts and assets are ported from the official WinUI Gallery with third-party attribution.
Download from the 0.1.0 release once the tag's release workflow completes:
| Asset | Purpose |
|---|---|
Kotlin-WinUI-Gallery-0.1.0-mingwX64.msix |
Native Gallery |
Kotlin-WinUI-Gallery-0.1.0-jvm.msix |
Gallery with a bundled JVM runtime |
kotlin-winrt-ide-0.1.0-<variant>.zip |
IDE plugin |
winui-gallery-signing.cer |
Public package signing certificate |
SHA256SUMS.txt |
Download checksums |
Install one Gallery variant at a time; both use the same application identity. The framework-dependent packages require the matching Windows App Runtime. If the signer is not already trusted, verify and trust the supplied public certificate before installing. See the Gallery guide for source builds and packaging.
The IDE plugin adds completion, navigation, diagnostics, project templates and run/debug integration. Install the matching ZIP with Settings → Plugins → Install Plugin from Disk. Its WinUI XAML Application template creates the application and projection modules, shared sources, manifest, icons and bundled Maven toolchain; enable both targets.
| ZIP variant | IDE SDK used to build and validate it |
|---|---|
idea-262 |
IntelliJ IDEA 2026.2.2 |
as-261 |
Android Studio Quail 4 / 2026.1.4.7 |
as-canary-262 |
Android Studio Rabbit 2 Canary 2 / 2026.2.2.2 |
IDE Run/Debug and Hot Reload currently target JVM WinUI applications. XAML Preview is temporarily disabled. UWP designer, Hot Reload and packaged --debug-output are not implemented. See IDE setup and Hot Reload for supported edits and current limitations.
WinUI quick start · UWP applications · Usage and packaging · Gallery · Compiler · Release procedure · Benchmarks
