Cross-platform app development in Rust
See the codeWatch the introductory talk | Read the book | Read API docs | Join Zulip community
Start with the book, then work through the examples in order. If you prefer a talk first, watch the introductory Rust Nation 2023 talk.
Read the API documentation.
You can also join the friendly conversation on our Zulip channel.
[!NOTE] Crux is pre-1.0 and under active development. It is production-ready, but occasional breaking changes to the API can be expected. We do our best to limit the extent of these and provide a smooth, gradual migration path
Crux has managed side-effects. It strictly separates pure computational tasks from tasks that cause side effects. This is similar to the way Elm works.
In the above diagram, the inner "Core" is compiled and linked to the outer "Shell" on each platform as a library:
In fact, because WebAssembly (Wasm) is one of the compilation targets, the core must remain side-effect-free, due to the sandboxed nature of the Wasm runtime environment.
As such, the core is completely isolated and secure against software supply-chain attacks, as it has no access to any external APIs. All it can do is perform pure calculations and keep internal state.
Following the Elm architecture, the core defines the key component types within the application:
Event — an enum describing the events which the core can handleModel — describes the internal state of the applicationEffect – the kinds of side-effects the core will requestViewModel — represents information that should be displayed to the userThe first three are tied together by the update function, familiar from Elm,
Redux or other event sourcing architectures, which has this type
signature:
fn update(
&self,
event: Event,
model: &mut Model,
) -> Command<Effect, Event> {
// ...
}
The job of the update function is to process an Event, update the model
accordingly, and request some side-effects by returning a Command.
[!NOTE] To learn more about the
CommandAPI, see the page in the book that describes Managed Effects, or look at the examples:
- Counter — get the basics
- Counter (HTTP) — understand how to talk to your API
- Weather — see how a real app works
- Notes — real-time collaboration
- Counter (Middleware) — use middleware for Rust-side effects
- Counter (Routing) — use effect routing for type-based, per-effect dispatching
The enclosing platform native "Shell" is written using the language appropriate for the platform, and acts as the runtime environment within which all the non-pure tasks are performed. From the perspective of the core, the shell is the platform on which the core runs.
Tests can act as another Shell, exercising the Core in the same way a real app would, observing and resolving the requested effects and checking the model and view model are correct. No need for fakes, mocks or stubs.
Following the Elm architecture, the interface with the core is message based.
To perform any task that creates a side-effect (such as an HTTP
call or random number generation), the core must request it from the shell as an Effect.
Effects support fire-and-forget, request/response, and streaming semantics.
Crux has a concept of Capabilities — reusable interfaces for common side-effects which can be used in the Core as a more ergonomic API.
The only built-in capability is Render. But this repository contains a few
capabilities at various stages of maturity, and you can easily write your own if
you want to:

Render (ask UI to render the ViewModel) —
source,
built-in to crux_core, request onlyHttp (full HTTP implementation) — source,
crate, request/responseKeyValue (basic key-value store API) — source,
crate, request/responseTime (get current time, notify after duration, notify at instant) —
source, crate,
request/responseSSE (basic Server-Sent Events) —
source,
request/streamingPubSub (pub sub with streaming) —
source,
request/response/streamingThe core API interface is very minimal — the three methods of
Bridge,
which wraps the Core and presents it in serialized form:
update: Event -> Vec<Request> - processes a user interaction event and
potentially responds with effect requests. This is the API for the driving
side in the above diagram.resolve: (EffectId, Output) -> Vec<Request> - hands the output of a
requested effect back to the core, which may follow up with further requests.
This is the API for the driven side in the above diagram.view: () -> ViewModel - provides the shell with the current data for
displaying user interfaceThe Foreign Function Interface allowing the shell to call those methods is generated by BoltFFI across native, web, and C# shells.
In order to keep the host-facing API consistent across platforms and enforce the message passing semantics, all messages are serialized, sent across the boundary, then deserialized using Bincode. Type definitions and serialization code for the foreign (non-Rust) languages are generated by facet-generate.
This means that changes to types in the core, especially the Event and
Request types, propagate out into the shell implementations and cause type
errors where appropriate (such as an exhaustive match on an enum check).
Three types of message are exchanged between the application and the core.
Event are sent from the Shell to the Core in response to an
event happening in the user interface (the driving side). They start a
potential sequence of further message exchanges between the shell and the
core. Messages are passed on unchanged.Request are sent from the Core to the Shell to request the
execution of some side-effect-inducing task. The Core responds with zero or
more Request messages after receiving an Event message (the driven
side).Request messages contain the inputs for the requested side-effect, along with
an id used by the core to pair requests and their responses together. The
exact mechanics are not important, but it is important for the request's id
to be passed on to the corresponding response.
A typical message exchange cycle may look like this:
Eventupdate function passing the Event as an
argumentRequest messages to the Shell (inside an enum
tagging the type of request)In the simplest case, the Core will respond to an Event by returning the
single Request - render.
This requests that the Shell re-renders the user interface. When Render is the
only response from the Core, the message cycle has completed and the Core has
now "settled".
In more complex cases however, the Core may well return multiple Requests;
each of which instructs the Shell to perform a side-effect-inducing task such
as:
Many of these side-effect-inducing tasks are asynchronous. The Shell is
responsible for passing responses back to the core (to the resolve function),
which may respond with further requests.
This exchange continues until the core stops requesting further side-effects
(typically the last side-effect requested would again be Render).
Crux is kindly sponsored by the following organizations. Your help is very much appreciated.
Red Badger is the digital product consultancy trusted by blue chips and global brands. Our product design and technical pedigree allow us to craft high-impact digital products customers want. We use modern engineering approaches to deliver sustainable change. And embed digital capabilities to power continuous innovation.
Zulip is an open-source modern team chat app designed to keep both live and asynchronous conversations organized.
Zulip sponsors Crux by providing our Zulip server — thank you Zulip!
(top 24 of 79)
53,336 followers · starred Nov 2025
2,273 followers · starred Mar 2023
1,891 followers · starred Feb 2023
69 followers · starred Sep 2026
Cross-platform app development in Rust
See the codeWatch the introductory talk | Read the book | Read API docs | Join Zulip community
Start with the book, then work through the examples in order. If you prefer a talk first, watch the introductory Rust Nation 2023 talk.
Read the API documentation.
You can also join the friendly conversation on our Zulip channel.
[!NOTE] Crux is pre-1.0 and under active development. It is production-ready, but occasional breaking changes to the API can be expected. We do our best to limit the extent of these and provide a smooth, gradual migration path
Crux has managed side-effects. It strictly separates pure computational tasks from tasks that cause side effects. This is similar to the way Elm works.
In the above diagram, the inner "Core" is compiled and linked to the outer "Shell" on each platform as a library:
In fact, because WebAssembly (Wasm) is one of the compilation targets, the core must remain side-effect-free, due to the sandboxed nature of the Wasm runtime environment.
As such, the core is completely isolated and secure against software supply-chain attacks, as it has no access to any external APIs. All it can do is perform pure calculations and keep internal state.
Following the Elm architecture, the core defines the key component types within the application:
Event — an enum describing the events which the core can handleModel — describes the internal state of the applicationEffect – the kinds of side-effects the core will requestViewModel — represents information that should be displayed to the userThe first three are tied together by the update function, familiar from Elm,
Redux or other event sourcing architectures, which has this type
signature:
fn update(
&self,
event: Event,
model: &mut Model,
) -> Command<Effect, Event> {
// ...
}
The job of the update function is to process an Event, update the model
accordingly, and request some side-effects by returning a Command.
[!NOTE] To learn more about the
CommandAPI, see the page in the book that describes Managed Effects, or look at the examples:
- Counter — get the basics
- Counter (HTTP) — understand how to talk to your API
- Weather — see how a real app works
- Notes — real-time collaboration
- Counter (Middleware) — use middleware for Rust-side effects
- Counter (Routing) — use effect routing for type-based, per-effect dispatching
The enclosing platform native "Shell" is written using the language appropriate for the platform, and acts as the runtime environment within which all the non-pure tasks are performed. From the perspective of the core, the shell is the platform on which the core runs.
Tests can act as another Shell, exercising the Core in the same way a real app would, observing and resolving the requested effects and checking the model and view model are correct. No need for fakes, mocks or stubs.
Following the Elm architecture, the interface with the core is message based.
To perform any task that creates a side-effect (such as an HTTP
call or random number generation), the core must request it from the shell as an Effect.
Effects support fire-and-forget, request/response, and streaming semantics.
Crux has a concept of Capabilities — reusable interfaces for common side-effects which can be used in the Core as a more ergonomic API.
The only built-in capability is Render. But this repository contains a few
capabilities at various stages of maturity, and you can easily write your own if
you want to:

Render (ask UI to render the ViewModel) —
source,
built-in to crux_core, request onlyHttp (full HTTP implementation) — source,
crate, request/responseKeyValue (basic key-value store API) — source,
crate, request/responseTime (get current time, notify after duration, notify at instant) —
source, crate,
request/responseSSE (basic Server-Sent Events) —
source,
request/streamingPubSub (pub sub with streaming) —
source,
request/response/streamingThe core API interface is very minimal — the three methods of
Bridge,
which wraps the Core and presents it in serialized form:
update: Event -> Vec<Request> - processes a user interaction event and
potentially responds with effect requests. This is the API for the driving
side in the above diagram.resolve: (EffectId, Output) -> Vec<Request> - hands the output of a
requested effect back to the core, which may follow up with further requests.
This is the API for the driven side in the above diagram.view: () -> ViewModel - provides the shell with the current data for
displaying user interfaceThe Foreign Function Interface allowing the shell to call those methods is generated by BoltFFI across native, web, and C# shells.
In order to keep the host-facing API consistent across platforms and enforce the message passing semantics, all messages are serialized, sent across the boundary, then deserialized using Bincode. Type definitions and serialization code for the foreign (non-Rust) languages are generated by facet-generate.
This means that changes to types in the core, especially the Event and
Request types, propagate out into the shell implementations and cause type
errors where appropriate (such as an exhaustive match on an enum check).
Three types of message are exchanged between the application and the core.
Event are sent from the Shell to the Core in response to an
event happening in the user interface (the driving side). They start a
potential sequence of further message exchanges between the shell and the
core. Messages are passed on unchanged.Request are sent from the Core to the Shell to request the
execution of some side-effect-inducing task. The Core responds with zero or
more Request messages after receiving an Event message (the driven
side).Request messages contain the inputs for the requested side-effect, along with
an id used by the core to pair requests and their responses together. The
exact mechanics are not important, but it is important for the request's id
to be passed on to the corresponding response.
A typical message exchange cycle may look like this:
Eventupdate function passing the Event as an
argumentRequest messages to the Shell (inside an enum
tagging the type of request)In the simplest case, the Core will respond to an Event by returning the
single Request - render.
This requests that the Shell re-renders the user interface. When Render is the
only response from the Core, the message cycle has completed and the Core has
now "settled".
In more complex cases however, the Core may well return multiple Requests;
each of which instructs the Shell to perform a side-effect-inducing task such
as:
Many of these side-effect-inducing tasks are asynchronous. The Shell is
responsible for passing responses back to the core (to the resolve function),
which may respond with further requests.
This exchange continues until the core stops requesting further side-effects
(typically the last side-effect requested would again be Render).
Crux is kindly sponsored by the following organizations. Your help is very much appreciated.
Red Badger is the digital product consultancy trusted by blue chips and global brands. Our product design and technical pedigree allow us to craft high-impact digital products customers want. We use modern engineering approaches to deliver sustainable change. And embed digital capabilities to power continuous innovation.
Zulip is an open-source modern team chat app designed to keep both live and asynchronous conversations organized.
Zulip sponsors Crux by providing our Zulip server — thank you Zulip!
(top 24 of 79)
53,336 followers · starred Nov 2025
2,273 followers · starred Mar 2023
1,891 followers · starred Feb 2023
69 followers · starred Sep 2026