Ktor 1.0 Released: A Connected Applications Framework by JetBrains

As we work on Kotlin, we implement many features that help build idiomatic and high-performing APIs. We’ve been dreaming of seeing a Web framework that utilizes these features to the max. Today, we can finally say we’ve built that kind of framework! Please welcome Ktor, which has just reached 1.0.

Ktor is a Kotlin framework for building asynchronous servers and clients in connected systems. It is being created by the Kotlin team, and as such, it takes full advantage of the language in order to provide a great developer experience and excellent runtime performance.

Ktor

Ktor is built from the ground up using coroutines, which make it possible to express complex asynchronous constructs as if they were simple sequential code. Coroutines are also quite efficient at runtime. In addition, the use of Kotlin features allows us to provide a domain-specific language (DSL) — a concise and developer-friendly API for configuring your application with no magic, just code.

Of course, Ktor is not the only option for building server-side applications in Kotlin. We’re pleased to see that other frameworks such as Spring and Vert.x are providing first-class support for Kotlin, and using these frameworks is a great way to preserve your existing investment and experience. At the same time, Ktor offers unique advantages thanks to its use of coroutines and DSLs, which makes it a great option when you’re starting a new backend project or a microservice.

Ktor is already deployed in production in a number of projects running at scale. For example, HLTV.org serves about 200 million pageviews per month and about 3.1 billion pageviews in total on Ktor. The latest release of the ThoughtWorks Technology Radar lists Ktor in their Assess category.

What’s Included

The two main parts of Ktor are the HTTP server framework, running on the JVM, and the multiplatform HTTP client. As a JetBrains project, Ktor naturally comes with helpful tools to get you started with new projects quickly.

Server

The HTTP server part is built upon proven technologies like Netty, Jetty, and also Java servlets. When using lightweight engines like Netty or Jetty, it starts ultrafast and is ready to receive connections in under a second. It is compatible with the 12 Factors paradigm, is container-friendly, and can easily be embedded into desktop (or even Android) applications. You can also run it in an application server such as Tomcat.

Ktor provides a rich and easy-to-use extensibility mechanism, on top of which most of the built-in functionality is implemented. Third-party features look no different from the built-in ones. Out of the box, Ktor includes all the essential features like sessions, authentication, JSON serialization, popular template engines, Web sockets, metrics, and many others. It also supports a productive development workflow, with a fast start, automatic reloading, and easy-to-use facilities for writing unit and integration tests.

Client

The client part is asynchronous as well, built using the same coroutines and IO primitives that drive the server. This makes it perfect for building asynchronous microservice architectures, connecting all the backend functionality into asynchronous pipelines.

The client is implemented as a multiplatform library, which currently supports JVM, JS, Android, and iOS. This makes it possible to retrieve data on mobile devices and web pages in a uniform way, without blocking application execution or building complex chains of anonymous functions to handle successes or failures.

Tools

Last but not least, the tools let you select the features you need and get a fully working starter app with Ktor. This works both on the Web and via a plugin for IntelliJ IDEA.

Like all other Kotlin libraries, Ktor is free and open-source, developed on GitHub and released under the Apache 2 license.

Getting Started

The Hello World of Ktor is small enough to fit in a tweet:

To go beyond that, the website provides a Quickstart guide, extensive documentation for writing servers and clients, and many sample projects. If you prefer videos, Ryan Harter’s KotlinConf 2018 talk is a great introduction to using Ktor on the backend.

Hop over to https://start.ktor.io/ to get a project template, check out the docs, and your new backend will be up and running in no time! If you need help, the friendly folks on the #ktor channel on Kotlin Slack are there for you.

Have a nice Ktor!

This entry was posted in JavaScript, Releases, Server and tagged . Bookmark the permalink.

13 Responses to Ktor 1.0 Released: A Connected Applications Framework by JetBrains

  1. Thank you for Ktor. It is percect

  2. Nick says:

    Are there plans for Ktor to target Serverless (via Kotlin Native) in the near future?

  3. Pingback: Ktor 1.0 正式发布:JetBrains 出品的互联应用框架 - Kotlin Blog

  4. Pankaj Rai says:

    Why not to build a networking library fot mobile like Retrofit which can auto parse response but also to have a functionality to give raw response also so that when auto parse is not required still that will work.

    Can kotr be that replacement?

  5. Donny says:

    Hi Guys,
    Any plan to support bean validation?

    Thanks for Ktor!!

  6. Ryan R says:

    Neat! Can this be used alongside Flask, or is this a complete replacement?

  7. Pingback: Интересные материалы для Android-разработчика #145 - Подкасты Android Dev

  8. Pingback: Ktor 1.0 Released: A Connected Applications Framework by JetBrains | Kotlin Blog – Notes de Francis

  9. Pingback: Ktor – Kotlin based framework | has many :code_blocks

  10. Pingback: Ktor 1.0 ist erschienen: Eigene DSL zum Konfigurieren

  11. Finally there is a Web framework that doesn’t make me feel dumber that I am!
    I suggest you to advertise more the little feature described in Ktor issue 508 ( https://github.com/ktorio/ktor/issues/508 ): thanks to Coroutines Ktor automatically handles backpressure so Ktor implicitely enforces a reactive contract without the need for libraries like Project Reactor + Reactor-Netty. This is awesome.

  12. Pingback: Дайджест интересных материалов для мобильного разработчика #276 (19 — 25 ноября) — MAILSGUN.RU

Leave a Reply

Your email address will not be published. Required fields are marked *