RepositoryKotlinGBUnited Kingdom
AR

arkivanov/Decompose

Kotlin Multiplatform lifecycle-aware business logic components (aka BLoCs) with routing (navigation) and pluggable UI (Jetpack Compose, SwiftUI, JS React, etc.)

2.9kstars
112forks
3issues
3views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: kotlin-multiplatform

#1 Repository of the month

1
TINIX TRENDING·Topic: multiplatform

#1 Repository of the month

1
TINIX TRENDING·Topic: navigation

#1 Repository of the month



License Twitter URL


Decompose is a Kotlin Multiplatform library for breaking down your code into tree-structured lifecycle-aware business logic components (aka BLoC), with routing functionality and pluggable UI (Jetpack/Multiplatform Compose, Android Views, SwiftUI, Kotlin/React, etc.).

Please see the project website for documentation and APIs.

Should you have any questions or ideas - there is Discussions section. Also welcome to the Kotlin Slack channel - #decompose! You can also try using DeepWiki!

Why Decompose?

  • Decompose breaks the code down into small and independent components and organizes them into trees. Each parent component is only aware of its immediate children.
  • Decompose draws clear boundaries between UI and non-UI code, which gives the following benefits:
    • Better separation of concerns
    • Pluggable platform-specific UI (Compose, SwiftUI, Kotlin/React, etc.)
    • Business logic code is testable with pure multiplatform unit tests
  • Navigation state is fully exposed - plug any UI you want, animate as you like using your favourite UI framework's API or use predefined API.
  • Navigation is a pure function from the old state to a new one - navigate without limits.
  • Proper dependency injection (DI) and inversion of control (IoC) via constructor, including but not limited to type-safe arguments.
  • Shared navigation logic
  • Lifecycle-aware components
  • Components in the back stack are not destroyed, they continue working in background without UI
  • State preservation (automatically on Android, manually on all other targets via kotlinx-serialization)
  • Instances retaining (aka ViewModels) over configuration changes (mostly useful in Android)

Meme time!

Setup

Please check the Installation section of the documentation.

Supported platforms

In general, Decompose supports the following targets: android, jvm, ios, watchos, tvos, macos, wasmJs, js. However, some modules do not support all targets or the support depends on the Decompose version. Please see the installation docs for details.

Overview

Here are some key concepts of the library, more details can be found in the documentation.

  • Component - every component represents a piece of logic with its own lifecycle, the UI is optional and is plugged externally
  • ComponentContext - every component has its own [ComponentContext], which makes components lifecycle-aware and allows state preservation, instances retaining (aka AndroidX ViewModel) and back button handling
  • Child Stack - enables navigation between child components, nested navigation is also supported
  • Child Slot - allows only one child component at a time, or none
  • Child Pages - a list of child components with one selected component (e.g. pager-like navigation)
  • Child Panels - a multi-pane navigation
  • Generic Navigation - provides a way to create your own custom navigation model, when none of the predefined models fit your needs
  • Lifecycle - provides a way to listen for lifecycle events in components
  • StateKeeper - makes it possible to preserve state or data in a component when it gets destroyed
  • InstanceKeeper - retains instances in your components (similar to AndroidX ViewModel)
  • BackPressedHandler - provides a way to handle and intercept back button presses

Decompose is a library

Decompose is a library that can be used as a framework. In its core, Decompose just manipulates instances of ComponentContext with strict parent-child relationship, which is also called "navigation". The possibility of creating custom implementations of the ComponentContext interface allows adding custom properties and functions, as well as storing additional data in each instance of ComponentContext. This makes it a very powerful tool with various use cases.

The "component" term is just one of the possible usages, the recommended one. The Decompose-Router library is a great example of leveraging Decompose to create a custom navigation solution with a completely different API.

Component hierarchy

Pluggable UI hierarchy

Typical component structure

Quick start

Please refer to the Quick start section of the docs.

Samples

Check out the Samples section of the docs for a full description of each sample.

Template

Check out the template repository which may be used to kick-start a project for you.

"Used by" list

Checkout a voluntary list of projects/companies using Decompose: https://github.com/arkivanov/Decompose/discussions/366. Feel free to add your project!

Articles

Author

Twitter: @arkann1985

If you like this project you can always Buy Me A Coffee ;-)

Similar Projects

Discover other similar projects and AI models.

RepositoryKotlin
gkd-kit/gkd

基于无障碍,高级选择器,订阅规则的自定义屏幕点击安卓应用 | An Android APP with custom screen tapping based on Accessibility, Advanced Selectors, and Subscription Rules

45.7k
Nov 13, 2026
RepositoryTypeScript
morluto/rea

Reverse engineer anything with agents, from app behavior down to native binaries.

487.0k
Dec 2, 2026
RepositoryKotlin
lysine-dev/okhttp

A meticulous HTTP client for the JVM, Android, and GraalVM.

47.1k
Nov 27, 2026
RepositoryKotlin
JunkFood02/Seal

🦭 Video/Audio Downloader for Android, based on yt-dlp

31.2k
Nov 25, 2026
RepositoryKotlin
komi-store/komi-store

🩵 A free, open-source app store for developers' releases on GitHub, Codeberg & Forgejo — browse, discover, and install apps with one click. Formerly GitHub Store.

23.2k
Dec 1, 2026
RepositoryKotlin
JetBrains/compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

19.5k
Nov 30, 2026
RepositoryKotlin
MetrolistGroup/Metrolist

Material Design YouTube Music client for Android, iOS and desktop

15.5k
Dec 1, 2026
RepositoryKotlin
InsertKoinIO/koin

Koin - pragmatic dependency injection for Kotlin & Kotlin Multiplatform. Koin DSL or Koin Annotations (JSR-330), compile safe with the Koin Compiler Plugin.

10.0k
Nov 6, 2026
RepositoryKotlin
kotest/kotest

Powerful, elegant and flexible test framework for Kotlin with assertions, property testing and data driven tests.

4.8k
Nov 24, 2026