Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/configcat/kotlin-sdk
ConfigCat SDK for Kotlin Multiplatform. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
https://github.com/configcat/kotlin-sdk
configcat configcat-sdk feature-flag feature-flagging feature-flags feature-toggle feature-toggles kotlin kotlin-multiplatform
Last synced: 25 days ago
JSON representation
ConfigCat SDK for Kotlin Multiplatform. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
- Host: GitHub
- URL: https://github.com/configcat/kotlin-sdk
- Owner: configcat
- License: mit
- Created: 2022-07-26T13:47:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-30T02:03:57.000Z (about 1 month ago)
- Last Synced: 2024-10-01T17:05:44.970Z (about 1 month ago)
- Topics: configcat, configcat-sdk, feature-flag, feature-flagging, feature-flags, feature-toggle, feature-toggles, kotlin, kotlin-multiplatform
- Language: Kotlin
- Homepage: https://configcat.com/docs/sdk-reference/kotlin
- Size: 1.74 MB
- Stars: 14
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- kmp-awesome - ConfigCat - Kotlin Multiplatform SDK for ConfigCat (Libraries / 🧩 Service SDK)
README
# ConfigCat SDK for Kotlin Multiplatform
https://configcat.comConfigCat SDK for Kotlin Multiplatform provides easy integration for your application to ConfigCat.
ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.
ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
[![Kotlin CI](https://github.com/configcat/kotlin-sdk/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/configcat/kotlin-sdk/actions/workflows/ci.yml)
[![Maven Central](https://img.shields.io/maven-central/v/com.configcat/configcat-kotlin-client?label=maven%20central)](https://search.maven.org/artifact/com.configcat/configcat-kotlin-client/)
![Snapshot](https://img.shields.io/nexus/s/com.configcat/configcat-kotlin-client?label=snapshot&server=https%3A%2F%2Foss.sonatype.org)
[![Quality Gate Status](https://img.shields.io/sonar/quality_gate/configcat_kotlin-sdk?logo=SonarCloud&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/project/overview?id=configcat_kotlin-sdk)
[![SonarCloud Coverage](https://img.shields.io/sonar/coverage/configcat_kotlin-sdk?logo=SonarCloud&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/project/overview?id=configcat_kotlin-sdk)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9-blueviolet.svg?logo=kotlin)](http://kotlinlang.org)[API Documentation](https://configcat.github.io/kotlin-sdk/)
## Getting started
### 1. Install the ConfigCat SDK
```kotlin
val configcatVersion: String by projectkotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.configcat:configcat-kotlin-client:$configcatVersion")
}
}
}
}
```### 2. Go to the ConfigCat Dashboard to get your *SDK Key*:
![SDK-KEY](https://raw.githubusercontent.com/ConfigCat/java-sdk/master/media/readme02-3.png "SDK-KEY")### 3. Import *com.configcat.** in your application code
```kotlin
import com.configcat.*
```### 4. Create a *ConfigCat* client instance
```kotlin
import com.configcat.*suspend fun main() {
val client = ConfigCatClient("#YOUR-SDK-KEY#")
}
```### 5. Get your setting value
```kotlin
import com.configcat.*suspend fun main() {
val client = ConfigCatClient("#YOUR-SDK-KEY#")
val isMyAwesomeFeatureEnabled = client.getValue("isMyAwesomeFeatureEnabled", false)
if (isMyAwesomeFeatureEnabled) {
doTheNewThing()
} else {
doTheOldThing()
}
}
```### 6. Close the client on application exit
```kotlin
client.close()
```## Getting user-specific setting values with Targeting
Using this feature, you will be able to get different setting values for different users in your application by passing a `User Object` to the `getValue()` function.Read more about Targeting [here](https://configcat.com/docs/advanced/targeting/).
## User Object
Percentage and targeted rollouts are calculated by the user object passed to the configuration requests.
The user object must be created with a **mandatory** identifier parameter which uniquely identifies each user:
```kotlin
import com.configcat.*suspend fun main() {
val client = ConfigCatClient("#YOUR-SDK-KEY#")
val user = ConfigCatUser("#USER-IDENTIFIER#")
val isMyAwesomeFeatureEnabled = client.getValue("isMyAwesomeFeatureEnabled", false, user)
if (isMyAwesomeFeatureEnabled) {
doTheNewThing()
} else {
doTheOldThing()
}
}
```## Sample / Demo app
* [Kotlin Multiplatform Mobile app](https://github.com/configcat/kotlin-sdk/tree/main/samples/kmm)
* [Android app](https://github.com/configcat/kotlin-sdk/tree/main/samples/android)
* [Kotlin app](https://github.com/configcat/kotlin-sdk/tree/main/samples/kotlin)
* [React app](https://github.com/configcat/kotlin-sdk/tree/main/samples/js)
* [Node.js app](https://github.com/configcat/kotlin-sdk/tree/main/samples/node-js)## Polling Modes
The ConfigCat SDK supports three different polling mechanisms to acquire the setting values from ConfigCat. After the latest setting values are downloaded, they are stored in an internal cache . After that, all requests are served from the cache. Read more about Polling Modes and how to use them at [ConfigCat Kotlin Docs](https://configcat.com/docs/sdk-reference/kotlin/).## Support
If you need help using this SDK, feel free to contact the ConfigCat Staff at [https://configcat.com](https://configcat.com). We're happy to help.## Contributing
Contributions are welcome. For more info please read the [Contribution Guideline](CONTRIBUTING.md).## About ConfigCat
- [Official ConfigCat SDKs for other platforms](https://github.com/configcat)
- [Documentation](https://configcat.com/docs)
- [Blog](https://configcat.com/blog)