Although C++ offers a wide range of computational libraries with various capabilities and enables high-performance computing, there are long-standing challenges in integrating them into a React Native project. To address these challenges, we developed a practical set of tools and a sustainable methodology for automating an all-in-one solution for using C++ libraries in cross-platform JavaScript applications.
Manually compiling, porting, and bridging a library is not only difficult but also unscalable in enterprise settings. For large corporations and commercial products, using C++ in React Native should not introduce additional complexity or make projects fragile. Instead, the React Native community needs a stable, permanent, long-term solution that works in a scalable manner while offering reliability.
With cpp.js, developers can include many pre-ported C++ libraries into React Native or WebAssembly projects by simply including the relevant header files. While the Codegen project already supports C++ bridging in React Native, it is limited to function calls and primitive types. In contrast, we offer Object-Oriented Programming (OOP) support and modern C++ features (C++11 & C++14), enabling integration with a broad range of widely-used C++ libraries. For example, we have successfully integrated GIS libraries such as GDAL into React Native, demonstrating cpp.js’s practical effectiveness. With little to no effort, cpp.js can support the long-term maintenance of various C++ libraries, thanks to our automation processes. This minimises the traditionally difficult engineering work of cross-compiling, porting, and bridging libraries to JSI.
Following the introduction to our toolset, architectural decisions and development journey, we will show;
(1) how to quickly write and execute native C++ code within a JavaScript environment,
(2) utilising and importing ready-to-use native C++ libraries from our cpp.js repository. Further, for developers in more sophisticated cases,
(3) we will show how to port a C++ library you need using our toolset, even if the C++ library has external dependencies. This showcases modularity, independence in maintenance, the scalability characteristics of our project, further giving developers more control.
We warmly welcome collaboration and feedback from the React Native community. Although this talk focuses on React Native, cpp.js is a cross-platform solution that also supports WebAssembly (web, Node.js, Cloudflare Workers, etc.), alongside mobile platforms. We will cover these broader aspects in our upcoming talks.