Skip to content
Back to skills

Multiplatform Settings

ASecurity

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/getI...

  • 16 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 11, 2026
developmentgokotlinsqlreactapidatabasesecurity

Works with

  • api

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add TalissonVitorino/kmp-ios-skills --skill multiplatform-settings --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Multiplatform Settings?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Multiplatform Settings
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/talissonvitorino-multiplatform-settings/badge)](https://www.skillsdirectory.com/skills/talissonvitorino-multiplatform-settings)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.