Flagship
Kotlin Multiplatform Feature Flags

Feature Flags & A/B Testing
for Kotlin Multiplatformv0.1.1

Powerful, type-safe feature flags with built-in A/B testing.
Works on Android & iOS out of the box.

Get Started View on GitHub

Quick Start Examples

Android Application Setup
dependencies {
    implementation("io.maxluxs.flagship:flagship-core:0.1.1")
    implementation("io.maxluxs.flagship:flagship-provider-firebase:0.1.1")
}

import android.app.Application
import io.maxluxs.flagship.core.Flagship
import io.maxluxs.flagship.core.FlagsConfig
import io.maxluxs.flagship.core.manager.DefaultFlagsManager
import io.maxluxs.flagship.core.platform.AndroidFlagsInitializer
import io.maxluxs.flagship.provider.firebase.FirebaseProviderFactory
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        
        val firebaseDefaults = mapOf(
            "new_ui" to false,
            "api_timeout" to 5000,
            "welcome_message" to "Hello"
        )
        
        val config = FlagsConfig(
            appKey = "my-app",
            environment = "production",
            providers = listOf(
                FirebaseProviderFactory.create(
                    application = this,
                    defaults = firebaseDefaults
                )
            ),
            cache = AndroidFlagsInitializer.createPersistentCache(this)
        )
        
        Flagship.configure(config)
        
        val manager = Flagship.manager() as DefaultFlagsManager
        val defaultContext = AndroidFlagsInitializer.createDefaultContext(this)
        manager.setDefaultContext(defaultContext)
        
        CoroutineScope(Dispatchers.Default).launch {
            manager.ensureBootstrap(timeoutMs = 3000)
        }
    }
}

import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        lifecycleScope.launch {
            if (Flagship.isEnabled("new_ui")) {
                showNewUI()
            }
            
            val timeout: Int = Flagship.get("api_timeout", default = 5000)
            
            val assignment = Flagship.assign("checkout_exp")
            when (assignment?.variant) {
                "control" -> showLegacyCheckout()
                "variant_a" -> showNewCheckout()
            }
        }
    }
}
🚀
Kotlin Multiplatform
Share feature flag logic between Android and iOS. Write once, run everywhere.
🎯
A/B Testing
Built-in experiment support with deterministic bucketing using MurmurHash3.
🔌
Pluggable Providers
Firebase Remote Config, REST API, or custom providers. Mix and match as needed.
💾
Offline First
Persistent cache with TTL. Works without network connection.
🛡️
Type Safe
Compile-time safety with Kotlin sealed classes. No runtime surprises.
🎨
Debug Dashboard
Compose Multiplatform UI for testing and debugging flags locally.

Usage Examples

Simplified API (Suspend Functions)
// Boolean flags
lifecycleScope.launch {
    if (Flagship.isEnabled("new_ui")) {
        showNewUI()
    }
}

// Typed values - type inferred from default
lifecycleScope.launch {
    val timeout: Int = Flagship.get("api_timeout", default = 5000)
    val message: String = Flagship.get("welcome_msg", default = "Hello")
    val threshold: Double = Flagship.get("score_threshold", default = 0.75)
}

// Experiments
lifecycleScope.launch {
    val assignment = Flagship.assign("checkout_exp")
    when (assignment?.variant) {
        "control" -> showLegacyCheckout()
        "variant_a" -> showNewCheckout()
        else -> showLegacyCheckout()
    }
}

// With custom context
lifecycleScope.launch {
    val ctx = EvalContext(
        userId = "user123",
        region = "US",
        attributes = mapOf("tier" to "premium")
    )
    val assignment = Flagship.assign("checkout_exp", context = ctx)
}

Documentation

📖
Usage Guide
Learn how to integrate Flagship into your app with step-by-step examples.
📚
API Reference
Complete API documentation with examples for all public interfaces.
🔄
Migration Guide
Migrate from Firebase Remote Config, LaunchDarkly, or custom solutions.
🔧
KDoc
Auto-generated API documentation from source code comments.