javalin alternatives and similar libraries
Based on the "Web" category.
Alternatively, view javalin alternatives based on common mentions on social networks and blogs.
-
apollo-android
:rocket: A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform. -
http4k
The Functional toolkit for Kotlin HTTP applications. http4k provides a simple and uniform way to serve, consume, and test HTTP services. -
skrape.it
A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion. -
hexagon
Hexagon is a microservices toolkit written in Kotlin. Its purpose is to ease the building of services (Web applications or APIs) that run inside a cloud platform. -
firefly
Firefly is an asynchronous web framework for rapid development of high-performance web application. -
tekniq
A framework designed around Kotlin providing Restful HTTP Client, JDBC DSL, Loading Cache, Configurations, Validations, and more -
Pellet
An opinionated, Kotlin-first web framework that helps you write fast, concise, and correct backend services 🚀. -
bootique-kotlin
DISCONTINUED. RETIRED. Provides extension functions and features for smooth development with Bootique and Kotlin. -
Zeko-RestApi
Asynchronous web framework for Kotlin. Create REST APIs in Kotlin easily with automatic Swagger/OpenAPI doc generation -
komock
KoMock - Simple HTTP/Consul/SpringConfig http server framework written in Kotlin. Wiremock use cases -
voyager-server-spring-boot-starter
Easily create REST endpoints with permissions (access control level) and hooks includeded
SaaSHub - Software Alternatives and Reviews
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of javalin or a related project?
Popular Comparisons
README
Javalin - A simple web framework for Java and Kotlin
Javalin is a very lightweight web framework for Kotlin and Java which supports WebSockets, HTTP2 and async requests. Javalin’s main goals are simplicity, a great developer experience, and first class interoperability between Kotlin and Java.
Javalin is more of a library than a framework. Some key points:
- You don't need to extend anything
- There are no @Annotations
- There is no reflection
- There is no other magic; just code.
General information:
- :heart: Sponsor Javalin
- The project webpage is javalin.io (repo for webpage is at github.com/javalin/javalin.github.io).
- Documentation: javalin.io/documentation
- Chat on Discord: https://discord.gg/sgak4e5NKv
- Chat on Gitter: https://gitter.im/javalin-io/general
- Contributions are very welcome: CONTRIBUTING.md
- License summary: https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)
- Interesting issues: /tipsy/javalin/issues?q=label:INFO
Quickstart
Add dependency
Maven
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin</artifactId>
<version>4.1.0</version>
</dependency>
Gradle
implementation "io.javalin:javalin:4.1.0"
Start programming (Java)
import io.javalin.Javalin;
public class HelloWorld {
public static void main(String[] args) {
Javalin app = Javalin.create().start(7000);
app.get("/", ctx -> ctx.result("Hello World"));
}
}
Start programming (Kotlin)
import io.javalin.Javalin
fun main() {
val app = Javalin.create().start(7000)
app.get("/") { ctx -> ctx.result("Hello World") }
}
Examples
This section contains a few examples, mostly just extracted from the docs. All examples are in Kotlin, but you can find them in Java in the documentation (it's just syntax changes).
Api structure and server config
val app = Javalin.create { config ->
config.defaultContentType = "application/json"
config.autogenerateEtags = true
config.addStaticFiles("/public")
config.asyncRequestTimeout = 10_000L
config.dynamicGzip = true
config.enforceSsl = true
}.routes {
path("users") {
get(UserController::getAll)
post(UserController::create)
path(":user-id") {
get(UserController::getOne)
patch(UserController::update)
delete(UserController::delete)
}
ws("events", userController::webSocketEvents)
}
}.start(port)
WebSockets
app.ws("/websocket/:path") { ws ->
ws.onConnect { ctx -> println("Connected") }
ws.onMessage { ctx ->
val user = ctx.message<User>(); // convert from json string to object
ctx.send(user); // convert to json string and send back
}
ws.onClose { ctx -> println("Closed") }
ws.onError { ctx -> println("Errored") }
}
Filters and Mappers
app.before("/some-path/*") { ctx -> ... } // runs before requests to /some-path/*
app.before { ctx -> ... } // runs before all requests
app.after { ctx -> ... } // runs after all requests
app.exception(Exception.class) { e, ctx -> ... } // runs if uncaught Exception
app.error(404) { ctx -> ... } // runs if status is 404 (after all other handlers)
app.wsBefore("/some-path/*") { ws -> ... } // runs before ws events on /some-path/*
app.wsBefore { ws -> ... } // runs before all ws events
app.wsAfter { ws -> ... } // runs after all ws events
app.wsException(Exception.class) { e, ctx -> ... } // runs if uncaught Exception in ws handler
JSON-mapping
var todos = arrayOf(...)
app.get("/todos") { ctx -> // map array of Todos to json-string
ctx.json(todos)
}
app.put("/todos") { ctx -> // map request-body (json) to array of Todos
todos = ctx.body<Array<Todo>>()
ctx.status(204)
}
File uploads
app.post("/upload") { ctx ->
ctx.uploadedFiles("files").forEach { (contentType, content, name, extension) ->
FileUtil.streamToFile(content, "upload/$name")
}
}
OpenAPI (Swagger)
Javalin has an OpenAPI (Swagger) plugin. Documentation can be enabled both through a DSL and through annotations, and Javalin can render docs using both SwaggerUI and ReDoc. Read more at https://javalin.io/plugins/openapi.
Special thanks
- Blake Mizerany, for creating Sinatra
- Per Wendel, for creating Spark
- Christian Rasmussen, for being a great guy
- Per Kristian Kummermo, also for being a great guy
*Note that all licence references and agreements mentioned in the javalin README section above
are relevant to that project's source code only.