
¶
The Eio-native web framework for modern OCaml.
Fast, ergonomic and RFC-strict. Simple to start, ready for production.
open Spindle.Syntax
type greeting = { text : string } [@@deriving wiretype]
let hello name = Ok { text = "Hello, " ^ name ^ "!" }
let name = Spindle.Path.str "name"
let routes =
[
Spindle.get
Spindle.Path.(s "hello" / name)
(Spindle.Returns.json greeting_json)
(let+ name = Spindle.param name in
hello name);
]
let () =
Spindle.Log.setup ();
Eio_main.run @@ fun env ->
Spindle.serve env (routes @ Spindle.Openapi.docs routes)
-
Beautiful and idiomatic
Routes are values, inputs are typed, errors are values. Code that reads like OCaml, because it is.
-
Performant
Its own HTTP engine and every CPU core from the first request, with no tuning.
-
Eio-native
Built on OCaml 5 effects. Straight-line handlers: no promises, no monads, no callbacks.
-
OpenAPI docs via Scalar, out of the box
Interactive docs at
/docs, generated from your routes and never out of date. -
Front end in sync
Your OCaml types become your front end’s schemas, Zod included, in one command. Change a type and both ends change with it.
-
Typed end to end
JSON derived from your types and validated on the way in, with every mistake reported at once.
-
Battle-tested
Every HTTP requirement it meets is backed by a test. Secure defaults, bounded waits, clean shutdowns.
-
Postgres included
Typed queries, a pool and transactions, on a driver written in OCaml.
-
Batteries included
WebSockets, live updates, sessions, logging, traces, metrics, and tests that need no server.