Is OCaml web yet?
Not quite yet, but we're getting there!
OCaml, traditionally known for its strength in systems programming, formal verification, and as the language of choice for numerous academic endeavors, is steadily maturing in the web development landscape. With its strong static typing, emphasis on immutability, and excellent performance, it is gradually making a case for itself as a viable alternative to mainstream web development languages.
If you're considering using OCaml for your next web application, you should be aware that you'll likely have to write a noticeable amount of things yourself and won't yet get an equivalent of some frameworks you may be used to coming from other languages. In particular, OCaml doesn't have out-of-the-box solutions for authentication or a fully production-ready query-builder. You'll also probably have some challenges if you need to interact with external services or external APIs.
Want to Help?
Here are some projects that would help make OCaml a stronger candidate for web applications:
- Improve ocaml-swagger to be able to generate API for popular web APIs like Stripe.
- Implement a converter from JSON Schema to ATD. This would allow generating OCaml serializers for data formats that provide a JSON Schema (a lot of them do!).
- Create an Oauth2 client library.
- Create clients to the Azure services APIs.
- 🔴 Authentication
- 🟡 Binary protocols
- 🟢 Browser
- 🟡 Compression
- 🟡 Cryptography
- 🟠 Database
- 🟠 En- & Decoding
- 🟠 Web Frameworks
- 🔴 HTTP Clients
- 🆘 Internationalization
- 🟠 Logging
- 🟡 Lower Web-Stack
- 🆘 Message Queues & Key-Value Stores
- 🟡 Serializers
- 🟡 Syndication/RSS
- 🟡 Templating
- 🟡 Static Site Generation
- 🆘 External Web APIs
- 🔴 WebAssembly
- 🟢 : stable, tested and mature
- 🟡 : getting there, stable but still maturing
- 🟠 : not yet stable, but progressing
- 🔴 : unstable/incomplete, needs work
- 🆘 : barely there, needs serious work
Packages for authentication-related functionality in OCaml web applications.
- jwt Implementation of JWT in OCaml.
- cookie Cookie handling for OCaml and ReasonML
- FPauth Easy authentication system for Dream framework
- u2f Universal Second Factor (U2F) implementation in OCaml
- webauthn WebAuthn - authenticating users to services using public key cryptography
- ssl Bindings for OpenSSL
- twostep HOTP and TOTP algorithms for 2-step verification (for OCaml)
- oidc Base package for working with OIDC
- spoke SPAKE+EE implementation in OCaml
There are implementations for a lot of popular protocols, some of them are solid, but some of them are still incomplete and need more testing. Some useful protocols for which there is no package include FlatBuffers and AMQP.
- asn1-combinators Embed typed ASN.1 grammars in OCaml
- avro Runtime library for encoding/decoding Avro
- capnp OCaml code generation plugin for the Cap'n Proto serialization framework
- grpc A modular gRPC library
- protobuf Protobuf implementation for Ocaml
- rpc A library to deal with RPCs in OCaml - meta-package
- jsonrpc Jsonrpc protocol implemenation
- thrift OCaml bindings for the Apache Thrift RPC system
- bson A bson data structure, including encoding/decoding
- cbor CBOR encoder/decoder (RFC 7049) - native OCaml implementation
- mqtt MQTT message parser in OCaml
- msgpck Fast MessagePack (http://msgpack.org) library
- melange Toolchain to produce JS from Reason/OCaml
- brr Browser programming toolkit for OCaml
- bonsai A library for building dynamic webapps, using Js_of_ocaml
- ocaml-vdom This is a transition package, ocaml-vdom is now named vdom. Use the vdom package instead
- fmlib_browser Write web applications for the browser in elm style
Packages that enable compression and decompression of data in OCaml web applications.
- zlib Bindings to the zlib compression library
- decompress Implementation of Zlib and GZip in OCaml
- camlzip Accessing compressed files in ZIP, GZIP and JAR format
- lz4 Bindings to the LZ4 compression algorithm
- ezgzip Simple gzip (de)compression library
- hpack An HPACK (Header Compression for HTTP/2) implementation in OCaml
- brotli Bindings to Google's Brotli compresion algorithm
- zstd Bindings to zstd compression library
- snappy Bindings to snappy - fast compression/decompression library
- lzo Bindings to LZO - a portable lossless data compression library
- zstandard OCaml bindings to Zstandard
- carton Implementation of PACKv2 file in OCaml
Packages for secure communication, encryption, hashing, and other cryptographic operations.
- cryptokit A library of cryptographic primitives
- mirage-crypto Simple symmetric cryptography for the modern age
- nocrypto Simpler crypto
- pkcs11 PKCS#11 OCaml types
- tls Transport Layer Security purely in OCaml
- x509 Public Key Infrastructure (RFC 5280, PKCS) purely in OCaml
- fiat-p256 Primitives for Elliptic Curve Cryptography taken from Fiat
- sha Binding to the SHA cryptographic functions
- blake2 Blake2 cryptography
- blake3 Blake3 cryptography
- bls12-381 Implementation of the BLS12-381 curve (wrapper for the Blst library)
- pbkdf Password based key derivation functions (PBKDF) from PKCS#5
- dirsp-proscript OCaml-ified interfaces for the ProScript Cryptography Library
- digestif Hashes implementations (SHA*, RIPEMD160, BLAKE2* and MD5)
Database-related packages for interacting with databases in OCaml web applications, from simple connectors to type-safe SQL wrappers.
- petrol Petrol's an OCaml SQL API made to go FAST
- caqti Unified interface to relational database libraries
- pgocaml Native OCaml interface to PostgreSQL databases
- sqlite3 SQLite3 bindings for OCaml
- lmdb Bindings for LMDB, a fast in-file database with ACID transactions
- irmin Irmin, a distributed database that follows the same design principles as Git
- mysql Bindings to C client library for interacting with Mysql/MariaDB/Percona databases
- postgresql Bindings to the PostgreSQL library
- aws-rds Amazon Web Services SDK bindings to Amazon Relational Database Service
- sequoia Type-safe query builder for OCaml
- sqlgg SQL Guided (code) Generator
- mariadb OCaml bindings for MariaDB
Packages for sending and managing email communications.
- tidy_email An OCaml library that simplifies connecting to email services
- emile Parser of email address according RFC822
- smtp SMTP library with Unix and Lwt backends
- letters Client library for sending emails over SMTP
- mrmime Mr. MIME
- sendmail Implementation of the sendmail command
- received Received field according RFC5321
- email_message E-mail message parser
- colombe SMTP protocol in OCaml
- dkim Implementation of DKIM in OCaml
- uspf SPF implementation in OCaml
Encoding and decoding various data formats.
- tar Decode and encode tar format files in pure OCaml
- imagelib Library implementing parsing of image formats such as PNG, BMP, PPM
- base64 Base64 encoding for OCaml
- multipart-form-data Parser for multipart/form-data (RFC2388)
- multipart_form Multipart-form: RFC2183, RFC2388 & RFC7578
- biniou Binary data format designed for speed, safety, ease of use and backward compatibility as protocols evolve
Web development frameworks for building OCaml web applications.
- dream Tidy, feature-complete Web framework
- eliom Client/server Web and mobile framework
- opium OCaml web framework
- sihl The Sihl web framework
HTTP client libraries for making HTTP requests.
- cohttp An OCaml library for HTTP clients and servers
- hyper Web client with HTTP/1, HTTP/2, TLS, and WebSocket support
- ocurl Bindings to libcurl
- http-lwt-client A simple HTTP client using http/af, h2, and lwt
- ezcurl Friendly wrapper around OCurl
Internationalization and localization for OCaml applications.
- gettext Internationalization library (i18n)
Packages for logging and monitoring that assist in tracking application behavior and performance.
- logs Logging infrastructure for OCaml
- dolog The dumb OCaml logging library
- tracing Tracing library
- catapult Tracing system based on the Catapult/TEF format
- opentelemetry Instrumentation for https://opentelemetry.io
- prometheus Client library for Prometheus monitoring
Packages that provide foundational networking and communication capabilities.
- httpaf A high-performance, memory-efficient, and scalable web server for OCaml
- http Type definitions of HTTP essentials
- tls Transport Layer Security purely in OCaml
- websocket Websocket library
- websocketaf Websocket implementation for use with http/af
- gluten A reusable runtime library for network protocols
- awa SSH implementation in OCaml
- uri An RFC3986 URI/URL parsing library
- dns An opinionated Domain Name System (DNS) library
- tcpip OCaml TCP/IP networking stack, used in MirageOS
- charrua DHCP wire frame encoder and decoder
- mirage-nat Mirage-nat is a library for network address translation to be used with MirageOS
- arp Address Resolution Protocol purely in OCaml
- ethernet OCaml Ethernet (IEEE 802.3) layer, used in MirageOS
- paf HTTP/AF and MirageOS
- mimic A simple protocol dispatcher
- tiny_httpd Minimal HTTP server using threads
Packages for interacting with popular message queues and key-value stores.
- amqp-client Amqp client base library
- kafka OCaml bindings for Kafka
- redis Redis client
- zmq OCaml bindings for ZeroMQ 4.x
Packages for serializing and deserializing data in different formats.
- atd Parser for the ATD data format description language
- yojson Yojson is an optimized parsing and printing library for the JSON format
- jsonm Non-blocking streaming JSON codec for OCaml
- sexplib Library for serializing OCaml values to and from S-expressions
- yaml Parse and generate YAML 1.1/1.2 files
- csv A pure OCaml library to read and write CSV files
- bencode Bencode (`.torrent` file format) reader/writer in OCaml
- toml Library for TOML with a parser, a serializer and a printer
- xml-light Xml-Light is a minimal XML parser & printer for OCaml
- graphql Build GraphQL schemas and execute queries against them
- omd A Markdown frontend in pure OCaml
- cmarkit CommonMark parser and renderer for OCaml
- css CSS parser and printer
- csexp Parsing and printing of S-expressions in Canonical form
- data-encoding Library of JSON and binary encoding combinators
Packages for syndicating content and working with RSS feeds.
- syndic RSS1, RSS2, Atom and OPML1 parsing
- river RSS2 and Atom feed aggregator for OCaml
- rss Library to read and write RSS files
Packages that assist in generating dynamic HTML or text content.
- tyxml A library for building correct HTML and SVG documents
- embedded_ocaml_templates EML is a simple templating language that lets you generate text with plain OCaml
- mustache Mustache logic-less templates in OCaml
- jingoo Template engine almost compatible with Jinja2(python template engine)
Packages for generating static websites.
- finch Simple and fast site generator
- stone Simple static website generator, useful for a portfolio or documentation pages
- camyll A static site generator
- yocaml YOCaml is a static site generator, mostly written in OCaml
- dream-serve Static HTML website server with live reload
- soupault Static website generator based on HTML rewriting
Packages that provide OCaml bindings and clients for interacting with external web APIs.
- spotify-web-api OCaml bindings to the Spotify web API
- disml An OCaml library for interfacing with the Discord API
- openai OCaml OpenAI binding
- github GitHub APIv3 OCaml library
- telegraml Telegram Bot API for OCaml
- slacko Type-safe binding to the Slack API
Packages and tools for compiling OCaml code to WebAssembly.