Authentication & sessions
Sessions, CSRF protection, login flows, API tokens and rate limiting are added to the request pipeline as composable steps. The pipeline definition shows which steps apply to each route.
OCaml 5 · Eio · effects
araara is a web framework for OCaml 5. It provides logins and sessions, a database layer, type-safe HTML, real-time updates, background jobs and clustering, and it documents how these parts are combined in an application.
(* A small araara service with a single route, a typed view and a server.
Run with: dune exec examples/hcs_hello/main.exe *)
let hello_page =
let open Tyxml.Html in
html
(head (title (txt "Hello from araara")) [])
(body [ h1 [ txt "Hello, araara!" ] ])
let hello _params _req =
Hcs.Server.respond_html (Format.asprintf "%a" (Tyxml.Html.pp ()) hello_page)
let () =
Eio_main.run @@ fun env ->
Eio.Switch.run @@ fun sw ->
let routes =
Hcs.Router.(compile_scopes [ scope "/" [ Route.get "/" hello ] ])
in
let handler =
Hcs.Endpoint.(
create default_config |> Fun.flip router routes |> to_handler)
in
Hcs.Server.run ~sw
~net:(Eio.Stdenv.net env)
~clock:(Eio.Stdenv.clock env)
handlerFeatures
The features below cover common parts of a web application, including authentication, data storage, HTML rendering and background work. They are documented as parts of one stack.
Sessions, CSRF protection, login flows, API tokens and rate limiting are added to the request pipeline as composable steps. The pipeline definition shows which steps apply to each route.
Typed schemas and a query builder composed in OCaml are provided through repodb. Input is checked before it reaches the database, and the same model definitions can be used with Postgres, SQLite and MySQL.
Pages are rendered as OCaml functions. Output is escaped by default, and htmx attributes are available without a separate template language or build step.
A live document can be shared between the server and the browser. JSON CRDTs merge concurrent edits, and the wire format matches json-joy, so an OCaml backend can exchange updates with a JavaScript client.
Slow work can run in supervised background workers, with typed mailboxes, schedulers and one-off tasks. The same worker code can also run across a cluster of machines.
Pages can be updated by swapping in server-rendered HTML with htmx, and changes can be pushed over Server-Sent Events. A JSON API endpoint can be added for a web action using the same underlying logic.
Request bodies are decoded into typed OCaml values and responses are encoded with simdjsont. A zero-copy path is available for endpoints that need it.
The server, migrations, CLI and background workers compile to a single native binary. It can be deployed in a Docker image, as this site is, or wrapped as a desktop app.
Performance
The benchmarks page reports measurements for hcs, araara's HTTP layer, alongside the four highest-ranked standard-mode servers of the HttpArena board, written in Go, C++ and Zig, on the same machine and under the same load. The tests include HTTP/2, gRPC, WebSocket echo and static files. They are narrow synthetic tests of server behaviour, and they do not predict how a particular application will perform under its own traffic.
Conventions
Features follow the same path through the same layers: model, context, controller or API, view and router. Corresponding code therefore appears in corresponding modules in each feature, and OCaml types catch some mistakes at compile time.
Examples
A clustered trading-floor demo: two visible browser clients connect to different nodes while one thousand simulated traders place buy and sell orders, post chat messages, and drive realtime dashboard, portfolio and leaderboard updates over one multiplexed WebSocket per client. The trading book and chat log converge across the cluster with hive replicated state.
Read the source1000 simulated traders
A complete araara application from the docs: login, roles, typed routes, SQLite models, server-rendered HTML, htmx form updates and an operator queue that receives new tickets over Server-Sent Events.
Read the walkthroughSSE + htmx

An email client with an inbox, a screener for unknown senders and full-text search. Its JSON API uses the same service layer as the HTML UI, and the web, CLI and desktop builds come from one OCaml codebase.
Read the sourcedocker pull qswarm/ahoj:latest

A multiplayer snake game on a hive cluster. Each node runs the same code and simulates the snakes joined through it. Nodes compete for singleton roles such as the food spawner and the AI seats, which run on one node and move when cluster membership changes.
Thank you
araara depends on libraries written by members of the OCaml community. The acknowledgements page lists those libraries and their authors.