1. Docs
  2. Start
Edit on GitHub[]to change page

Introduction

Lithe is a web UI library for Kotlin. A component is a single .lithe file where you write Kotlin, HTML and scoped CSS side by side, like a Svelte component. It compiles to plain Kotlin on a small reactive runtime. The page is rendered to HTML at build time, then Kotlin/JS hydrates it in the browser.

Lithe
<script kotlin>
	prop val step: Int = 1

	var count by state(0)
	val doubled by derived { count * 2 }
</script>

<button class="counter" @click={count += step}>{count} × 2 = {doubled}</button>

@if (count > 10) {
	<p>That's a lot of clicks. Everything okay at home?</p>
}

<style>
	.counter { padding: .5rem 1rem; }
</style>

And here it is, running live in the page:

Heads up, Lithe is experimental. 0.1.0 is on Maven Central, for a Gradle project like a Kobweb site, and you can also write an app as a module of the Lithe repository.

What it does

Feature Read more
HTML first. Every page is complete before any JavaScript runs, and only the components that can change hydrate, as islands. Static pages and islands
Fine-grained updates. A component runs once, and each dynamic part of the page follows the state it reads. No virtual DOM. State
Plain Kotlin. Props, state and handlers are Kotlin, with the typed DOM of kotlin-browser. A client only carries what its components use. Component files
A template language. Blocks such as @if, @for and @await, two-way bindings, <head> elements and scoped styles. Control flow, Bindings, Styles
Routing. var path by window.route() follows the URL, and links move without reloading through the Navigation API where the browser has it. Routing
Compose interop. Components and Compose HTML composables mount each other, and only the sites that use Compose ship it. Compose, Kobweb
Tooling. A dev server that rebuilds on save, and a language server with a VS Code extension and a plugin for IntelliJ IDEA. Dev server, Editors

Where to go next

Page What it covers
Getting started Run an example, then build an app of your own.
How it works From a .lithe file to HTML and JavaScript, and why it is built this way.
Component files The script, props and the parts of a file.
Static sites Building a site and what the build writes.
Compile errors and warnings Every message of the compiler, with its cause.
Build, dev server and runtime errors The messages of a site build, the dev server and a running app.
Optimizations The choices that keep the client small and fast, with their measured effect and what they ask of you.
Performance Sizes and times, against Svelte and Compose.