
Standard redux implementation fostering an ecosystem of middleware, store enhancers, and dev tools. Offers modular development, supports multiple platforms, and promotes open development and community involvement.
A redux standard for Kotlin that supports multiplatform projects.
Full documentation at http://reduxkotlin.org.
Provide a standard redux implementation for Kotlin. In doing so will foster a ecosystem of middleware, store enhancers, & dev tools. These core values will guide descisions for the project:
Redux in Kotlin, and in mobile in particular, may differ a bit from javascript. Many have found the basic pattern useful on Android & iOS leading to tens of opensource redux libraries in Kotlin, Java, and Swift, yet an ecosystem has yet to emerge. A port of javascript redux is a good starting point for creating a standard and will aid in cross-pollination of middleware, store enhancers, & dev tools from the javascript world.
Redux has proven helpful for state management in mobile. A multiplatform Kotlin implementation & ecosystem will increase developer productivity and code reuse across platforms.
Droidcon NYC Slides Video TBA
Artifacts are hosted on Maven Central. Replace <version> with the latest release shown by the
badge above.
Requirements:
minSdk 21 or higherjvm, js (browser/node), android, iosArm64, iosX64,
iosSimulatorArm64, macosArm64, macosX64, linuxArm64, linuxX64, mingwX64
One dependency for the common redux-kotlin stack. For Jetpack / Multiplatform Compose apps:
kotlin {
sourceSets {
commonMain { // <--- name may vary on your project
dependencies {
implementation("org.reduxkotlin:redux-kotlin-bundle-compose:<version>")
}
}
}
}For everything else (no Compose runtime pulled in):
implementation("org.reduxkotlin:redux-kotlin-bundle:<version>")redux-kotlin-bundle transitively brings the core, the concurrent store
(lock-free reads + serialized writes), granular field-level subscriptions,
ModelState multi-model state (plus granular subscriptions over it), the
multi-store registry, and the routed-reducer DSL. redux-kotlin-bundle-compose
adds the Compose State<T> bindings and saveable snapshot persistence on top.
val store = createConcurrentModelStore {
model(UserModel()) {
on<LoggedIn> { s, a -> s.copy(user = a.user) }
on<LoggedOut> { s, _ -> s.copy(user = null) }
}
}
store.dispatch(LoggedIn("ann"))See the Bundle guide and the
TaskFlow sample — a Compose Multiplatform Kanban app built
on redux-kotlin-bundle-compose end-to-end.
Every module is published individually. Import the BOM once to keep versions aligned, then add only what you need without repeating versions:
dependencies {
implementation(platform("org.reduxkotlin:redux-kotlin-bom:<version>"))
implementation("org.reduxkotlin:redux-kotlin")
implementation("org.reduxkotlin:redux-kotlin-concurrent")
}| Group | Modules |
|---|---|
| Core & stores |
redux-kotlin (core contracts + createStore), redux-kotlin-concurrent (createConcurrentStore — the recommended thread-safe store), redux-kotlin-threadsafe (deprecated — fully-synchronized predecessor), redux-kotlin-thunk (async actions middleware) |
| State shape |
redux-kotlin-granular (field-level subscriptions), redux-kotlin-registry (keyed multi-store container), redux-kotlin-multimodel (ModelState typesafe model bag), redux-kotlin-multimodel-granular (granular subscriptions over ModelState) |
| Compose |
redux-kotlin-compose (fieldState / selectorState bindings), redux-kotlin-compose-multimodel (bindings for ModelState), redux-kotlin-compose-saveable (snapshot persistence across rotation + process death) |
| Routing |
redux-kotlin-routing (routed (model, action) reducer DSL), redux-kotlin-routing-codegen (KSP @Reduce processor — in-repo, not yet on Maven Central) |
| Bundles |
redux-kotlin-bundle, redux-kotlin-bundle-compose, redux-kotlin-bom (Maven BOM) |
| DevTools (experimental) |
redux-kotlin-devtools-core, -bridge, -remote, -inapp, -inapp-noop, -ui — aligned by the BOM but exempt from semver until the surface stabilizes |
Usage is very similar to JS Redux and those docs will be useful https://redux.js.org/. These docs are not an intro to Redux, and just documentation on Kotlin specific bits. For more info on Redux in general, check out https://redux.js.org/.
Create an AppState class
data class AppState(val user: User, val feed: List<Feed>)Create Reducers:
val reducer: Reducer<AppState> = { state, action ->
when (action) {
is UserLoggedInAction -> state.copy(user = action.user)
...
}
}Create Middleware: There are a few ways to create middleware:
Using a curried function stored in a val/var:
val loggingMiddleware: Middleware = { store ->
{ next ->
{ action ->
//log here
next(action)
}
}
}Using a function:
fun loggingMiddleware(store: Store) = { next: Dispatcher ->
{ action: Any ->
//log here
next(action)
}
}Using the convenience helper function middleware:
val loggingMiddleware = middleware { store, next, action ->
//log here
next(action)
}Create a store
val store = createStore(reducer, AppState(user, listOf()), applyMiddleware(loggingMiddleware))You then will have access to dispatch and subscribe functions from the store.
For thread-safe access from multiple threads, use createConcurrentStore from
redux-kotlin-concurrent (lock-free reads, serialized writes) — the older
createThreadSafeStore / createSynchronizedStoreEnhancer are deprecated; see the
threading docs.
The repo ships a DevTools family for inspecting a running redux-kotlin app:
redux-kotlin-devtools-inapp) — a Compose Multiplatform overlay with
Actions / State / Diff / Pipeline / Outputs tabs, swapped out at release time by
redux-kotlin-devtools-inapp-noop.redux-kotlin-devtools-standalone) — observe any app
(including headless/native) from outside its process via the WebSocket bridge.redux-kotlin-devtools-cli) — the rk-devtools terminal tool: capture, query,
diff, and tail action streams.redux-kotlin-devtools-remote) — stream to the Redux DevTools
browser extension.See the integration guide and the website DevTools page.
Optional companion modules in this repo build on the core contracts — Compose bindings
(redux-kotlin-compose), async actions (redux-kotlin-thunk), granular subscriptions,
multi-store registries, routing, and the one-dependency bundles. See the
ecosystem page for the full list.
Raise an issue to add your external extension!
Want to give feedback, contribute, or ask questions?
A redux standard for Kotlin that supports multiplatform projects.
Full documentation at http://reduxkotlin.org.
Provide a standard redux implementation for Kotlin. In doing so will foster a ecosystem of middleware, store enhancers, & dev tools. These core values will guide descisions for the project:
Redux in Kotlin, and in mobile in particular, may differ a bit from javascript. Many have found the basic pattern useful on Android & iOS leading to tens of opensource redux libraries in Kotlin, Java, and Swift, yet an ecosystem has yet to emerge. A port of javascript redux is a good starting point for creating a standard and will aid in cross-pollination of middleware, store enhancers, & dev tools from the javascript world.
Redux has proven helpful for state management in mobile. A multiplatform Kotlin implementation & ecosystem will increase developer productivity and code reuse across platforms.
Droidcon NYC Slides Video TBA
Artifacts are hosted on Maven Central. Replace <version> with the latest release shown by the
badge above.
Requirements:
minSdk 21 or higherjvm, js (browser/node), android, iosArm64, iosX64,
iosSimulatorArm64, macosArm64, macosX64, linuxArm64, linuxX64, mingwX64
One dependency for the common redux-kotlin stack. For Jetpack / Multiplatform Compose apps:
kotlin {
sourceSets {
commonMain { // <--- name may vary on your project
dependencies {
implementation("org.reduxkotlin:redux-kotlin-bundle-compose:<version>")
}
}
}
}For everything else (no Compose runtime pulled in):
implementation("org.reduxkotlin:redux-kotlin-bundle:<version>")redux-kotlin-bundle transitively brings the core, the concurrent store
(lock-free reads + serialized writes), granular field-level subscriptions,
ModelState multi-model state (plus granular subscriptions over it), the
multi-store registry, and the routed-reducer DSL. redux-kotlin-bundle-compose
adds the Compose State<T> bindings and saveable snapshot persistence on top.
val store = createConcurrentModelStore {
model(UserModel()) {
on<LoggedIn> { s, a -> s.copy(user = a.user) }
on<LoggedOut> { s, _ -> s.copy(user = null) }
}
}
store.dispatch(LoggedIn("ann"))See the Bundle guide and the
TaskFlow sample — a Compose Multiplatform Kanban app built
on redux-kotlin-bundle-compose end-to-end.
Every module is published individually. Import the BOM once to keep versions aligned, then add only what you need without repeating versions:
dependencies {
implementation(platform("org.reduxkotlin:redux-kotlin-bom:<version>"))
implementation("org.reduxkotlin:redux-kotlin")
implementation("org.reduxkotlin:redux-kotlin-concurrent")
}| Group | Modules |
|---|---|
| Core & stores |
redux-kotlin (core contracts + createStore), redux-kotlin-concurrent (createConcurrentStore — the recommended thread-safe store), redux-kotlin-threadsafe (deprecated — fully-synchronized predecessor), redux-kotlin-thunk (async actions middleware) |
| State shape |
redux-kotlin-granular (field-level subscriptions), redux-kotlin-registry (keyed multi-store container), redux-kotlin-multimodel (ModelState typesafe model bag), redux-kotlin-multimodel-granular (granular subscriptions over ModelState) |
| Compose |
redux-kotlin-compose (fieldState / selectorState bindings), redux-kotlin-compose-multimodel (bindings for ModelState), redux-kotlin-compose-saveable (snapshot persistence across rotation + process death) |
| Routing |
redux-kotlin-routing (routed (model, action) reducer DSL), redux-kotlin-routing-codegen (KSP @Reduce processor — in-repo, not yet on Maven Central) |
| Bundles |
redux-kotlin-bundle, redux-kotlin-bundle-compose, redux-kotlin-bom (Maven BOM) |
| DevTools (experimental) |
redux-kotlin-devtools-core, -bridge, -remote, -inapp, -inapp-noop, -ui — aligned by the BOM but exempt from semver until the surface stabilizes |
Usage is very similar to JS Redux and those docs will be useful https://redux.js.org/. These docs are not an intro to Redux, and just documentation on Kotlin specific bits. For more info on Redux in general, check out https://redux.js.org/.
Create an AppState class
data class AppState(val user: User, val feed: List<Feed>)Create Reducers:
val reducer: Reducer<AppState> = { state, action ->
when (action) {
is UserLoggedInAction -> state.copy(user = action.user)
...
}
}Create Middleware: There are a few ways to create middleware:
Using a curried function stored in a val/var:
val loggingMiddleware: Middleware = { store ->
{ next ->
{ action ->
//log here
next(action)
}
}
}Using a function:
fun loggingMiddleware(store: Store) = { next: Dispatcher ->
{ action: Any ->
//log here
next(action)
}
}Using the convenience helper function middleware:
val loggingMiddleware = middleware { store, next, action ->
//log here
next(action)
}Create a store
val store = createStore(reducer, AppState(user, listOf()), applyMiddleware(loggingMiddleware))You then will have access to dispatch and subscribe functions from the store.
For thread-safe access from multiple threads, use createConcurrentStore from
redux-kotlin-concurrent (lock-free reads, serialized writes) — the older
createThreadSafeStore / createSynchronizedStoreEnhancer are deprecated; see the
threading docs.
The repo ships a DevTools family for inspecting a running redux-kotlin app:
redux-kotlin-devtools-inapp) — a Compose Multiplatform overlay with
Actions / State / Diff / Pipeline / Outputs tabs, swapped out at release time by
redux-kotlin-devtools-inapp-noop.redux-kotlin-devtools-standalone) — observe any app
(including headless/native) from outside its process via the WebSocket bridge.redux-kotlin-devtools-cli) — the rk-devtools terminal tool: capture, query,
diff, and tail action streams.redux-kotlin-devtools-remote) — stream to the Redux DevTools
browser extension.See the integration guide and the website DevTools page.
Optional companion modules in this repo build on the core contracts — Compose bindings
(redux-kotlin-compose), async actions (redux-kotlin-thunk), granular subscriptions,
multi-store registries, routing, and the one-dependency bundles. See the
ecosystem page for the full list.
Raise an issue to add your external extension!
Want to give feedback, contribute, or ask questions?