Here is server-reason-react
, the OCaml implementation of React I have been working on: Server-side rendering React in OCaml | sancho.dev
The blog post is targeted for a Frontend/JS dev, but I believe it can be interesting from the OCaml site as well.
server-reason-react
is an implementation of react-dom/server
and some of React’s internals in OCaml. The purpose is to render HTML markup from the server for a Reason React application natively.
It supports hydration (renderToString) and full render (renderToStaticMarkup) and most unit tests from ReactDOMServer are migrated as well. Basically, to ensure hydration “hacks” work the same way as react’s DOM (in JavaScript).
It’s obviously fast, talking about req/s: x10 against Node and x6 against Bun on the same codebase. Performance is not the priority, though. I did 0 perf work but is cool. If you want to help making it very fast, let me know!
The priority is to implement streaming and later RSC. Can’t wait to try OCaml multicore with Server components.
All of this is thanks to Melange, and I’m grateful to work with @_anmonteiro and @javierwchavarri.