Skip to main content

trillium

Composition as Configuration

Trillium is a modular async Rust web toolkit. The components you choose and how you arrange them are your configuration. Add what you need, publish what you build, swap what you outgrow.

use trillium::{Conn, Handler};
use trillium_logger::Logger;
use trillium_router::Router;

fn app() -> impl Handler {
(
Logger::new(),
Router::new()
.get("/", "hello world")
.get("/greet/:name", |conn: Conn| async move {
let name = conn.param("name").unwrap_or("stranger");
conn.ok(format!("hello, {name}!"))
}),
)
}

fn main() {
trillium_tokio::run(app());
}

Thoughtful Abstraction

A Conn carries request, response, and state as a single object through your entire stack. Every component — logger, router, auth gate, endpoint — is a Handler that transforms it. One abstraction, no special cases, no impedance between layers.

HTTP/3

HTTP/3 over QUIC alongside HTTP/1.x — add a crate and two lines of config, and existing handlers run unchanged across protocols. WebTransport, for bidirectional browser communication over HTTP/3, is included.

Runtime and TLS Independent

Choose tokio, smol, async-std, or AWS Lambda — swap with one import. TLS (rustls or native-tls) is equally orthogonal. Infrastructure choices live at the application boundary, invisible to handler code.

Opt-in Composable Ecosystem

Router, API layer, sessions, WebSockets, channels, SSE, static files, compression, templates, reverse proxy — all independent crates that compose the same way. Add what you need; nothing else compiles.

Matching HTTP Client

A full async HTTP client: runtime-agnostic, TLS-independent, and protocol-forward. Upgrades to HTTP/3 automatically via Alt-Svc, supports WebSocket upgrades, and shares your server's runtime without friction.

Integration Testing Framework

trillium-testing exercises the full HTTP stack without binding a port. Test any handler — a single component or the full application — with a fluent assertion API.

Ecosystem

Routing & API

  • Router Pattern-based routing with named params and wildcards
  • API Extractor-based handlers with JSON in and out

Observability

Auth, Cookies & Sessions

  • Basic Auth HTTP Basic Authentication
  • Cookies Parse and set cookies
  • Sessions Server-side sessions with pluggable stores

Content

Real-time

  • Server-Sent Events Lightweight server-to-client event streams
  • WebSockets Full-duplex connections with original request context
  • Channels Phoenix-style topic pub/sub over WebSocket
  • WebTransport Multiplexed streams and datagrams over HTTP/3

Client & Proxy

  • HTTP Client Async HTTP/1.1 and HTTP/3 client with connection pooling
  • Reverse Proxy Forward requests to upstream servers
  • HTML Rewriter Inject or modify content as it streams through a proxy

TLS

  • Rustls TLS via rustls
  • Native TLS TLS via native-tls
  • ACME Automatic certificate provisioning via Let's Encrypt
  • Quinn HTTP/3 over QUIC

Runtimes

  • Tokio Tokio runtime adapter
  • Smol Smol runtime adapter — lightweight and fast
  • async-std async-std runtime adapter
  • AWS Lambda Lambda adapter — TLS handled by the load balancer

Testing

  • Testing Full HTTP stack exercised without binding a port — fluent assertions, any handler in isolation

Any Handler composes. Build and publish your own.

Trillium 1.0

Trillium takes semver seriously. Breaking changes are deliberate and infrequent. The release of 1.0 reflects a commitment to the current API shape and a considered approach to how and when it evolves from here. There's an extensive roadmap for further trillium features, but breaking changes should be extremely rare.

Trillium is actively developed and available for commercial support and consulting. If your organization is building on trillium and would benefit from professional support, architecture review, or custom development, I'd love to hear from you.