Desktop apps with Tauri

I'm always looking for better ways to create desktop applications. See here.

Now, the easiest way to compose UIs is HTML and CSS, because it is used everywhere. And it would be great if it could be used to create desktop apps, right?

"Ah, there's Electron!" you might say. And yes, you are right. Electron exists.

However, I'm not exactly a fan of it, mainly because of the resulting executable file size (>100mb), but also of security things..I'm sure the browser of most electron apps are never updated and are target to hackers (see: WhatsApp Desktop patches major security vulnerability). People call it the "flash for desktop" for a reason.

Now there's Tauri: It just uses the operating system's browser and a webview to display content. Looks like a good option to me. Okay, you are limited to IE 10 (worst case) on Windows. But beside that it looks super-promising imo:

The user interface in Tauri apps currently leverages Cocoa/WebKit on macOS, gtk-webkit2 on Linux and MSHTML (IE10/11) or Webkit via Edge on Windows.

1. Build

One (small) downside: You need to install a lot of dependencies. It's documented quite well, but you need to do it for each operating system of course.

1.1. Linux

I've written a small docker image for builds on linux (see below), because I don't like to pollute my system with thousands of dependencies, and the resulting binary is executable without the dev-dependencies.

I've ran tauri init once in the app directory, and now I can use this:

docker run -it --rm -v $(pwd):/root/app tauri tauri build

1.2. Windows

Aha! Windows. You have to install the world. Prepare to spend some time on installing the prerequisites.

I've started on a clean Win7 box and had to install this:

Now, in the project directory, run the normal build

And boom, you get a .exe file in the src-tauri/target/release folder.
Unfortunately I had an issue to execute the file, see this issue.


2. Result

My test app loaded quickly and behaved just as the browser version.

ldd src-tauri/target/release/app ``` $ ldd src-tauri/target/release/app (0x00007fff7cac0000) => /usr/lib/ (0x00007f1444a74000) => /usr/lib/ (0x00007f1444392000) => /usr/lib/ (0x00007f1444299000) => /usr/lib/ (0x00007f1442c77000) => /usr/lib/ (0x00007f1442c1b000) => /usr/lib/ (0x00007f1442af6000) => /usr/lib/ (0x00007f1442aef000) => /usr/lib/ (0x00007f1442acd000) => /usr/lib/ (0x00007f1442ab3000) => /usr/lib/ (0x00007f14428ec000) /lib64/ => /usr/lib64/ (0x00007f1447fd2000) => /usr/lib/ (0x00007f14427a6000) => /usr/lib/ (0x00007f1442720000) => /usr/lib/ (0x00007f144270d000) => /usr/lib/ (0x00007f1442702000) => /usr/lib/ (0x00007f14426e8000) => /usr/lib/ (0x00007f144269a000) => /usr/lib/ (0x00007f1442596000) => /usr/lib/ (0x00007f144256d000) => /usr/lib/ (0x00007f1442447000) => /usr/lib/ (0x00007f1442421000) => /usr/lib/ (0x00007f1442271000) => /usr/lib/ (0x00007f1442267000) => /usr/lib/ (0x00007f1442258000) => /usr/lib/ (0x00007f144224e000) => /usr/lib/ (0x00007f14420e6000) => /usr/lib/ (0x00007f14420a5000) => /usr/lib/ (0x00007f1441f74000) => /usr/lib/ (0x00007f1441c80000) => /usr/lib/ (0x00007f1441a9e000) => /usr/lib/ (0x00007f1441893000) => /usr/lib/ (0x00007f144184a000) => /usr/lib/ (0x00007f144177c000) => /usr/lib/ (0x00007f1441777000) => /usr/lib/ (0x00007f1441659000) => /usr/lib/ (0x00007f1441649000) => /usr/lib/ (0x00007f14415d9000) => /usr/lib/ (0x00007f14414c9000) => /usr/lib/ (0x00007f1441493000) => /usr/lib/ (0x00007f1441421000) => /usr/lib/ (0x00007f14413e7000) => /usr/lib/ (0x00007f1441346000) => /usr/lib/ (0x00007f14412da000) => /usr/lib/ (0x00007f14412ce000) => /usr/lib/ (0x00007f1441237000) => /usr/lib/ (0x00007f14411ff000) => /usr/lib/ (0x00007f14411a2000) => /usr/lib/ (0x00007f1441132000) => /usr/lib/ (0x00007f144112c000) => /usr/lib/ (0x00007f1441091000) => /usr/lib/ (0x00007f1441084000) => /usr/lib/ (0x00007f144107f000) => /usr/lib/ (0x00007f1441036000) => /usr/lib/ (0x00007f1440fd4000) => /usr/lib/ (0x00007f1440fbe000) => /usr/lib/ (0x00007f1440db6000) => /usr/lib/ (0x00007f1440c76000) => /usr/lib/ (0x00007f1440c71000) => /usr/lib/ (0x00007f1440c6c000) => /usr/lib/ (0x00007f1440c56000) => /usr/lib/ (0x00007f1440c51000) => /usr/lib/ (0x00007f1440c3f000) => /usr/lib/ (0x00007f1440a55000) => /usr/lib/ (0x00007f1440a45000) => /usr/lib/ (0x00007f1440a2e000) => /usr/lib/ (0x00007f1440a10000) => /usr/lib/ (0x00007f1440a02000) => /usr/lib/ (0x00007f14408d7000) => /usr/lib/ (0x00007f14408c4000) => /usr/lib/ (0x00007f1440890000) => /usr/lib/ (0x00007f1440887000) => /usr/lib/ (0x00007f1440846000) => /usr/lib/ (0x00007f144083b000) => /usr/lib/ (0x00007f1440826000) => /usr/lib/ (0x00007f144081a000) => /usr/lib/ (0x00007f144080d000) => /usr/lib/ (0x00007f1440808000) => /usr/lib/ (0x00007f14407fb000) => /usr/lib/ (0x00007f1440788000) => /usr/lib/ (0x00007f14406d1000) => /usr/lib/ (0x00007f144069e000) => /usr/lib/ (0x00007f1440693000) => /usr/lib/ (0x00007f144066c000) => /usr/lib/ (0x00007f14405c2000) => /usr/lib/ (0x00007f14405bd000) => /usr/lib/ (0x00007f1440593000) => /usr/lib/ (0x00007f1440583000) => /usr/lib/ (0x00007f1440576000) => /usr/lib/ (0x00007f1440517000) => /usr/lib/ (0x00007f14404fe000) => /usr/lib/ (0x00007f14404d6000) => /usr/lib/ (0x00007f143ea25000) => /usr/lib/ (0x00007f143e822000) => /usr/lib/ (0x00007f143e812000) => /usr/lib/ (0x00007f143e7e2000) => /usr/lib/ (0x00007f143e7d9000) => /usr/lib/ (0x00007f143e7c6000) => /usr/lib/ (0x00007f143e7a3000) => /usr/lib/ (0x00007f143e787000) => /usr/lib/ (0x00007f143e733000) => /usr/lib/ (0x00007f143e6b1000) => /usr/lib/ (0x00007f143e6ab000) => /usr/lib/ (0x00007f143e6a6000) => /usr/lib/ (0x00007f143e697000) => /usr/lib/ (0x00007f143e682000) => /usr/lib/ (0x00007f143e671000) => /usr/lib/ (0x00007f143e621000) => /usr/lib/ (0x00007f143e60e000) => /usr/lib/ (0x00007f143e5c2000) => /usr/lib/ (0x00007f143e58b000) => /usr/lib/ (0x00007f143e384000) => /usr/lib/ (0x00007f143e37f000) => /usr/lib/ (0x00007f143e377000) => /usr/lib/ (0x00007f143e324000) => /usr/lib/ (0x00007f143e301000) => /usr/lib/ (0x00007f143e2e7000) => /usr/lib/ (0x00007f143e2bd000) => /usr/lib/ (0x00007f143e1d0000) => /usr/lib/ (0x00007f143e19a000) => /usr/lib/ (0x00007f143e194000) => /usr/lib/ (0x00007f143e185000) => /usr/lib/ (0x00007f143e17e000) => /usr/lib/ (0x00007f143dffc000) => /usr/lib/ (0x00007f143dfdb000) => /usr/lib/ (0x00007f143df32000) => /usr/lib/ (0x00007f143df10000) ```

File size is 6.6 MB.


3. Dockerfile

FROM ubuntu:19.10

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Berlin

# Dev tools
RUN apt-get update && apt-get install -y libwebkit2gtk-4.0-dev build-essential curl libssl-dev gnupg

# Node
RUN curl -sL | bash -
RUN apt-get -y install nodejs

# Rust
RUN curl --proto '=https' --tlsv1.2 -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Tauri
RUN cargo install tauri-bundler --force
RUN cargo install tauri-cli --force

RUN npm install --unsafe-perm -g tauri

WORKDIR /root/app
docker build -t tauri .

Note on the Dockerfile: I hate the way you have to install node and rust. Running scripts from the web. :/ This should be discouraged.

Tauri at least warns about it in their documentation:

We have audited this bash script, and it does what it says it is supposed to do. Nevertheless, before blindly curl-bashing a script, it is always wise to look at it first.

Their reasoning is pretty...naive at least. They've audited the script once? And now they believe it never changes / cannot be changed afterwards?! ... :(