Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 12, 2026·2 min de lecture

Ktor — Async Web Framework for Kotlin by JetBrains

Ktor is a framework for quickly creating connected applications in Kotlin with minimal effort. Built by JetBrains, it supports coroutines natively, runs on multiple engines (Netty, CIO, Jetty), and works for server + client HTTP in Kotlin Multiplatform.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
step-1.md
Commande d'installation directe
npx -y tokrepo@latest install 41300248-3634-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

TL;DR
Ktor is JetBrains' lightweight async web framework for building Kotlin server and client HTTP applications.
§01

What it is

Ktor is a framework by JetBrains for building connected applications in Kotlin with minimal effort. It supports coroutines natively, runs on multiple engines (Netty, CIO, Jetty), and works for both server-side HTTP and client-side HTTP in Kotlin Multiplatform projects.

Ktor is designed for Kotlin developers who want a lightweight, non-opinionated framework that leverages Kotlin's language features rather than imposing its own abstractions.

§02

How it saves time or tokens

Ktor's plugin-based architecture means you only include what you need. There is no framework boilerplate for features you do not use. Native coroutine support makes async I/O straightforward without callback hell. The same HTTP client works across JVM, Android, iOS, and JavaScript targets via Kotlin Multiplatform.

§03

How to use

  1. Create a project via IntelliJ IDEA or Gradle
  2. Add Ktor dependencies to build.gradle.kts:
plugins {
    id("io.ktor.plugin") version "3.0.0"
    kotlin("plugin.serialization") version "2.0.0"
}

dependencies {
    implementation("io.ktor:ktor-server-core")
    implementation("io.ktor:ktor-server-netty")
    implementation("io.ktor:ktor-server-content-negotiation")
    implementation("io.ktor:ktor-serialization-kotlinx-json")
}
  1. Write your server:
fun main() {
    embeddedServer(Netty, port = 8080) {
        install(ContentNegotiation) { json() }
        routing {
            get("/hello") {
                call.respond(mapOf("message" to "Hello, Ktor"))
            }
        }
    }.start(wait = true)
}
§04

Example

// Full REST API with serialization
@Serializable
data class Task(val id: Int, val title: String, val done: Boolean)

fun Application.configureRouting() {
    val tasks = mutableListOf(
        Task(1, 'Build API', false),
        Task(2, 'Write tests', false)
    )
    routing {
        get("/tasks") { call.respond(tasks) }
        post("/tasks") {
            val task = call.receive<Task>()
            tasks.add(task)
            call.respond(HttpStatusCode.Created, task)
        }
    }
}
§05

Related on TokRepo

§06

Common pitfalls

  • Forgetting to install the ContentNegotiation plugin, which causes serialization to silently fail
  • Mixing blocking I/O calls inside coroutine handlers, which blocks the event loop
  • Not configuring CORS when building APIs consumed by browser frontends

Questions fréquentes

How does Ktor compare to Spring Boot?+

Ktor is lightweight and non-opinionated, using a plugin system where you add only what you need. Spring Boot provides a comprehensive ecosystem with convention-over-configuration. Ktor is better for microservices and Kotlin-first projects; Spring Boot is better for enterprise Java ecosystems.

Does Ktor support WebSockets?+

Yes. Ktor has a built-in WebSocket plugin for both server and client. Server-side WebSockets support coroutine-based message handling, making it natural to write async real-time applications in Kotlin.

Can Ktor run on Kotlin Multiplatform?+

The Ktor HTTP client works across JVM, Android, iOS, JavaScript, and native targets via Kotlin Multiplatform. The server side runs on JVM targets (Netty, CIO, Jetty engines).

What engines does Ktor support?+

Ktor supports Netty (most popular, production-ready), CIO (Kotlin-native coroutine-based), Jetty (servlet-based), and Tomcat. Each engine has different performance characteristics and deployment requirements.

Is Ktor production-ready?+

Yes. Ktor is maintained by JetBrains and used in production by many companies. It follows semantic versioning with stable API guarantees. The 3.x release line is the current stable version.

Sources citées (3)

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires