ktor-kmp-client-architecture

Installation
SKILL.md

One engine, several clients

The only platform-specific thing about an HTTP client is the engine, so that is the only thing behind expect/actual:

// commonMain
expect fun getEngine(): HttpClientEngineFactory<HttpClientEngineConfig>
// androidMain and jvmMain — the same JVM-backed engine
actual fun getEngine(): HttpClientEngineFactory<HttpClientEngineConfig> = OkHttp
// iosMain
actual fun getEngine(): HttpClientEngineFactory<HttpClientEngineConfig> = Darwin

Everything above it — plugins, serialization, defaults — is common code. Each integration then builds its own client, and an integration that also downloads bytes builds a second one:

Installs
2
GitHub Stars
35
First Seen
6 days ago
ktor-kmp-client-architecture — maxrave-dev/kotlin-footguns