The Spindle documentation highlights its automatic generation of codecs, OpenAPI specs, and frontend schemas.
*Spindle offers a type‑driven, multicore web framework for OCaml 5. It auto‑generates codecs, OpenAPI specs and frontend schemas, promising tighter server‑client contracts and benchmarked speed gains over NestJS and FastAPI.*
Spindle has landed on GitHub as a full‑featured, type‑safe web framework for OCaml 5. Its creators market it as multicore‑by‑design and eio‑native, targeting developers who demand both safety and speed. The framework promises an expressive API that automatically derives codecs, request validation, OpenAPI specs, and frontend schemas for Zod and Melange, keeping server‑client contracts in lockstep. In a landscape where OCaml web tooling is sparse, Spindle’s bundled production features—RFC‑strict HTTP, WebSockets, SSE, distributed tracing, OT‑compatible metrics and logging—aim to close the gap. Benchmarks claim it outpaces NestJS by a factor of two and FastAPI by a factor of five on a single core, a striking figure for a language traditionally viewed as niche in web development.
Spindle is a multicore‑by‑design, eio‑native web framework built for modern OCaml. Its core premise is an expressive, type‑driven API that eliminates manual contract definitions. By deriving codecs, request validation, OpenAPI specifications and frontend schemas directly from OCaml types, Spindle reduces duplication and potential mismatches. The framework targets developers who need high‑level abstractions without sacrificing the safety guarantees of OCaml's type system. Its design reflects a shift toward tighter integration between server logic and client expectations, a rare focus in the OCaml ecosystem.
Spindle’s type‑driven API automatically derives request and response codecs, ensuring that data shapes remain consistent across the stack. It generates an OpenAPI specification from the same type definitions used on the server, removing the need for separate API documentation. For the client side, Spindle produces schemas compatible with Zod and Melange, allowing JavaScript and ReasonML frontends to validate data against the exact server contract. This single source of truth eliminates manual translation errors and streamlines full‑stack development.
Beyond core routing, Spindle includes an RFC‑strict HTTP server, composable dependency injection, WebSocket and Server‑Sent Events support, and high‑level primitives for building MCP servers. It also ships with production‑ready observability tools: distributed tracing, OpenTelemetry‑compatible metrics, and structured logging. These components match the expectations of enterprise deployments, letting teams adopt Spindle without stitching together a separate monitoring stack.
Speed was never the primary goal, yet benchmarks show Spindle running twice as fast as NestJS and five times faster than FastAPI on a single core. The multicore design and eio‑native I/O contribute to these gains, positioning Spindle as a high‑performance alternative for latency‑sensitive services written in OCaml.
Benchmarks show Spindle running twice as fast as NestJS on a single core.
Yes, its type‑driven API derives an OpenAPI spec from the same OCaml type definitions.
Spindle generates schemas for Zod and Melange, enabling client‑side validation that matches server contracts.
Spindle’s arrival could reshape how OCaml teams build web services, offering a unified, type‑driven stack that eliminates manual contract work while delivering measurable performance gains. If the community adopts its tooling and the benchmark claims hold under real‑world load, Spindle may become the de‑facto standard for high‑throughput OCaml backends. The next test will be production adoption beyond the GitHub showcase.
Sources: [Hacker News – Show HN: Spindle – a full-featured, type-safe web framework for OCaml 5]