Home Linux Tauri Framework: Build And Package Lightweight Applications

Tauri Framework: Build And Package Lightweight Applications

A Beginners Guide to Create and Package Tauri Apps on Linux.

By sk
416 views 9 mins read

If you're looking for a lightweight, fast, and secure alternative to Electron for building cross-platform desktop applications, the Tauri framework is a great choice. Designed to work seamlessly with web technologies like HTML, CSS, and JavaScript, Tauri allows developers to create native desktop apps while keeping the app size small and performance optimized.

In this guide, we’ll cover everything a beginner needs to know about getting started with Tauri on Linux. You’ll learn:

  • What Tauri is and how it compares to other frameworks like Electron,
  • Key features of Tauri,
  • Step-by-step installation guide for setting up Tauri on a Linux system,
  • How to create and package Tauri apps.

Whether you're a web developer exploring desktop app development or a Linux user looking to build and distribute applications efficiently, this detailed guide will walk you through the steps to build and package apps using Tauri framework on Linux.

Let us get started!

What is Tauri Framework?

Tauri is an opensource framework for building lightweight, secure and fast applications for major desktop and mobile platforms.

It allows developers to use any frontend framework that compiles to HTML, JavaScript, and CSS for the user interface, and languages like Rust, Swift, and Kotlin for backend logic.

Tauri Features

  • Cross-Platform Development: Tauri supports building applications for Linux, macOS, Windows, Android, and iOS from a single codebase.
  • Frontend Independence: Tauri integrates with any framework that compiles to HTML, CSS, and JavaScript. This allows developers to use their existing web stack or start new projects without being restricted to a specific framework.
  • Rust-Powered Backend: Tauri leverages Rust for its backend, which provides performance, security, and access to system-level APIs. Rust is described as suitable for the next generation of applications.
  • Security Focus: Security is a core tenet of the Tauri project. Tauri includes features like permissions, command scopes, capabilities, Content Security Policy (CSP), and HTTP headers. Tauri also undergoes security audits for major and minor releases, covering both the core code and upstream dependencies.
  • Small Binary Size: Tauri apps can achieve smaller binary sizes compared to traditional Electron-based applications by utilising the operating system's native web renderer. A minimal Tauri app can be as small as 600KB.
  • Plugin Architecture: Tauri offers a plugin system to extend core functionality, with plugins developed and maintained by the Tauri team and the community.
  • Inter-Process Communication (IPC): Tauri enables communication between the frontend (JavaScript) and backend (Rust/Swift/Kotlin) components. This allows developers to integrate deeply into the operating system while maintaining a familiar frontend development workflow.

Why Choose Tauri?

  • Secure Foundation: Built on Rust, Tauri benefits from its memory, thread, and type safety.
  • Smaller App Size: By using the system’s native webview, Tauri apps have a smaller bundle size.
  • Flexible Architecture: Tauri is compatible with virtually any frontend framework because it uses web technologies.

TAO (Window creation library) handles Tauri window creation, and WRY (WebView rendering library) renders the web view. These libraries are maintained by Tauri and can be used directly for deeper system integration.

Comparison with Electron

FeatureTauriElectron
SizeSmaller (Few MBs)Large (~100MB)
PerformanceFaster, lower memory usageSlower, higher memory usage
SecurityMore secure (Rust-based, restricted API access)Less secure (Node.js APIs)
BackendRustNode.js
RenderingSystem WebViewBundled Chromium

Use Cases

  • Building lightweight desktop applications,
  • Converting web apps into native apps,
  • Applications requiring better security and performance than Electron.

Install Tauri Framework in Linux

To install Tauri on Linux, you need to install a few dependencies and Rust. Node.js is required if you intend to use a JavaScript frontend framework.

Prerequisites

Tauri requires various system dependencies for development on Linux, which may vary depending on your distribution.

If you're on Alpine Linux, install the following prerequisites:

sudo apk add \
  build-base \
  webkit2gtk \
  curl \
  wget \
  file \
  openssl \
  libayatana-appindicator-dev \
  librsvg

Arch Linux:

sudo pacman -Syu
sudo pacman -S --needed \
  webkit2gtk-4.1 \
  base-devel \
  curl \
  wget \
  file \
  openssl \
  appmenu-gtk-module \
  libappindicator-gtk3 \
  librsvg

On Debian:

sudo apt update
sudo apt install libwebkit2gtk-4.1-dev \
  build-essential \
  curl \
  wget \
  file \
  libxdo-dev \
  libssl-dev \
  libayatana-appindicator3-dev \
  librsvg2-dev

Fedora:

sudo dnf check-update
sudo dnf install webkit2gtk4.1-devel \
  openssl-devel \
  curl \
  wget \
  file \
  libappindicator-gtk3-devel \
  librsvg2-devel
sudo dnf group install "c-development"

Gentoo:

sudo emerge --ask \
  net-libs/webkit-gtk:4.1 \
  dev-libs/libappindicator \
  net-misc/curl \
  net-misc/wget \
  sys-apps/file

openSUSE:

sudo zypper up
sudo zypper in webkit2gtk3-devel \
  libopenssl-devel \
  curl \
  wget \
  file \
  libappindicator3-1 \
  librsvg-devel
sudo zypper in -t pattern devel_basis

NixOS:

let
  pkgs = import <nixpkgs> { };
in
pkgs.mkShell {
  nativeBuildInputs = with pkgs; [
    pkg-config
    gobject-introspection
    cargo
    cargo-tauri
    nodejs
  ];

  buildInputs = with pkgs;[
    at-spi2-atk
    atkmm
    cairo
    gdk-pixbuf
    glib
    gtk3
    harfbuzz
    librsvg
    libsoup_3
    pango
    webkitgtk_4_1
    openssl
  ];
}

This will install tauri along with Rust and Node.js, so you can skip the following steps.

Install Rust Programming Language

Tauri’s backend is written in Rust, so you need to install Rust and Cargo (Rust’s package manager).

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

To verify the installation:

rustc --version
cargo --version

It is advisable to examine the script before execution. After the installation is complete, be sure to restart your Terminal (and in some cases your system) for the changes to take effect.

Install Node.js (Optional)

If you plan to use a JavaScript frontend framework, download and install Node.js Long Term Support (LTS) version.

To install Node.js (Recommended Version 18 or later), run the following commands one by one.

curl -fsSL https://fnm.vercel.app/install | bash
source ~/.bashrc
fnm install 18
fnm use 18

After installation, verify it by running the following commands in your terminal:

node -v
npm -v

Restart your terminal after installing Node.js.

Build and Package Lightweight Applications with Tauri Framework

Now, we have Tauri installed on our system. Let us move on and build a Tauri app on Linux.

The recommended way to create a new Tauri project is using the create-tauri-app tool, which can be invoked via various package managers or directly using shell commands.

Step 1: Install System Dependencies

Make sure you have installed the necessary dependencies on your system. If not, go back to the Prerequisites section and install the necessary dependencies based on your OS version.

Step 2: Create a New Tauri Project

Now, create a project directory for your Tauri app.

npm create tauri-app@latest my-tauri-app
cd my-tauri-app

During setup, it will ask:

  • Choose a package manager: npm, yarn, or pnpm (choose one)
  • Choose a frontend framework: React, Vue, Svelte, Solid, or vanilla HTML/CSS/JS

If you don't know which option to choose, just go with the defaults.

Sample Output:

Need to install the following packages:
create-tauri-app@4.5.9
Ok to proceed? (y) y


> npx
> create-tauri-app my-tauri-app

✔ Identifier · com.my-tauri-app.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)
✔ Choose your package manager · npm
✔ Choose your UI template · Vanilla
✔ Choose your UI flavor · TypeScript

Template created! To get started run:
cd my-tauri-app
npm install
npm run tauri android init

For Desktop development, run:
npm run tauri dev

For Android development, run:
npm run tauri android dev

npm notice
npm notice New major version of npm available! 10.9.2 -> 11.1.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.1.0
npm notice To update run: npm install -g npm@11.1.0
npm notice

If you already have a web app, you can integrate Tauri into it instead.

Step 3: Run the Tauri App

Navigate into the project directory and run:

npm install
npm run tauri dev

This starts the Tauri development server. It will build and launch the app in a native window.

Run Tauri App
Run Tauri App

If you see the above window, it means that app is ready. Close the window and move on to the next step.

Step 4: Build the Tauri App

Once development is complete, you can build the app into a distributable binary.

npm run tauri build

The built app will be found in:

src-tauri/target/release/

Please be patient! This will take a few minutes to complete.

Tauri will automatically build and generate binaries (.AppImage, .deb, and .rpm) in src-tauri/target/release/bundle/ directory:

ls src-tauri/target/release/bundle/
appimage  deb  rpm

Go to each directory and install the respective package using the default package manager on your system.

Step 5: Install and Test the Tauri Apps

1. Install and Test .deb Package:

For example, if you want to test the .deb package, you can do:

sudo dpkg -i src-tauri/target/release/bundle/deb/my-tauri-app_0.1.0_amd64.deb

If dependencies are missing, fix them with:

sudo apt-get install -f

You can now launch the app from the Application launcher or Menu.

Launch Tauri App
Launch Tauri App

Click on the tauri app to launch it. This will open the newly built Tauri app.

Run Tauri App
Run Tauri App

If the .deb package does not install correctly, check dependencies using:

dpkg -I my-tauri-app_0.1.0_amd64.deb

Similarly, you can launch the other binaries, for example .rpm and .AppImage.

2. Install and Test .AppImage Package:

The .AppImage is portable and works on most Linux distributions.

Your .AppImage file will be located in:

src-tauri/target/release/bundle/appimage/

To run it:

chmod +x my-tauri-app.AppImage
./my-tauri-app.AppImage

Replace my-tauri-app.AppImage with your own.

If the .AppImage does not run, check dependencies with:

ldd my-tauri-app.AppImage

3. Install and Test .rpm Package:

To install the .rpm package on Fedora or RHEL-based systems:

sudo rpm -i src-tauri/target/release/bundle/rpm/my-tauri-app-0.1.0-1.x86_64.rpm

If any dependencies are missing, install them with:

sudo dnf install -y src-tauri/target/release/bundle/rpm/my-tauri-app-0.1.0-1.x86_64.rpm

To verify installation:

rpm -q my-tauri-app

To uninstall:

sudo rpm -e my-tauri-app

The .rpm package is useful for Fedora, RHEL, CentOS, openSUSE, and similar distributions. If the package does not install correctly, check dependencies with:

rpm -qpR my-tauri-app-0.1.0-1.x86_64.rpm

Configure Tauri Settings

Tauri uses tauri.conf.json to define how it builds packages.

Open the file inside src-tauri/ and edit:

"tauri": {
  "bundle": {
    "identifier": "com.example.mytauriapp",
    "icon": [
      "icons/32x32.png",
      "icons/128x128.png",
      "icons/512x512.png"
    ],
    "resources": [],
    "deb": {
      "depends": ["libwebkit2gtk-4.0-37", "libgtk-3-0"]
    },
    "appimage": {
      "bundle": true
    }
  }
}
  • Replace com.example.mytauriapp with your app’s unique identifier.
  • Ensure icons are placed in src-tauri/icons/.

Once you have made necessary changes, run the following command to build your app:

npm run tauri build

or

cargo tauri build --release

This will generate binaries in:

src-tauri/target/release/

Additional Tips

  • If using another frontend framework, replace react in npm create tauri-app@latest with vue, svelte, etc.
  • Use cargo tauri build --release for optimized production builds.

Conclusion

Tauri is a powerful and lightweight alternative to Electron for building cross-platform desktop applications using web technologies and Rust.

In this guide, we covered everything a beginner need to know to get started with Tauri on Linux, from installation to packaging the apps as .deb and .rpm files for easy distribution.

Using Tauri, you can easily create fast and optimized desktop applications for Linux, Windows, and macOS.

Whether you’re a beginner or an experienced developer looking for a modern desktop framework, Tauri provides an excellent foundation for building efficient and scalable apps.

Now that you’ve learned the basics, the next step is to experiment, build, and refine your Tauri applications. Good luck!

Resources:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More