How to build secure, lightweight standalone desktop apps with Tauri

Introduction

Tauri is a modern framework for building lightweight, secure desktop applications using web technologies for the frontend and Rust for the backend. Compared to Electron, Tauri apps are smaller and faster because they use the system’s native WebView instead of bundling Chromium.

Requirements

Before creating a Tauri app, install the following tools:

  • Node.js and npm or yarn
  • Rust and Cargo (via rustup)
  • Cargo prerequisites: CMake, Ninja, and a C++ build toolchain
  • Platform specific tools:
    • Windows: Visual Studio Build Tools with Desktop development workload
    • Linux: libgtk-3-dev, libwebkit2gtk, cmake, ninja-build
    • macOS: Xcode Command Line Tools, cmake, ninja

Install Rust

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

Create a Frontend Project

You can use Vite or React as the frontend. For example, with Vite:

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

Add Tauri

Initialize Tauri inside your project:

npm install @tauri-apps/cli @tauri-apps/api
npx tauri init

Tauri Configuration File

The file src-tauri/tauri.conf.json defines app settings. Example:

{
  "package": {
    "productName": "MyTauriApp",
    "version": "0.1.0"
  },
  "tauri": {
    "windows": [
      {
        "title": "My Tauri App",
        "width": 800,
        "height": 600
      }
    ]
  }
}

Rust Backend Example

Inside src-tauri/src/main.rs, you can define commands:

#![cfg_attr(
  all(not(debug_assertions), target_os = "windows"),
  windows_subsystem = "windows"
)]

#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}!", name)
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running Tauri application");
}

Frontend Call to Rust

In your React or Vite frontend, call the Rust function:

import { invoke } from '@tauri-apps/api/tauri'

async function greetUser() {
  const message = await invoke("greet", { name: "Mirza" })
  console.log(message)
}

Run the App

npm run tauri dev

Build a Standalone Executable

npm run tauri build

This generates platform-specific binaries inside the src-tauri/target/release folder.

Conclusion

Tauri combines the flexibility of web technologies with the performance of Rust. By installing the required dependencies, configuring tauri.conf.json, and writing Rust commands, you can build secure, lightweight standalone desktop apps for Windows, Linux, and macOS.