“This is the third day of my participation in the First Challenge 2022, for more details: First Challenge 2022”.

What is a Tauri?

Tauri is a framework for building small, fast binaries for all major desktop platforms. Developers can integrate any front-end framework compiled into HTML, JS, and CSS to build their user interfaces. The back end of the application is a Rust binary with an API with which the front end can interact.

In the star chart of 2021, Tauri has grown by 18K in one year and ranked fifth, so we wondered, what is tauri’s advantage?

I then tested a Hello World program packaged with tauri and electron.js, to see their sizes.

The size of the contrast

  • Electron.JS 62.5mb
  • Tauri 4.32mb

The desktop application Tauri builds is far too small to be comparable to Electron.js, as it does away with the massive Chromium kernel and NodeJS, uses the operating system’s WebView on the front, and integrates Rust on the back. Tauri provides templates for initializing programs such as native JS, react, svelte.js, vue.js, and so on.

From the MOBILE the when? The Tauri team is also working on supporting Android and IOS. Isn’t that a bit of an expectation?

Start trying Tauri

Because Tauri is a multilingual tool chain, the installation involved is a bit complicated.

I have macOS

1. Install GCC compiler first

$ brew install gcc
Copy the code

You can switch the source of Homebrew to Tsinghua University first. You need to install Homebrew first. The following command is the domestic installation address of Homebrew

Install homebrew

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Copy the code

2. Make sure xcode is installed

xcode-select --install
Copy the code

3. Install the Nodejs operating environment and the package management tool YARN

We’ve already installed the front end at this point

Install ruSTC, the compiler for the Rust programming language

$ curl --proto '=https'- tlsv1.2 - sSf https://sh.rustup.rs | shCopy the code

You can then use the official CLI initializer.

yarn create tauri-app
Copy the code

It is then initialized in the project directory

yarn tauri init
Copy the code

This step is slow, I am not sure if I did not specify the internal source of rust, you can leave a comment in the comments section. After completing yarn Start, just like developing react, hot updates can be made in real time.

The first time you run this command, it takes a few minutes for Rust package manager to download and build all the required packages, and subsequent builds are much faster because they are cached.

Client development startup command

yarn tauri dev

You can also right-click to review elements

Package client

yarn tauri build

Compared with Electron

We can check out the electron comparison via the official Github Readme

Comparison between Tauri and Electron

detailed Tauri Electron
Installation package size Linux 3.1 MB 52.1 MB
Memory consumption Linux 180 MB 462 MB
Boot time Linux 0.39 s 0.80 s
Interface Service provision WRY Chromium
The back-end binding Rust Node.js (ECMAScript)
Potential engine Rust V8 (C/C++)
FLOSS Yes No
multithreading Yes Yes
Bytecode delivery Yes No
A lot of window Yes Yes
Automatic updates Yes Yes1
Custom App Icon Yes Yes
Windows Binary Yes Yes
MacOS Binary Yes Yes
Linux Binary Yes Yes
iOS Binary Soon No
Android Binary Soon No
Desktop Tray Yes Yes
Sidecar Binaries Yes No

summary

This attempt, from the Web layer only, does not involve the back end of the system and requires some rust-related knowledge. If you are familiar with the Node.js API, it is recommended to use Tauri. After all, a program as large as VScode is also built from electron.js.

That’s all the content of this article. I hope this article is helpful to you. You can also refer to my previous articles or share your thoughts and experiences in the comments section.