r/ktor • • Apr 20 '23

🎉 Ktor 2.3.0 has arrived

13 Upvotes

It provides:

  • Regular expression support in routing

  • Static content API cleanup

  • Support for `100 Continue`

  • Static linking of the libcurl library for mingwx64

and other features.

You can learn more in our blog post 👉 https://blog.jetbrains.com/ktor/2023/04/18/ktor-2-3-0-released/


r/ktor • • Jan 31 '26

Ktor 3.4.0 Is Now Available

Thumbnail
blog.jetbrains.com
8 Upvotes

r/ktor • • Jul 05 '21

Best practice Ktor project structure in bigger services

8 Upvotes

Hello,

me and my team are currently working with spring boot 2.5 + reactor stuff + kotlin and I try to migrate one of our services to ktor.
It has to support:

  • deployability on k8s, needs to have a health check route

  • graceful shutdown (min the http routes, best case also kafka consumer / streams)

  • prometheus metrics

  • errors to sentry

  • logback for kibana stack

  • custom authentication behaviour

for most of that we already discovered something for ktor or will be able to assemble it real quick.
The main problem for me is that ktor is very easy from the start, so nearly every video there is on yt is about the first 30min, before your code gets messy and big and you really need to think about a good structure, how to divide in packages ...

Right now in spring, with annotations, that's really easy, everything gets scanned and put into the application context, but we don't want that anymore, it has to be more lightweight. Also in my former company we used Scala with akka http + akka streams and hadn't had DI at all, and we still managed to build good structured applications that were testable and readable, so there must be a way...

I would like to ask you if you have bigger projects in ktor?
What did you do when you went from small to big, was there a key feature of that language that helped you? I assume it might be the extension function because ktor seems to be based around that
Were there any needed crucial dependencies that helped you or did you do it without DI?


r/ktor • • May 31 '21

Ktor 1.6.0 Released

Thumbnail
blog.jetbrains.com
8 Upvotes

r/ktor • • Dec 13 '22

Ktor 2.2.1 (and 2.2.0) released

7 Upvotes

It brings OpenAPI documentation generation, a new API for creating custom client plugins, the new Rate Limiting plugin, the Protobuf serializer, and more.

Go to the blog post for the full overview: https://blog.jetbrains.com/ktor/2022/12/08/ktor-2-2-0-released/

Share your thoughts about the new release!


r/ktor • • Jul 21 '21

Swagger/OpenApi Documentation in ktor

7 Upvotes

hi, guys, someone knows how create a api documentation of a ktor application using openapi-generator? Thanks for you help


r/ktor • • Nov 09 '23

Ktor Server Task Scheduling plugin

6 Upvotes

I just added a server task scheduling plugin to my Extra Ktor Plugins project

This new plugin is designed to bring enterprise-level task scheduling capabilities to Ktor, offering seamless coordination of scheduled tasks across distributed server instances. It's inspired by the functionality of Spring Boot's ShedLock but tailored for the Ktor framework, with out-of-the-box support for Redis, JDBC, and MongoDB, and can be easily extendable to acommodate other use cases

As always, feedback and contributions are welcome and appreciated 😊


r/ktor • • Jul 02 '23

Ktor + Koin + Exposed template

6 Upvotes

Hello,

These days I'm creating an template with mentioned stack on GitHub.

I thought this might be a good place to share, if someone would like to take an inspiration:

https://github.com/tkrason/ktor-koin-template


r/ktor • • Dec 19 '22

Ktor 2023 Roadmap

6 Upvotes

Hi!

We have updated our roadmap for 2023. Check out this blog post describing the main areas of focus for the upcoming year: https://blog.jetbrains.com/ktor/2022/12/16/ktor-2023-roadmap/


r/ktor • • May 04 '25

Best way to implement admin-only routes

5 Upvotes

I want to add routes only admins can access, to build an admin web interface. I thought the easiest way would be to have routes that only allow requests from localhost, maybe even on a different port than the public REST API, so only admins using a SSH tunnel for example could access them.

What are other ways to implement admin-only routes? Maybe using one of the authentication methods provided by Ktor?


r/ktor • • Mar 19 '24

The Ktor Roadmap for 2024

5 Upvotes

Hi! Check out our latest blog post to learn about Ktor's plans for 2024, including the update on DI support: https://blog.jetbrains.com/kotlin/2024/03/the-ktor-roadmap-for-2024/


r/ktor • • Feb 01 '24

Ktor 2.3.8 has been released

5 Upvotes

Hi! The new Ktor has arrived. Check out the changelog: https://ktor.io/changelog/2.3/


r/ktor • • Mar 15 '23

GitHub - mjovanc/awesome-ktor: A curated list of awesome books, tutorials, courses, and resources for the Ktor framework ecosystem ⚡

Thumbnail
github.com
5 Upvotes

r/ktor • • Feb 28 '23

🎉 Ktor 2.2.4 is here!

5 Upvotes

Check out the changelog for the full list of updates: https://ktor.io/changelog/2.2/#version-2-2-4.


r/ktor • • Feb 23 '23

What do you use to generate openapi documentation?

5 Upvotes

I use IntelliJ generator via endpoints, but noticed that it doesn't recognize payloads.

For example:

val payload = call.receive<Foo>()

Doesn't generate the documentation, while `call.respond(Foo())` is recognized.

Found this https://github.com/SMILEY4/ktor-swagger-ui, looks promising. Is anyone using this lib? Do you use something else and can recommend it?


r/ktor • • Nov 24 '22

Ktor vs Node.js, Django, Go etc..

5 Upvotes

What are the pros and cons of ktor, as compared to servers built using Node.js, Django, Go, and other performant sever side frameworks?

In terms of speed, scalability, number of lines of code to be written etc..

Looking for answers from devs with good knowledge and experience in server side development using multiple frameworks.


r/ktor • • Dec 19 '21

Use Ktor websockets to create chatting application (with source code)

5 Upvotes

See Source on github


r/ktor • • Nov 09 '21

Local Ktor documentation

5 Upvotes

I'm looking ktor 2.0 migration documentation, but could not find the link to read the doc for this EAP version. So i tried cloning the doc, but i don't know how to run it locally.

Any HowTo to run the doc locally, or link to online doc for 2.0 version would be best.

Thank you.

EDIT:
They just announced it

https://twitter.com/JetBrainsKtor/status/1459147914345959433

Here is the link

https://ktor.io/docs/eap/welcome.html


r/ktor • • Aug 06 '21

how to optimize netty settings in ktor?

5 Upvotes

Hi fellows, i am work with ktor and netty as server, and after run a load test we discover that the aplication is losting requests, we realized that the configuration parameter the Netty is not otimized. I would ask if you guys can help me figuring out how to optimize netty settings in ktor. Thanks a lot for the help


r/ktor • • Jul 25 '25

trying to use ktor but getting errors about duplicate classes

4 Upvotes

I started a project in react native and needed to use a websocket server. After looking for a while I couldn't find a solution for this in react-native and decided to write my own module in native kotlin code. I started with this code

package com.nullrequest.foxcam_websocket

import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
import java.net.URL
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.request.*
import io.ktor.server.routing.*
import io.ktor.server.websocket.*
import kotlinx.coroutines.*

class FoxcamWebsocketModule : Module() {
  private var server: EmbeddedServer<NettyApplicationEngine, NettyApplicationEngine.Configuration>? = null;
  private var serverPort: Int = 8080;
  // Each module class must implement the definition function. The definition consists of components
  // that describes the module's functionality and behavior.
  // See https://docs.expo.dev/modules/module-api for more details about available components.
  override fun definition() = ModuleDefinition {
    // Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
    // Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
    // The module will be accessible from `requireNativeModule('FoxcamWebsocket')` in JavaScript.
    Name("FoxcamWebsocket")
    // Defines event names that the module can send to JavaScript.
    Events("onChange")

    AsyncFunction("startServer") { port: Int ->
      serverPort = port
      startHttpServer()
      "Server started on port $serverPort"
    }

    AsyncFunction("stopServer") {
      stopHttpServer()
      "Server stopped"
    }


    // Enables the module to be used as a native view. Definition components that are accepted as part of
    // the view definition: Prop, Events.
    View(FoxcamWebsocketView::class) {
      // Defines a setter for the `url` prop.
      Prop("url") { view: FoxcamWebsocketView, url: URL ->
        view.webView.loadUrl(url.toString())
      }
      // Defines an event that the view can send to JavaScript.
      Events("onLoad")
    }

    OnDestroy {
      stopHttpServer()
    }
  }

  private fun startHttpServer() {
    if (server!=null) return
    server = embeddedServer(Netty, host="0.0.0.0", port = serverPort) {
      install(WebSockets)

      routing {
        get("/") {
          call.respondText("Foxcam HTTP Server is running on port $serverPort")
        }

        get("/hello") {
          val name = call.request.queryParameters["name"] ?: "Guest"
          call.respondText("Hello, $name!")
        }
      }
    }.start(wait = false)
  }


  private fun stopHttpServer() {
    server?.stop(gracePeriodMillis = 1000, timeoutMillis = 2000)
    server = null
  }
}

(if this is a horrible way of doing things please feel free to yell at me i've never used kotlin before). I tried building this and got errors about various classes from io.netty having duplicate classes, an example of the error is

Duplicate class io.netty.bootstrap.AbstractBootstrap found in modules netty-all-4.1.48.Final.jar -> netty-all-4.1.48.Final (io.netty:netty-all:4.1.48.Final) and netty-transport-4.2.2.Final.jar -> netty-transport-4.2.2.Final (io.netty:netty-transport:4.2.2.Final)
Duplicate class io.netty.bootstrap.AbstractBootstrap$1 found in modules netty-all-4.1.48.Final.jar -> netty-all-4.1.48.Final (io.netty:netty-all:4.1.48.Final) and netty-transport-4.2.2.Final.jar -> netty-transport-4.2.2.Final (io.netty:netty-transport:4.2.2.Final)

I don't know enough about kotlin or gradle to fix these errors so pointers would be appricated


r/ktor • • Jul 24 '25

Seamless Android File Sharing Using Ktor Client/Server in Kotlin

4 Upvotes

Hi everyone 👋,

I recently worked on a Kotlin-based Android project that allows offline file transfer between two devices using a Ktor client-server setup and QR code-based pairing. Thought it would be relevant to share it here for feedback and to showcase Kotlin’s versatility—even for peer-to-peer communication use cases.

⚙️ How It Works

Both users install the same Kotlin Android app.

User A (Sender) selects photos/videos → Long press triggers QR generation with connection metadata.

User B (Receiver) scans the QR code → App opens camera → Connects to sender via embedded Ktor server → Starts secure file download.

Entire exchange runs offline on a local network (e.g., hotspot or Wi-Fi Direct).

💡 Why Kotlin + Ktor?

I wanted a clean, maintainable, coroutine-backed HTTP layer, and Ktor's embedded Netty server worked great for that. The entire logic is built in pure Kotlin, from the file provider logic to coroutine-based byte streaming.

📖 Full Write-Up & Demo

👉 Medium Post – Seamless Data Exchange Between Android Apps Using Ktor

Includes:

Architecture overview

GIF demo of real usage

Code structure using Kotlin coroutines

File server/client logic using Ktor

QR generation/scanning with ZXing

🧠 Looking for Suggestions

Would love your thoughts on:

Optimizing Ktor server lifecycle in Android

Handling large files efficiently with Kotlin coroutines

Making the architecture more modular (KMM friendly maybe?)

This is my first public Kotlin project post—any encouragement, critique, or improvement ideas are welcome 🙏


r/ktor • • May 12 '25

Is this a valid tech stack for my backend? (Kotlin, Ktor, Exposed, Google Cloud, Firebase Auth, Firebase App Check)

4 Upvotes

I have an existing Android app which I'd like to enhance by implementing a custom backend which is composed of a relational database and user authentication based on Firebase Auth. The business domain model might be something like a recipe app with data such as the sample below. It is not set in stone and just serves as a placeholder for my domain.

{
   "name":"Cheesecake",
   "ingredients":[
      {
         "name":"Banana",
         "amount":150,
         "unit":"grams"
      }
   ]
}

I especially need FTS capabilities so that I can query based on, let's say, the recipe's name. I'm pretty fluent in Kotlin and familiar with SQL.

The tech stack I was thinking about is this:

  • Ktor (backend framework)

  • Exposed (ORM)

  • MySQL (relational database)

Infrastructure:

I'm an experienced Android developer but I'm having practically no backend development experience which is why I don't want to implement authentication myself at this stage.

However I want to secure my backend and since my app integrates Firebase Auth, I'd like to use OpenAPI 2.0 security scheme in API Gateway to secure my backend from unauthorized users.

At the same time I want to secure my backend from unauthorized clients by using Firebase App Check JWT authentication in API Gateway.

What are your thoughts on this? Did I miss something?


r/ktor • • Oct 31 '24

Log4k: Logging and Tracing platform for Kotlin Multiplatform

4 Upvotes

Hello!
Recently I was working on small logging/tracing library. It's compatible with OpenTelemetry standard and also supports the OpenMetric standard for collecting and publishing metrics. Take a look here:
https://github.com/smyrgeorge/log4k


r/ktor • • Sep 17 '24

📢 Ktor Annual Survey is here!

4 Upvotes

Hi everyone! We’d love to get your insights on how we can improve Ktor. It’ll only take a few minutes to complete the survey, and your feedback would mean a lot to us!

➡️ https://surveys.jetbrains.com/s3/ktor-research-reddit


r/ktor • • Sep 16 '24

new to ktor

4 Upvotes

Hi everyone,

I am new to ktor and i want to build Restful api from it.

Can anyone just tell me what should be my approach and from where i can learn the basics to build custom api for the native android app.

Thanks..