$devvkit learn --librarie tauri-guide
Tauri Guide
[rust][desktop][gui]
Rust
Install
cargo install create-tauri-app cargo create-tauri-app my-app
Tauri lets you build desktop apps with a web frontend (React, Vue, Svelte, etc.) and a Rust backend.
Smaller bundle size than Electron (often <5MB vs 100MB+), fewer memory requirements.
Security-first: CSP enforced, no Node.js in renderer, commands must be explicitly exposed.
Setup
Create app— Scaffold a Tauri app.
cargo install create-tauri-app cargo create-tauri-app my-app --template react-ts
Commands
Rust command— Expose function to JS.
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}!", name)
}Register command— In main builder.
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
}Call from JS— Invoke Rust command.
import { invoke } from '@tauri-apps/api/core';
const msg = await invoke('greet', { name: 'World' });Events
Emit event— Send event to JS.
use tauri::Manager;
fn send_event(app: &tauri::AppHandle) {
app.emit("progress", 42).unwrap();
}Listen in JS— Receive Rust events.
import { listen } from '@tauri-apps/api/event';
const unlisten = await listen<number>('progress', (e) => console.log(e.payload));File System
Read file— File system access.
use tauri::api::path;
let config_dir = path::app_config_dir(&config);
let contents = std::fs::read_to_string(config_dir.join("config.json"));Build
Build for production— Create installer.
cargo tauri build