kmp-networking

Create a shared Ktor-based HTTP client with platform-specific engines for Kotlin Multiplatform.

61|17|Updated Feb 2, 2026
One-click install
npx skills add https://github.com/ahmed3elshaer/everything-claude-code-mobile --skill kmp-networking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kmp-networking
Source: https://github.com/ahmed3elshaer/everything-claude-code-mobile/tree/main/skills/kmp-networking
Command: npx skills add https://github.com/ahmed3elshaer/everything-claude-code-mobile --skill kmp-networking

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a shared networking layer for Kotlin Multiplatform projects, unifying HTTP calls across platforms and reducing boilerplate by using a single Ktor-based client with platform-specific engines.

Core Features & Use Cases

  • Shared HttpClientFactory for commonMain with JSON serialization, request configuration, and logging.
  • Platform-specific engines: OkHttp for Android and Darwin for iOS, ensuring performance and native behavior.
  • API service pattern with Bearer token authentication and structured error handling across platforms.
  • Reusable patterns for retries, default requests, and consistent API wrappers across Kotlin/Native and JVM targets.

Quick Start

  • Add Kotlin Multiplatform, Ktor, and serialization dependencies in your shared module.
  • Create and configure the HttpClient via HttpClientFactory and inject it into your API services.
  • Use the provided UserApi or your own API wrappers to make network requests.

Frequently Asked Questions about kmp-networking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up cross-platform HTTP networking in Kotlin Multiplatform?

Cross-platform HTTP networking in Kotlin Multiplatform uses a shared Ktor HttpClient with platform-specific engines: OkHttp for Android and Darwin for iOS. Configure the client in commonMain with JSON serialization, then inject it into API services for consistent requests across platforms.

Can I use the same HTTP client for both Android and iOS in Kotlin Multiplatform?

Yes. A single Ktor-based HttpClient with platform-specific engines handles both Android and iOS. This eliminates boilerplate, ensures consistent API access and authentication, and reduces duplicate networking code across targets.

How do I implement Bearer token authentication in a Kotlin Multiplatform networking layer?

Bearer token authentication is implemented via the API service pattern with token refresh and structured error handling. Configure defaultRequest in the HttpClient to include authorization headers, then apply retry logic and error handling consistently across all platform-specific engines.

What's the best way to handle platform-specific HTTP engines in Kotlin Multiplatform?

Use a shared HttpClientFactory in commonMain that exposes platform-specific engine implementations. OkHttp handles Android networking with native performance, while Darwin provides native iOS behavior—both behind a unified client interface for simplified API wrapper code.

Do I need separate networking code for Android and iOS in Kotlin Multiplatform projects?

No. A shared networking layer with platform-specific engines eliminates duplication. The HttpClientFactory abstracts engine selection, so Android and iOS applications use the same API service wrappers, logging, and request configuration from commonMain.

How do I structure error handling across platforms in a Kotlin Multiplatform HTTP client?

Error handling is centralized in the API service pattern with structured responses that work across all platform engines. Combine Ktor's built-in error mechanisms with custom handlers in commonMain to ensure consistent error propagation from Android/OkHttp and iOS/Darwin.