
Feature-flagging toolkit with type-safe properties, DSL configuration, serialization support, custom stores, auto-create behavior, conditional ifEnabled helpers, group management, and extensible property retrieval.
FF4K is a Kotlin Multiplatform port of the ideas behind FF4J (Feature Flipping for Java): feature flags, flipping strategies and typed properties behind a small, coroutine-first API. The JVM target ships today; other Kotlin targets can be added from the same common code.
Alpha. FF4K is pre-1.0. Public APIs, the JSON format and store schemas change between releases without a deprecation cycle.
dependencies {
implementation(platform("com.yonatankarp:ff4k-bom:<version>"))
implementation("com.yonatankarp:ff4k-core")
}import com.yonatankarp.ff4k.*
import com.yonatankarp.ff4k.strategy.*
val ff4k = FF4k()
ff4k.features.put(Feature("dark-mode", enabled = true, group = "ui"))
ff4k.features.put(
Feature(
id = "beta-checkout",
enabled = true,
strategy = ContextFilterStrategy("region", setOf("eu")) and UserPercentageStrategy(10),
),
)
ff4k.properties.put(Property("max-retries", 3))
if (ff4k.check("dark-mode")) enableDarkMode()
ff4k.check("beta-checkout", mapOf("region" to "eu", "userId" to user.id))
val retries: Int? = ff4k.property("max-retries")
ff4k.features.disableGroup("ui")Features and properties can also be loaded from JSON:
val ff4k = FF4k(FF4kConfiguration.fromJson(File("ff4k.json").readText())){
"features": [
{ "id": "dark-mode", "enabled": true, "group": "ui" },
{ "id": "beta-checkout", "enabled": true,
"strategy": { "type": "contextFilter", "key": "region", "allowed": ["eu"] } }
],
"properties": [
{ "name": "max-retries", "type": "int", "value": 3 }
]
}Stores are pluggable: ff4k-core ships in-memory stores, ff4k-store-jdbc persists to PostgreSQL or MySQL on any DataSource, and ff4k-store-sqlite to SQLite through SQLDelight. Wrap a database store with cached() to keep flag checks off the database. Implement FeatureStore and PropertyStore for anything else and verify it with ff4k-contract-test.
See the documentation for strategies, configuration and custom stores.
Contributions are welcome! Please read our Contributing Guidelines before submitting a pull request.
To report a security vulnerability, please see our Security Policy.
This project is licensed under the Apache License 2.0.
FF4K is a Kotlin Multiplatform port of the ideas behind FF4J (Feature Flipping for Java): feature flags, flipping strategies and typed properties behind a small, coroutine-first API. The JVM target ships today; other Kotlin targets can be added from the same common code.
Alpha. FF4K is pre-1.0. Public APIs, the JSON format and store schemas change between releases without a deprecation cycle.
dependencies {
implementation(platform("com.yonatankarp:ff4k-bom:<version>"))
implementation("com.yonatankarp:ff4k-core")
}import com.yonatankarp.ff4k.*
import com.yonatankarp.ff4k.strategy.*
val ff4k = FF4k()
ff4k.features.put(Feature("dark-mode", enabled = true, group = "ui"))
ff4k.features.put(
Feature(
id = "beta-checkout",
enabled = true,
strategy = ContextFilterStrategy("region", setOf("eu")) and UserPercentageStrategy(10),
),
)
ff4k.properties.put(Property("max-retries", 3))
if (ff4k.check("dark-mode")) enableDarkMode()
ff4k.check("beta-checkout", mapOf("region" to "eu", "userId" to user.id))
val retries: Int? = ff4k.property("max-retries")
ff4k.features.disableGroup("ui")Features and properties can also be loaded from JSON:
val ff4k = FF4k(FF4kConfiguration.fromJson(File("ff4k.json").readText())){
"features": [
{ "id": "dark-mode", "enabled": true, "group": "ui" },
{ "id": "beta-checkout", "enabled": true,
"strategy": { "type": "contextFilter", "key": "region", "allowed": ["eu"] } }
],
"properties": [
{ "name": "max-retries", "type": "int", "value": 3 }
]
}Stores are pluggable: ff4k-core ships in-memory stores, ff4k-store-jdbc persists to PostgreSQL or MySQL on any DataSource, and ff4k-store-sqlite to SQLite through SQLDelight. Wrap a database store with cached() to keep flag checks off the database. Implement FeatureStore and PropertyStore for anything else and verify it with ff4k-contract-test.
See the documentation for strategies, configuration and custom stores.
Contributions are welcome! Please read our Contributing Guidelines before submitting a pull request.
To report a security vulnerability, please see our Security Policy.
This project is licensed under the Apache License 2.0.