Tauri – a PC side spa framework that can replace electronic


Recently, I found this framework by accident. From the description of this framework and my practice, it is indeed the mainstream framework on the PC side in the future. As we all know, the only two disadvantages of electron are: 1. Poor performance; 2. The size of the package is too large. Here are the reasons for using Tauri

Introduction to Tauri

The following is from the official note:

Why use Tauri

  • Design of the original Tauri applicationPacking sizeLess than 3 MB, 140 Mb smaller than electron.
  • Memory footprintLess than half the size of an electron application built with the same code base.
  • securityIt’s Tauri’s top priority, and we’re constantly innovating.
  • Unfortunately, users with chromium at the bottom (such as electron) can’t get itFloss (free / open source software)permit. Source:0 1 2

Technical details

Tauri has five main components

  • Node.js cli for creating, developing and building applications
  • Rust core, which is used to bind to the underlying WebView and provide an API for rocking tree optimization
  • Rust bundler is used to make the final binary
  • Rust binding of WebView
  • WebView low level library is used to create and interact with the “native” WebView of the operating system

Currently, the user interface of Tauri application uses cocoa / WebKit on Mac OS, gtk-webkit2 on Linux, and mshtml (ie10 / 11) or WebKit on edge on windows. Tauri works based on MIT license, namely WebView.

Comparison between Tauri and electron

Tauri Electron
Packet size of MacOS 0.6 MB 47.7 MB
Memory consumption of MacOS 13 MB 34.1 MB
Interface service provision Varies Chromium
Background binding Rust Node.js (ECMAScript)
Underlying engine C/C++ V8 (C/C++)
Free / open source software Yes No
Multithreading Yes No
Bytecode delivery Yes No
Pdf can be displayed Yes No
Multi window Soon Yes
GPU access Yes Yes
Auto update Soon Yes (1)
Cross platform Yes Yes
Custom app Icon Yes Yes
Windows package Yes Yes
MacOS package Yes Yes
Linux package Yes Yes
IOS package Soon No
Android package Soon No
Support local web services Yes Yes
There is no local service option Yes No
Desktop file box Soon No


  1. Electron has no local automatic update program on Linux, but it is provided by electronic packer

Environment construction

The following is an example of MacOS. You can view the original document in other environmentsClick here to view

Tauri is a multilingual system, so it needs a lot of tools.

System dependencies:

$ brew install gcc

Download GCC dependencies using brew

Node running environment:

This framework needs more than node 12 environment to run

nvm install 12
nvm use 12

Download node 12 using NVM

Rustc and cargo package management

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

This command requires a ladder to get down. OK
When downloading, just press enter all the way
When finished, close the terminal and open it to view

[email protected] ~ % rustc --version
rustc 1.42.0 (b8cedc004 2020-03-09)

Tauri packaging tool

$ cargo install tauri-bundler --force

It is also recommended to use a ladder to download this command, otherwise it will be slow

So far, the basic environment of this framework has been built

Use (seamless integration into existing projects)

First of all, you need a web project, which can be created by react create app or Vue cli, or any web project

Download Tauri in the project:

yarn add tauri
npm install tauri

After downloading, in the current project directory, use the command

tauri init

After that, a directory will appear under your projectsrc-tauri:
Tauri - a PC side spa framework that can replace electronic

Then modify the file according to the port when your web project startssrc-tauri/tauri.conf.json:

"build": {
    "Distdir": ". / build" // path after packaging
    "devPath": " http://localhost : 8080 ", // this is the URL when dev starts
    "beforeDevCommand": "",
    "beforeBuildCommand": ""

Now start the project:

    "dev": "tauri dev",

The first time it starts, it will be a little slow. To load something, it will be much faster later

Here I leave my demo:



Judging from the above situation, this is indeed a PC framework with greater potential, but now (time point: 2020-04-27) has obvious shortcomings, that is, it is not mature enough
So now the experimental PC project can be used, but if you want to use it in the production environment, you need to wait

Recommended Today

[database] MySQL exercises and answers (educational administration management system)_ MySQL_ 5.7)

✨ statement The answer to the exercise is not guaranteed to be completely correct, which is for reference only MySQL:5.7 Recommended software: Navicat premium Learning SQL statements requires diligent practice! ✨ Field description of each table course CId Course serial number, primary key PCId Prerequisite course DId Opening department number, foreign key CName Course name […]