Jane Street’s open-source Bonsai project offers OCaml developers a framework for building reactive interfaces from incremental, composable state machines. The company says it uses the technology for nearly all of its internal web applications, ranging from a corporate directory to systems that monitor and interact with trading infrastructure.
Bonsai is partly inspired by Elm, but its architecture separates concerns often combined within a conventional user-interface component. State management and incremental computation can be composed independently, while values are recomputed only when necessary. That principle applies beyond rendering: developers can also incrementalize costly business logic operating on a dataset that changes over time.
The framework represents components as purely functional state machines. Because state does not have to belong to an explicit position in a component hierarchy, Bonsai provides lifecycle and scoping tools for retaining and organizing it as a user moves through an application. Jane Street uses a tabbed collection of stateful interfaces as one example: the framework can manage the nested state without requiring developers to lift every value into a top-level application model.
OCaml also allows teams to use the same language and type definitions across browser and server code. Jane Street says that continuity has made large applications easier to understand and maintain, while allowing existing types and business logic from terminal-based internal tools to be reused on the web. Browser applications are delivered through Bonsai_web and Js_of_ocaml.
Bonsai includes a templating language, component-specific stylesheets and support for automated application testing. Its tests can programmatically interact with interface elements and record how the document object model changes. Test scenarios can make multiple assertions, inspect differences in attributes or class names, mock server calls and track changes in underlying state. The project documentation says this enables developers to build and test a component without repeatedly opening a browser.
The repository’s scope is broader than web development alone. The core Bonsai library supports general-purpose incremental state machines. Bonsai_web specializes those primitives for interactive browser interfaces, while Bonsai_term applies them to terminal applications. Jane Street has also produced an experimental virtual-reality variant as an April Fools’ project.
That layered structure distinguishes the reusable computation model from any single rendering environment. For teams already invested in OCaml, it offers a path from typed business logic to interactive tools while keeping state and recalculation explicit. For newcomers, Jane Street directs readers to its Quick Start and “Thinking in Bonsai” guides, along with examples comparing approaches to state composition.
Bonsai’s internal deployment at Jane Street demonstrates the range the company claims for the library. External teams will still need to assess its OCaml and Js_of_ocaml requirements, ecosystem fit and learning curve against more established browser frameworks.


