multiplatform-settings
/multiplatform-settings
Key-value persistence in Kotlin Multiplatform with the multiplatform-settings library (com.russhwolf:multiplatform-settings:1.3.0). Use when storing simple preferences, flags, or tokens in shared code - the Settings and ObservableSettings interfaces, typed get/put (getInt, putString, getBooleanOrNull), property delegates (by settings.int()), the no-arg Settings() factory, platform factories (SharedPreferencesSettings on Android, NSUserDefaultsSettings on Apple), and reactive FlowSettings/getIntFlow via multiplatform-settings-coroutines. For a shared relational database use sqldelight-patterns;
- Author
- TalissonVitorino ↗
- Repository
- kmp-ios-skills ↗
- Licence
- MIT
- Last repository change
- 25.08.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 25.08.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Key-value persistence in Kotlin Multiplatform with the multiplatform-settings library (com.russhwolf:multiplatform-settings:1.3.0). Use when storing simple preferences, flags, or tokens in shared code - the Settings and ObservableSettings interfaces, typed get/put (getInt, putString, getBooleanOrNull), property delegates (by settings.int()), the no-arg Settings() factory, platform factories (SharedPreferencesSettings on Android, NSUserDefaultsSettings on Apple), and reactive FlowSettings/getIntFlow via multiplatform-settings-coroutines. For a shared relational database use sqldelight-patterns;
Original author description
Key-value persistence in Kotlin Multiplatform with the multiplatform-settings library (com.russhwolf:multiplatform-settings:1.3.0). Use when storing simple preferences, flags, or tokens in shared code - the Settings and ObservableSettings interfaces, typed get/put (getInt, putString, getBooleanOrNull), property delegates (by settings.int()), the no-arg Settings() factory, platform factories (SharedPreferencesSettings on Android, NSUserDefaultsSettings on Apple), and reactive FlowSettings/getIntFlow via multiplatform-settings-coroutines. For a shared relational database use sqldelight-patterns;
How it works
- Overview
- When to use
- Dependencies
- Creating a Settings instance
- Typed access & delegates
- Reactive (FlowSettings)
- Common mistakes
- See also
SKILL.md preview
---
name: multiplatform-settings
description: Key-value persistence in Kotlin Multiplatform with the multiplatform-settings library (com.russhwolf:multiplatform-settings:1.3.0). Use when storing simple preferences, flags, or tokens in shared code - the Settings and ObservableSettings interfaces, typed get/put (getInt, putString, getBooleanOrNull), property delegates (by settings.int()), the no-arg Settings() factory, platform factories (SharedPreferencesSettings on Android, NSUserDefaultsSettings on Apple), and reactive FlowSettings/getIntFlow via multiplatform-settings-coroutines. For a shared relational database use sqldelight-patterns; for Android-only DataStore/Room use room-patterns; for secrets use mobile-security.
---
# Multiplatform Settings (key-value persistence)
## Overview
`multiplatform-settings` (russhwolf) is the KMP equivalent of SharedPreferences / NSUserDefaults — simple typed key-value storage from `commonMain`. Current version **1.3.0**. The `Settings` interface wraps `SharedPreferences` on Android and `NSUserDefaults` on Apple, plus `localStorage` on JS.
## When to use
- Storing small preferences, flags, or tokens in shared code
- Reactive reads of a setting (`FlowSettings`)
- NOT for structured/relational data → use `sqldelight-patterns`
## Dependencies
```kotlin
commonMain.dependencies {
implementation("com.russhwolf:multiplatform-settings:1.3.0")
implementation("com.russhwolf:multiplatform-settings-coroutines:1.3.0") // Flow support
// implementation("com.russhwolf:multiplatform-settings-no-arg:1.3.0") // Settings() factory
}
```
## Creating a Settings instance
```kotlin
// Shared code takes a Settings (inject it — see kmp-di)
class Prefs(private val settings: Settings) { /* ... */ }
// Android
val settings: Settings = SharedPreferencesSettings(sharedPreferences)
// Apple
val settings: Settings = NSUserDefaultsSettings(NSUserDefaults.standardUserDefaults)
// No-arg (platform defaults) — needs multiplatform-settings-no-arg
val settings: Settings = Settings()
```
## Typed access & delegates
```kotlin
settings.putString("token", t)
val token: String? = settings.getStringOrNull("token")
val launches: Int = settings.getInt("launches", defaultValue = 0)
// Property delegate (key defaults to the property name)
var darkMode: Boolean by settings.boolean("dark_mode", false)
```
## Reactive (FlowSettings)
Reactive reads require an **`ObservableSettings`** — `SharedPreferencesSettings` (Android) and `NSUserDefaultsSettings` (Apple) implement it; the bare no-arg `Settings()` does not guarantee observability. Build an `ObservableSettings` and use the typed `*Flow` extensions (from `multiplatform-settings-coroutines`):
```kotlin
val observable: ObservableSettings = SharedPreferencesSettings(prefs) // or NSUserDefaultsSettings(...)
val darkModeFlow: Flow<Boolean> = observable.getBooleanFlow("dark_mode", false)
val launchesFlow: Flow<Int> = observable.getIntFlow("launches", 0)
// or the full coroutine API:
val flowSettings: FlowSettings = observable.toFlowSettings()
val tokenFlow: Flow<String?> = flowSettings.getStringOrNullFlow("token")
```
## Common mistakes
| Mistake | Fix |
|---|---|
| Expecting listeners from a plain `Settings` | Use/cast to `ObservableSettings` for flows and listeners |
| Storing large or structured data | Use SQLDelight (`sqldelight-patterns`) |
| Leaking a `SettingsListener` | Call `deactivate()` on the returned listener when done |
| Putting secrets in plain prefs | Not encrypted — use platform secure storage (`mobile-security`) |
## See also
- Shared relational storage: `sqldelight-patterns`
- Injecting the `Settings` instance: `kmp-di`
- Android-only DataStore/Room: `room-patterns`
Versions
The database has no other skills named multiplatform-settings.
Database snapshot: 13.11.2026 · package version 5e2246ad9afb (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100sqldelight-patterns
SQLDelight for Kotlin Multiplatform shared persistence - .sq files in commonMain, platform drivers (AndroidSqliteDriver on Android, NativeSqliteDriver on iOS), type adapters, migrations, and a shared database accessed from common code. Use for multiplatform or shared… - 100kotlin-expert
Expert-level Kotlin development, Android, coroutines, and multiplatform. Use when the user mentions Android, coroutines, multiplatform, or JVM, or when the task involves Kotlin Fundamentals, Android Development, Kotlin Multiplatform, or Kotlin Style. - 90mobile-kotlin-multiplatform
Use this skill when the user says 'Kotlin Multiplatform', 'KMP', 'Compose Multiplatform', 'shared Kotlin', 'KMP module', 'expect/actual', 'commonMain', 'KMP project', 'multiplatform library'. Build cross-platform mobile apps with Kotlin Multiplatform sharing business logic,… - 100kotlin-multiplatform
KMP/CMP shared business logic, Compose Multiplatform, expect/actual, Ktor, SQLDelight, and platform-specific implementations. Use when building cross-platform Kotlin applications for Android, iOS, desktop, or web. - 100kotlin-multiplatform
Kotlin Multiplatform (KMP) is JetBrains' technology for sharing Kotlin code between Android, iOS, web, and desktop applications while keeping the UI native on each platform. Use when a user asks to set up a KMP shared module, share business logic, networking or a data layer… - 100kotlin-multiplatform
Expert Kotlin Multiplatform (KMP) assistance covering expect/actual declarations, shared business logic across iOS/Android, Compose Multiplatform, and Ktor client integration. Use when sharing domain models, networking, or persistence across platforms while retaining native UI.