How Kuikly Achieves Native‑Level Performance Across Five Platforms with Kotlin Multiplatform
Kuikly, Tencent’s open‑source cross‑platform framework built on Kotlin Multiplatform, delivers native‑level performance and dynamic UI across Android, iOS, HarmonyOS, Web and mini‑programs by combining a lightweight native rendering layer, a two‑tree DSL architecture, precise diffing, and extensive tooling support.
Kuikly is a widely used cross‑platform development framework at Tencent, built on Kotlin Multiplatform technology to provide a unified development experience across multiple platforms. It has been open‑sourced on GitHub.
Background
Cross‑platform development is a key focus in the large‑frontend field, especially with the launch of HarmonyOS Next, increasing business demand for cross‑platform solutions. New scenarios require broader and deeper cross‑platform capabilities, raising the bar for framework performance, dynamic capabilities, and consistency.
Current frameworks struggle to balance cross‑platform ability, performance, and dynamic features. Dynamic language solutions like RN‑style frameworks and Web containers offer dynamism but suffer low performance, while AOT‑compiled native‑drawing solutions like Flutter and JetBrains Compose achieve near‑native performance but lack dynamic updates. These limitations make it hard to meet business needs.
Kuikly aims to break these limits by seeking a better balance among cross‑platform, performance, and dynamic capabilities, targeting a pure native cross‑platform dynamic solution with native‑level performance and a native technology stack.
Capabilities and Feature Advantages
Kuikly is deployed at large scale within Tencent, covering over 15 apps and 500+ business pages with daily page views reaching billions. Some services on HarmonyOS are fully developed with Kuikly and reused on Android and iOS, significantly improving development efficiency.
One code, five platforms, including HarmonyOS
Supports Android, iOS, HarmonyOS, Web, and mini‑programs. Android and iOS platforms are already open‑sourced; HarmonyOS support will be open‑sourced in May, with Web and mini‑program support planned for Q2.
Native‑level performance
Leveraging Kotlin Multiplatform, Kuikly compiles Kotlin code into native artifacts (e.g., .aar, framework) for each platform, achieving performance close to native.
Performance comparison (high‑mid‑low end devices)
First‑screen load time of Kuikly pages is comparable to native; memory overhead is minimal because Kuikly uses KMP compilation and native rendering without additional engine layers.
Comparison with other frameworks
Overall, Kuikly shows better startup and memory performance.
Pure native development toolchain driven by Kotlin
Kuikly uses Kotlin as the development language and native IDEs (Android Studio / VS Code) along with native performance analysis tools, enabling a unified stack for business and framework code development, debugging, and performance analysis.
Framework development modes comparison:
Declaration + Reactive DSL
Self‑developed declarative + reactive DSL improves UI development efficiency. ComposeDSL support is in progress and will be open‑sourced in Q2.
Page‑level dynamic capability
Kuikly supports built‑in and dynamic modes on demand, offering page‑level updates with high stability. Android dynamic mode uses platform artifacts with near‑native performance; iOS and HarmonyOS dynamic mode uses JS, achieving performance comparable to RN‑style frameworks.
Lightweight, stable, and easy to maintain
The framework is designed to be compact with no complex external dependencies, resulting in high stability, controllability, and maintainability.
Implementation Principles and Architecture
The team explored various cross‑platform languages and adopted Kotlin Multiplatform Mobile (KMM, now KMP) for its cross‑platform compilation capabilities.
Kotlin is the official Android language, naturally compatible with Android toolchains and ecosystem, lowering developer onboarding cost.
KMP compiles Kotlin code into native artifacts for each platform (e.g., Android JVM/ART bytecode, iOS native binaries), enabling high‑performance multi‑platform execution.
KMP can also compile to JS/Wasm, providing code‑dynamic‑update capabilities.
These features align well with Kuikly’s requirements and form the core technical foundation.
Core Layer (Cross‑platform Logic)
DSL driver : Includes a self‑developed declarative + reactive Kuikly DSL and the standard Compose DSL (under development).
BuildTree : High‑performance DSL component‑tree mapping logic that generates the native UI tree, featuring dual‑tree mapping, O(1) diff algorithm, and rendering command generation.
Unified UI components : Ensures consistency across platforms by re‑implementing complex high‑order components (e.g., ListView, ViewPager, Waterfall) in the cross‑platform layer, while mapping a few native atomic components directly.
Layout engine : Uses the mature Yoga layout engine to support FlexBox layouts.
Native Rendering Layer (Lightweight)
Unified platform interface layer : Provides a consistent API across native platforms.
Native UI mapping : Minimal atomic rendering components (Text, Image, Input, ScrollView, etc.) are placed in the native layer.
API implementation modules : Offer extensible unified APIs for the cross‑platform layer.
Communication between Core and Render layers avoids direct KMP actual/expect calls, using a callKotlin/callNative command scheme to achieve compilation isolation and support dynamic updates.
KuiklyBase infrastructure : Provides Kotlin/Native adaptation for HarmonyOS, basic cross‑platform components, a complete development toolchain, and stack trace capture/reporting capabilities.
Key Technical Points
Two‑Tree Rendering Principle
The typical rendering pipeline (create ViewTree, measure, layout, draw) places the first three steps in the platform‑agnostic Kotlin layer, while drawing occurs in the native layer, enabling a lightweight rendering mechanism compared to virtual‑DOM approaches.
High‑Consistency Native Rendering
Kuikly chooses native rendering to benefit from better toolchain support, native interaction experience, and smaller package size, while achieving high consistency through a lightweight native layer and extensive high‑order component logic in the cross‑platform layer.
Declarative & Reactive DSL
Inspired by modern Compose/Swift DSLs, Kuikly leverages Kotlin’s higher‑order functions and type‑safe builders for declarative syntax, and property delegation for automatic reactive updates, allowing model changes to trigger view updates seamlessly.
Extreme Rendering Performance Optimizations
Precise Diff : Implements a custom patch instruction system (conditional and loop statements) to achieve fine‑grained diffing for performance‑critical scenarios.
UI Flattening : Reduces deep UI hierarchies by rendering only visible nodes, using a two‑tree design where the prototype tree marks renderable nodes and the render tree maps them 1:1 to native components.
Dynamic Capability
Kuikly’s design decouples cross‑platform code from platform code, allowing both built‑in and on‑demand dynamic execution. Android dynamic mode uses native artifacts for near‑native efficiency; iOS and HarmonyOS dynamic mode uses JS, offering performance comparable to RN‑style frameworks.
Plans
Near‑term
HarmonyOS support open‑source in May.
H5 and mini‑program support open‑source in Q2.
Compose DSL support open‑source in Q2.
Future
Enhance framework capabilities and tooling.
Expand to additional platforms such as Windows/Mac desktop.
Build internationalization support.
Grow community ecosystem with component platforms and active交流.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Tencent TDS Service
TDS Service offers client and web front‑end developers and operators an intelligent low‑code platform, cross‑platform development framework, universal release platform, runtime container engine, monitoring and analysis platform, and a security‑privacy compliance suite.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
