My Experiments with ̷T̷r̷u̷t̷h̷ Tauri

Vinayak Nigam
7 min readJun 15, 2023

My story started with me trying to apply for GSoC for the first time.
I first came to know about Tauri when I was browsing the projects list of Rocket.Chat, in the past I did know about Electron and such but never heard about any other framework to build cross-platform desktop apps. This story is for those who don't know anything about Tauri and want a beginner’s insight into it.

The goal of this blog is not to tell you everything about Tauri or how to code in it etc. My goal here is to show you the different paths I discovered in my exploration of Tauri which might be obscured for a newcomer and I trust your intellect in further exploring those paths

Okaaaay lets go!

Tauri and Rust devs lol

For those who don't know Tauri

Tauri is an open-source application development platform that allows developers to create desktop and mobile applications using web technologies like HTML, CSS, and JavaScript.

Tauri provides a secure and lightweight runtime environment for building applications with a native look and feel. It enables developers to build cross-platform applications that work seamlessly on Windows, Mac, and Linux operating systems.

Lightweight”- That was the word thrown around, along with “memory efficient” (We’ll come back on that later!)on the internet in regards to Tauri everywhere I searched on the internet and one of the key advantages which Tauri has on ElectronJS.
ElectronJS’ major drawback is that it makes massive apps in terms of storage size and computer resources like RAM and CPU, courtesy of Google Chrome ofc. If you search the internet about Tauri vs Electron, these 3 points are the main ones that come up in almost every blog or video.

  1. Built on Rust: Tauri leverages the power of Rust, a programming language known for its performance and memory safety, as opposed to relying solely on JavaScript, the traditional choice for frameworks like Electron.
  2. Minimal bundle size: Unlike ElectronJS, Tauri ships applications with an impressively small bundle size. By stripping away unnecessary binaries, Tauri offers a lean package that doesn’t burden your users’ devices.
  3. Security and isolation: Tauri incorporates robust security measures through an allowlist mechanism and many other features. With this feature, you can specify precisely which APIs can be called by the backend, ensuring the integrity and safety of your application

One of the most convenient features of Tauri is that a single command will scaffold a fully functioning app without having to configure painstakingly or having to find a ready-made template for any primary framework etc.(👀 Electron)

By simply entering yarn create tauri-app and answering a few questions, you'll have a clean and efficient starting point for your project. Clean and efficient for onboarding 😸

what? done like that? Fr?

A Fusion of Frontend and Backend, Forged in Rust

Tauri essentially ties together a frontend(generally Vite) and a Rust backend to make a blazingly fast and secure app. The general structure of a newly created Tauri app is src(frontend) and src-tauri(backend). While the Rust part of the application may take a few minutes to compile during the initial cold start or when adding dependencies, the front end benefits from Hot Module Replacement (HMR) through Vite, enabling rapid development iterations but every time you save a change in the Rust part, the app re-compiles(only the files in which changes happen) and then restart the game.

You might be wondering, “Do I need to learn Rust to use Tauri?” The answer is both yes and no. While the backend requires Rust code, Tauri provides JavaScript APIs that allow you to perform various Rust-based actions without writing a single line of Rust. This approach strikes a balance between harnessing the power of Rust and offering a familiar environment for web developers.

Tauri provides a robust security measure in terms of allowlist ie we can specify in detail what APIs can be called to the backend and what specific function of that APIs too.

Aside from the APIs, Tauri also offers some plugins to handle other functionalities like uploading/downloading, autostart, watching the filesystem for changes etc. By leveraging these plugins, you can take advantage of Rust’s efficiency while streamlining your development process.

How does it even happen anyway?

With these things out of the way, let's talk about how Tauri can even ship such small-size applications. For that, we have to understand why Electron ones are so large.

The apps made in Electron are shipped with a sandbox of Chrome inside which the app is opened

so in essence the app and a whole browser are being shipped when the Electron app is built and because Chrome is a hungry resource eater, so does its Electron counterparts do as well. Tauri takes a different approach in which only the app is shipped and stripped of any extra binaries.

It uses the already installed Edge (yea that Microsoft one which you always ignore) for Windows, Safari for MacOS and WebkitGTK for Linux(This is made possible with Tao and Wry which you can check out later). Since there are different “browsers” for different devices so even though there is a cross-platform compilation, there can still be some browser compatibility issues especially when you are using any third-party libraries.

For example, when I wanted to use notify-rust, a major of its features were only available in XDG(Linux) so I would have to code for the other platform. But this “problem” is not of Tauri but more so of the ecosystem as a whole since it's still in its infant years. This may sound weird but Tauri does not support cross-platform compilation(it's in their roadmap) but does through Tauri Actions(GH Actions) which is very well documented.

The Community tho!

but fr they are cool

The Tauri Community is really welcoming(looking at you Fabian 🐐)and their support is what motivated me to involve myself in Tauri and use it even though I didn't know any Rust or much about Tauri. The community offers two primary avenues for discussion: Github Discussions and Discord. While GitHub Discussions provide a platform for focused and concise interactions, Discord offers a broader community experience with diverse channels dedicated to showcasing projects built with Tauri, problem-solving, and discussions about experimental core features of the framework. Do check out their website and docs for more info cause they have done a good job.

As the docs are still in rapid development, there might be a chance that what you wanted to find might not be documented. In that case, you can simply check out the docs.rs default Rust docs(99% chance they are present) for that function/crate(library in Rust) and if you still don’t understand then you can simply ask on GH Discussions or Discord.
While asking, if you present your research regarding that topic and effort, it has a high chance of being answered, not just for Tauri but in any community. Ofc don’t forget to search on StackOverflow and Google 😉

Also on an unrelated topic, you don't know how much I appreciate Rust’s compiler, especially coming from a JS background. It is such a godsend and properly tells me where the error is and what might solve it instead of straight-up committing seppuku and now I have to check the nook and cranny of the intestines(Call stack) to know which morsel poisoned it lol

Soooooo, what’s the catch?

Of course, not everything is all rainbow and sunshine, because if Tauri is so perfect, why is it not being immediately adopted everywhere?
There are several reasons for that

  1. Tauri’s early stage: Tauri is in its infancy years and it still developing so there are still many features which are not made or in progress or not even in the roadmap.
  2. Resistance to change: In the programming world nobody wants to change anything still working, although this is slowly changing more and more people are becoming aware of Tauri so we don't know what the future holds.
  3. The RAM consumption might have a little caveat. From my research and fortunately finding an issue too I have found that both Electron and WebView2 are built from the Chromium source for rendering web content. Strictly speaking, WebView2 is built from the Edge source, but Edge is built using a fork of the Chromium source, which explains the somewhat high memory usage. Pretty much all of the memory usages is outside of Tauri’s control and entirely depends on the WebView2 runtime. The issue here is that both Electron and Tauri use Chromium, so magically cutting RAM usage in half is unrealistic.

I mean, sure, if most of the RAM usage were from the Node.js process, then I’d imagine Tauri’s Rust backend would be more efficient, but for in-browser stuff, there likely won’t be much of a difference. The use case of Tauri is in theory, everything except actual browsers. And I think that this might be a “problem” in Windows only due to Webview2 but Tauri uses WebKitGTK on Linux and WebKit on macOS so it might be better. Due to some error, I’m not able to test things on Linux to come to a more solid conclusion.

btw if you want a 100-second introduction to revise what I said, you can check out Fireship’s video. He makes awesome videos related to dev.
Some cool people make videos about Tauri like this one by Simon Hyll

Hopefully, this blog has given you enough context about Tauri that you can now explore on your own.

Until next time!

In future blog posts, I might delve deeper into specific aspects of Tauri that I might have missed in this article. Stay tuned for more insights and discoveries!
Follow me on Twitter for regular updates.

--

--

Vinayak Nigam

I'm Vinayak aka louremipsum - Frontend Developer, UI/UX designer, and problem-solving enthusiast. Passionate about coding, anime, philosophy, and random things