JetBrains' Kotlin-native server framework — coroutine-driven, composable, and deeply idiomatic. The lightweight alternative to Spring for Kotlin teams.
← Back to Server SideContentNegotiation, Authentication, CORS) via a clean DSL.fun main() { embeddedServer(Netty, port = 8080) { install(ContentNegotiation) { json() } routing { get("/products") { call.respond(listOf(Product("Widget", 9.99))) } post("/products") { val p = call.receive<Product>() call.respond(HttpStatusCode.Created, p) } } }.start(wait = true) } @Serializable data class Product(val name: String, val price: Double)
Every Ktor handler is a suspend function. You can await DB calls or HTTP requests without blocking — millions of concurrent connections on a small thread pool.
Cross-cutting concerns are added with install(...):
| Plugin | Purpose |
|---|---|
| ContentNegotiation | JSON / XML / ProtoBuf via kotlinx.serialization, Jackson, Gson. |
| Authentication | JWT, OAuth, Basic, Form, sessions. |
| StatusPages | Centralized exception handling. |
| CallLogging | Structured request logging. |
| WebSockets | Built-in WebSocket DSL. |
The same DSL powers a multiplatform HTTP client. Same code can fetch APIs from a JVM backend, an Android app, or an iOS app — perfect with Kotlin Multiplatform.
Teams who chose Kotlin and want a Kotlin-native framework.
Lighter than Spring Boot; faster cold starts.
Ktor client shares HTTP code across Android, iOS, web.
Coroutine-based async excels at long-lived connections.