Rust, Tauri, and React: Our Technology choices for a desktop app in 2022
This year, we built HighFlux, a transformative git client that synchronizes code to the cloud while a developer is writing it. As a team with experience in mobile and web app development, building a desktop app was a new and exciting challenge for us. Here, we want to share the decisions we made and what we learned along the way.
Why Rust was the ideal choice for our app
When we started, we needed to choose which core technology to use. We wanted a lightweight and fast solution that would not consume too much CPU or memory. Developers frequently run multiple programs, like an IDE, development servers, and potentially docker images, and HighFlux should leave as much CPU and RAM as possible available for those tools.
To meet these requirements we rejected garbage-collected technology like a JVM language (Kotlin would have been our preferred technology given our previous experience) or Go. Almost all information on the internet points in one direction: Rust is the modern non-garbage collected multi-platform language of choice right now.
Frontend: Tauri + React
For the GUI, we chose the Tauri platform on which we built a React frontend. Tauri reuses an already installed browser on your system, so the app stays lightweight. Our final app is less than 20MB for all three platforms we’re targeting (Windows, macOS, and Linux).
Rust took a short while to get used to, but once we got the hang of the borrow checker and the tokio async runtime, development was productive and pleasant, with (libgit2)[https://github.com/rust-lang/git2-rs] as a big help in implementing our fully git-compatible code.
Supporting Windows, macOS and Linux from the start
We considered doing a single platform launch first, but as between the three founders we use 2 out of the 3 platforms already, we decided we could launch for all three. With Windows being the least used platform by us as developers, that platform required the most tweaking: named pipes work differently than on UNIX platforms, UNC pathnames sometimes break stuff (thankfully, there’s a crate called dunce crate that simplifies this), and we ran into some issues with the maximum length of pathnames. Apple macOS required sending our builds to Apple for signing and notarizing to prevent users from having to click through a big scary security warning, and this also took some time to set up.
We ended up with one Rust codebase with a limited number of #[cfg(unix)]
and #[cfg(windows)]
classifiers for OS-specific code. The UI is a node React project without special cases for the different OSes.
Other choices
Some other choices we made:
- We track any potential crashes of our app using Sentry’s Rust SDK.
- We use Rudderstack to log essential usage metrics to analyze our app's usage and make improvements. Rudderstack allows us to choose where we view our user events flexibly, and at this moment, we can view them in Google Analytics and Mixpanel.
- We created an in-app notification when there’s a newer version of our software that users can upgrade to. Unfortunately, there’s no good mechanism to automate the upgrade for the user yet. Upgrading software is a no-brainer in the web app and mobile app world, and, unfortunately, desktop apps don’t have a method that’s just as easy.
Overall, building a desktop app with Rust, Tauri, and React was a great experience. Rust's performance and safety made it a perfect fit, while Tauri and React allowed us to quickly develop a modern, lightweight GUI. Supporting all three platforms required some extra effort, but it was worth it to reach a wider audience.
Mathijs is one of the co-founders of HighFlux.io
HighFlux is a transformative git client that lets you automate tedious git tasks, get early feedback on your code, and prevent conflicts, all while maintaining the full power and flexibility of Git.