
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 (KMP) implementation of the popular FF4J (Feature Flipping for Java) library. It brings robust feature flagging capabilities to the Kotlin ecosystem, supporting multiplatform projects.
kotlinx.serialization.Use the ff4k DSL to configure the library. This allows you to define features and properties in a structured, type-safe way.
import com.yonatankarp.ff4k.dsl.core.ff4k
val ff4k = ff4k {
// Define features
features {
feature("dark-mode") {
isEnabled = true
description = "Enable dark mode theme"
group = "ui-experiments"
}
feature("beta-dashboard") {
isEnabled = false
permissions("ADMIN", "BETA_USER")
}
}
// Define properties
properties {
property("max-retries") {
value = 3
description = "Maximum API retry attempts"
readOnly = true
}
property("api-url") {
value = "https://api.example.com"
}
}
}You can configure storage backends and behavior via the ff4k function arguments.
val ff4k = ff4k(
autoCreate = true, // Auto-create missing features as disabled
featureStore = InMemoryFeatureStore(), // Default
propertyStore = InMemoryPropertyStore() // Default
) {
// ... configuration block
}Use the idiomatic ifEnabled and ifEnabledOrElse functions for cleaner conditional logic.
// Execute a block if the feature is enabled
ff4k.ifEnabled("dark-mode") {
enableDarkMode()
}
// Execute one block if enabled, another if disabled
ff4k.ifEnabledOrElse("dark-mode",
enabled = { enableDarkMode() },
disabled = { enableLightMode() }
)Access properties safely with type conversion.
// Retrieve property object and access its value
val retries: Int? = ff4k.property<Int>("max-retries")?.value
val apiUrl: String? = ff4k.property<String>("api-url")?.valueEnable or disable entire groups of features.
// Enable all features in the 'ui-experiments' group
ff4k.enableGroup("ui-experiments")
// Disable all features in the 'ui-experiments' group
ff4k.disableGroup("ui-experiments")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 (KMP) implementation of the popular FF4J (Feature Flipping for Java) library. It brings robust feature flagging capabilities to the Kotlin ecosystem, supporting multiplatform projects.
kotlinx.serialization.Use the ff4k DSL to configure the library. This allows you to define features and properties in a structured, type-safe way.
import com.yonatankarp.ff4k.dsl.core.ff4k
val ff4k = ff4k {
// Define features
features {
feature("dark-mode") {
isEnabled = true
description = "Enable dark mode theme"
group = "ui-experiments"
}
feature("beta-dashboard") {
isEnabled = false
permissions("ADMIN", "BETA_USER")
}
}
// Define properties
properties {
property("max-retries") {
value = 3
description = "Maximum API retry attempts"
readOnly = true
}
property("api-url") {
value = "https://api.example.com"
}
}
}You can configure storage backends and behavior via the ff4k function arguments.
val ff4k = ff4k(
autoCreate = true, // Auto-create missing features as disabled
featureStore = InMemoryFeatureStore(), // Default
propertyStore = InMemoryPropertyStore() // Default
) {
// ... configuration block
}Use the idiomatic ifEnabled and ifEnabledOrElse functions for cleaner conditional logic.
// Execute a block if the feature is enabled
ff4k.ifEnabled("dark-mode") {
enableDarkMode()
}
// Execute one block if enabled, another if disabled
ff4k.ifEnabledOrElse("dark-mode",
enabled = { enableDarkMode() },
disabled = { enableLightMode() }
)Access properties safely with type conversion.
// Retrieve property object and access its value
val retries: Int? = ff4k.property<Int>("max-retries")?.value
val apiUrl: String? = ff4k.property<String>("api-url")?.valueEnable or disable entire groups of features.
// Enable all features in the 'ui-experiments' group
ff4k.enableGroup("ui-experiments")
// Disable all features in the 'ui-experiments' group
ff4k.disableGroup("ui-experiments")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.