When we use Crux to build Web apps, the shared core is compiled to WebAssembly. This has the advantage of sandboxing the core, physically preventing it from performing any side-effects (which is conveniently one of the main goals of Crux anyway!). The invariants of Crux are actually enforced by the WebAssembly runtime.
When building UI with React, or any other JS/TS framework, the Core API bindings are generated in TypeScript using Mozilla's Uniffi, and, just like with Android and iOS we must serialize and deserialize the messages into and out of the WebAssembly binary.
The shared core (that contains our app's behavior) is compiled to a WebAssembly
creates an npm package for us that we can add to our project just like any other
The shared types are also generated by Crux as a TypeScript npm package, which
we can add in the same way (e.g. with
This section has two guides for building TypeScript UI with Crux:
When building UI with Rust, we can compile the entire app to WebAssembly, and
reference the core and the
shared crate directly. We do not have to serialize
and deserialize messages, because the messages stay in the same memory space.
The shared core (that contains our app's behavior) and the UI code are
compiled to a WebAssembly binary, using the relevant toolchain for the language
and framework we are using. We use
trunk for the Yew
and Leptos guides and
for the Dioxus guide.
When using Rust throughout, we can simply use Cargo to add the
directly to our app.
This section has three guides for building Rust UI with Crux: