Static Web

Server-rendered HTML templates, flash sessions, web resources with cache busting, and Semantic UI integration.

Templates

Kotlinx HTML-based templates with placeholder support. Define a layout once, fill placeholders per page.

class MyTemplate : SimpleTemplateBase() {
    val content = placeholder<FlowContent>()

    override fun FlowContent.apply() {
        head { /* styles, scripts */ }
        body {
            div("ui container") {
                insert(content)
            }
        }
    }
}

Virtual host routing

Serve different apps on different subdomains from the same server. Each host gets its own Kontainer scope, routes, and static assets.

routing {
    // API on api.*
    host("api.*".toRegex()) {
        installApiKontainer(app, config.api.insights)
        init.get(ApiApp::class).apply { mountApiAppModule() }
    }

    // Admin panel on admin.*
    host("admin.*".toRegex()) {
        installWwwKontainer(app, config.api.insights)
        staticResources(remotePath = "assets", basePackage = "assets")

        init.use(InsightsGui::class) { mount() }
    }
}

Flash sessions

One-time messages that survive a redirect. Set a message, redirect, and the message appears on the next page load then disappears.

// Set a flash message before redirecting
call.flashSession.success("User created successfully")
call.flashSession.warning("Email not verified")

// On the next page, pull messages (clears them)
val messages = call.flashSession.pull()

Web resources

Manage CSS and JavaScript bundles with automatic cache busting via content hashing. Subresource integrity (SRI) hashes are computed automatically. Reference resources in templates and the correct versioned URL is generated.

Cache busting means browsers always fetch the latest version after a deploy, while caching indefinitely otherwise. No more "clear your cache" instructions.

PrismJS integration

Built-in support for PrismJS syntax highlighting in server-rendered pages. Useful for documentation sites or admin panels that display code.