Back to articles
Tauri v2 Has a Free API — Here's How to Build Cross-Platform Desktop Apps

Tauri v2 Has a Free API — Here's How to Build Cross-Platform Desktop Apps

via Dev.to WebdevAlex Spinov

Tauri v2 lets you build desktop and mobile apps using web technologies with a Rust backend. Apps are tiny (< 5MB), fast, and secure — unlike Electron's 200MB+ bundles. Getting Started npm create tauri-app@latest cd my-app npm install npm run tauri dev Invoke Rust Commands from JavaScript // src-tauri/src/lib.rs #[tauri::command] fn greet ( name : & str ) -> String { format! ( "Hello, {}! You have been greeted from Rust!" , name ) } #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run () { tauri :: Builder :: default () .invoke_handler ( tauri :: generate_handler! [ greet ]) .run ( tauri :: generate_context! ()) .expect ( "error while running tauri application" ); } // Frontend import { invoke } from " @tauri-apps/api/core " ; const greeting = await invoke ( " greet " , { name : " World " }); console . log ( greeting ); // Hello, World! You have been greeted from Rust! File System Access import { readTextFile , writeTextFile , BaseDirectory } from " @tauri-apps/plugin-fs " ; // Rea

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles