LinuxCommandLibrary

ktor

CLI for Ktor, a Kotlin framework for building asynchronous servers

TLDR

Create a new project (interactive)

$ ktor new
copy
Create with specific plugins
$ ktor new --plugins [routing,content-negotiation,ktor-serialization]
copy
Create with custom name
$ ktor new --name [myapp]
copy
Generate with Gradle Kotlin DSL
$ ktor new --build-system gradle-kotlin
copy
List available plugins
$ ktor plugins list
copy
Search for plugins
$ ktor plugins search [auth]
copy
Show version
$ ktor --version
copy

SYNOPSIS

ktor command [options]

DESCRIPTION

ktor is the CLI for Ktor, a Kotlin framework for building asynchronous servers and clients. It scaffolds new projects with selected features.
ktor new generates a project with build files, application configuration, and plugin setup. Plugins add functionality like authentication, serialization, and WebSockets.
Ktor applications configure features in Application.kt using DSL. Plugins are installed in modules: install(ContentNegotiation), install(Authentication), etc.
The framework runs on multiple engines: Netty, Jetty, Tomcat, or CIO (Kotlin coroutines). Choose based on requirements—Netty is default for production.
Configuration via HOCON (application.conf) or YAML specifies ports, hosts, and plugin settings. Environment variables override configuration values.

COMMANDS

new

Create new Ktor project.
plugins list|search
Browse available plugins.
--version
Display CLI version.
--help
Display help information.

NEW OPTIONS

--name name

Project name.
--package package
Base package name.
--plugins list
Comma-separated plugin list.
--build-system type
Build system: gradle-kotlin, gradle-groovy, maven.
--engine engine
Server engine: netty, jetty, tomcat, cio.
--configuration type
Configuration method: hocon, yaml.
--ktor-version version
Ktor version.
--kotlin-version version
Kotlin version.
--output path
Output directory.
--interactive
Interactive mode.

PLUGINS

routing

HTTP routing.
content-negotiation
Content type negotiation.
ktor-serialization-kotlinx-json
JSON serialization.
auth, auth-jwt
Authentication support.
call-logging
Request logging.
websockets
WebSocket support.
cors
Cross-origin resource sharing.
sessions
Session management.
status-pages
Error handling.

CAVEATS

Requires Kotlin knowledge. Plugin compatibility may vary across Ktor versions. CIO engine has limited features compared to Netty. Some plugins require additional configuration.

HISTORY

Ktor was created by JetBrains and first released in 2017. It was designed as a native Kotlin framework leveraging coroutines for asynchronous programming. Unlike Spring, Ktor is lightweight with explicit configuration. Version 2.0 (2022) brought significant API changes. Ktor is popular for microservices and API development in Kotlin projects.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community