Ktor 3.0 launches with Kotlin 2.0, enhanced IO, and real-time features
Ktor 3.0 has been released, bringing major updates such as the integration of Kotlin 2.0 and the adoption of the kotlinx-io library. This new library enhances performance and unifies IO functionality with a multiplatform API capable of handling various data sources, including files and compression. The update deprecates older IO APIs like Input, Output, ByteReadChannel, and ByteWriteChannel, although these will remain supported until version 4.0.
Significant performance improvements, with over 90% enhancements in certain scenarios, are achieved by reducing byte copying between channels and network interfaces. Additionally, the update introduces initial support for Server-Sent Events (SSE), which enhances real-time communication by allowing servers to push event updates to clients over HTTP.
Beyond performance enhancements, Ktor 3.0 offers new features such as the StaticZip function for serving ZIP archive contents as static content and a CSRF protection plugin to safeguard state-changing operations like POST, PUT, and DELETE. The Ktor client now supports WebAssembly as a build target, further expanding the Kotlin Multiplatform ecosystem. Changes to the TestApplication class necessitate explicit module loading, while plugin updates include a renamed CallLogging plugin package and the replacement of the Locations plugin with the new Resources plugin for type-safe routing.