native middleware client developer-experience OCaml Server HTTP
Need help with httpkit?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.


⚡️ High-level, High-performance HTTP(S) Clients/Servers in Reason/OCaml

198 Stars 9 Forks 126 Commits 7 Opened issues

Services available

Need anything else?

⚡️HttpKit — high-level, high-performance HTTP1.1/2 clients/servers in Reason

NOTE: under heavy reconstruction. Latest stable version was


HttpKit is a high-level library for building and consuming web servers over HTTP, HTTPS, and HTTP2.

It serves as a thin layer over

, and when it can it allows you to seamlessly transition from one to the other.
  1. Roadmap
  2. Getting Started
  3. Running the Examples


| Feature | HTTP/1.1 | HTTPS/1.1 | HTTP/2 | HTTPS/2 | |------------------|----------|-----------|--------|---------| | Listen as Server | Yes | No | Yes | No | | Send Request | Yes | Yes | No | No | | Server Push | - | - | No | No | | | | | | |

Getting Started


can be used both to build servers and to make requests as a client.

Documentation is still a work-in-progress, but there's examples in the

section that can give you a better idea of how to use the libraries. In short:

For making a request:

open Lwt_result.Infix;

module Httpkit = Httpkit_lwt_unix_httpaf;

let req = Httpkit.Request.create( ~headers=[("User-Agent", "Reason HttpKit")], `GET, Uri.of_string(""), );

/* Send over HTTP */ req |> Httpkit.Client.Http.send >>= Httpkit.Client.Response.body |>

/* Send over HTTPS */ req |> Httpkit.Client.Https.send >>= Httpkit.Client.Response.body |>

For making a server:

module Httpkit = Httpkit_lwt_unix_httpaf;

let port = 8080;

let on_start = (~hoststring) => => m("Running on %s", hoststring));

let handler: Httpkit.Server.handler = (req, reply, kill_server) => { let method = req |> Httpkit.Request.meth |> H2.Method.to_string; let path = req |> Httpkit.Request.path; => m("%s %s", method, path)); reply(200, "hi"); kill_server(); };

/* Start server over HTTP */ Httpkit.Server.Http.listen(~port, ~address=`Any, ~handler, ~on_start) |>;

/* Start server over HTTPS */ Httpkit.Server.Http.listen(~port, ~address=`Any, ~handler, ~on_start) |>;

Installing with esy

You can install by dropping the following dependencies in your

  "dependencies": {
    "@opam/httpkit": "*",
    "@opam/httpkit-lwt-unix-httpaf": "*",
    "@opam/logs": "*",
    "@opam/fmt": "*",
    // ...
  "resolutions": {
    "@opam/httpkit": "ostera/httpkit:httpkit.opam#f738417",
    "@opam/httpkit-lwt-unix-httpaf": "ostera/httpkit:httpkit-lwt-unix-httpaf.opam#f738417",


make sure you're using the latest commit hash!

Running the Examples

All of the examples are runnable as binaries after compilation, so you can either run

esy build
and find them within
or you can ask dune to run them for you:
ostera/httpkit λ esy dune exec ./examples/Request.exe

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.