How Tauri Turns Web Designs into Compact Native Apps
Tauri is more of a methodology with some tools, as opposed to a complete platform approach. But it looks like a strong option for engineering teams looking to turn web designs into small apps.
Jul 30th, 2022 6:00am by
- A Rust binary that creates the windows and exposes native functionality to those windows
- A web frontend of your choice that produces the user interface inside the window
💡 Tauri is a framework to build desktop applications with any frontend framework and a Rust core.I’d probably prefer to be writing less JavaScript, but I’m a pragmatist. Most of the worlds UI is written for the web, after all. So for my test drive, I’ve used the start guide with the given Vite example. Tauri presents itself as a glue-like technology that focuses on the toolchain, which means it might feel a bit rougher on new developers because you touch a lot of pieces in passing. It’s always harder to tell what made you sick when you eat from a buffet. Conversely, it is well suited to leveraging the knowledge of an experienced frontend developer. I’ll follow the steps in the guide with my mac. I know one prerequisite is Rust, but I also figure my node setup is totally out of date. From my shell, I check I have the all-important Xcode libraries:
<code class="language-bash">> xcode-select --install </code>
<code class="language-bash">> nvm install v16.16.0 </code>
<code class="language-bash">> curl --proto '=https' --tlsv1.2 [https://sh.rustup.rs](https://sh.rustup.rs/) -sSf | sh</code>
<code class="language-bash">> npm create tauri-app</code>
<code class="language-bash">> npm run tauri dev</code>
We can also make a release build, that will build a fully installable application:
<code class="language-bash">> npm run tauri build</code>
This was a 9MB file inside my Applications folder. Small enough. So I made a very simple app, but the toolchain was comprehensible and fairly quick on my elderly machine.
Before I leave, let’s see if we can use Tauri to make the app a bit smaller. I note that an “allowlist” in “tauri.conf.json” mentions which modules will be built. Now the only special bits this app needs is the ability to open an HTML page on an external browser, so using the documentation, I tried this quick hack:
...
"tauri": {
"allowlist": {
"all": false,
"fs": {
"all": true
},
"shell": {
"open": true
},
"http": {
"request": true
}
}
},
...
And the resulting build went down to a size of 8MB, which was still functional.
From 9MB to 8MB is certainly an effective crash diet, more importantly, underlining how relatively easy it is to control the size.
Now to delve deeper would involve a little more familiarity with Rust, but that language is in vogue at the moment so it would likely be a rewarding task. As I mentioned, Tauri is more of a methodology with some tools, as opposed to a complete platform approach. It looks like a strong option for engineering teams looking to turn web designs into small apps.
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube
channel to stream all our podcasts, interviews, demos, and more.