DEV Community

rerere L.
rerere L.

Posted on • Originally published at autognosi.Medium on

Typst Studio Desktop: 90% Smaller, 100% Native, Same WASM Codebase, with Tauri


Image by Author with ideogram.ai

1. The Tauri Revolution: From Electron to Native Performance

The desktop application landscape has undergone profound transformation over the past five years, driven largely by Tauri’s emergence as a viable alternative to Electron’s long-standing dominance. Since its stable 1.0 release in June 2022 and subsequent Tauri 2.0 in late 2024, this Rust-powered framework has challenged fundamental assumptions about cross-platform desktop development, demonstrating that native performance and minimal resource consumption need not require abandoning web technologies or familiar development workflows. The implications extend far beyond mere technical preference; Tauri represents a paradigm shift toward truly native desktop experiences built with modern web frontend tools.

Electron revolutionized desktop development in 2013 by enabling web developers to create cross-platform applications using familiar JavaScript, HTML, and CSS. Applications like Slack, Visual Studio Code, Discord, and Microsoft Teams proved the model’s viability, spawning an entire generation of desktop software. However, this convenience came with substantial costs: every Electron application bundles a complete Chromium browser (~80MB) plus Node.js runtime (~40MB), resulting in baseline installers of 120–150MB before adding any application code. Memory consumption similarly suffers, with typical Electron apps consuming 300–500MB RAM at idle and multiple renderer processes multiplying overhead for multi-window applications.

Tauri’s architectural approach fundamentally diverges by leveraging the operating system’s native WebView rather than bundling Chromium. On Windows, this means WebView2 (Edge-based); on macOS, WKWebView (Safari-based); on Linux, WebKitGTK. This architectural decision yields immediate benefits: Tauri installers measure 3–15MB depending on application complexity — a 97% size reduction compared to equivalent Electron apps. The WebView already exists on users’ systems, maintained and updated by the OS vendor, eliminating redundant browser engines and dramatically reducing distribution sizes.

Memory efficiency shows equally impressive improvements. Real-world measurements demonstrate Tauri applications consuming 30–40MB RAM at idle versus 300–500MB for Electron equivalents — an 85–90% reduction. This efficiency stems from sharing the system WebView across applications and Rust’s zero-cost abstractions that compile to lean native code without garbage collection overhead. For users keeping applications open throughout workdays, these differences translate to tangible improvements in system responsiveness, battery life, and ability to run multiple applications simultaneously on modest hardware.

Startup performance benefits from both smaller binary sizes and native compilation. Tauri applications consistently launch in under 500 milliseconds on mid-range hardware, while Electron apps average 1–2 seconds for similar functionality. This responsiveness matters particularly for tools users invoke frequently — terminal emulators, note-taking apps, password managers — where launch latency directly impacts workflow efficiency. The difference stems from Tauri’s native binary loading nearly instantaneously versus Electron’s requirement to initialize Node.js, parse JavaScript, and bootstrap Chromium before displaying UI.

The security model deserves careful examination given desktop applications’ privileged access to user systems. Electron’s security relies on proper configuration of numerous flags and careful API usage, with many applications historically shipping insecure defaults. The Chromium content process runs with significant privileges, and Node.js integration provides direct file system access and native module loading that malicious code can exploit. Developers must explicitly opt into context isolation, nodeIntegration: false, and sandbox: true — settings often neglected in practice.

Tauri implements security-by-default through Rust’s memory safety guarantees and explicit capability-based permissions. The Rust backend cannot experience memory corruption vulnerabilities like buffer overflows or use-after-free errors that plague C/C++ and compromise JavaScript runtimes. Every API access requires explicit declaration in tauri.conf.json — file system operations, HTTP requests, shell commands, notifications — with granular scopes limiting what paths or resources the application can access. An application cannot read arbitrary files unless specifically granted that capability at build time, providing audit-friendly permission manifests and reducing attack surfaces.

Industry adoption validates Tauri’s maturity beyond early adopters. TablePlus, a popular database management tool, migrated from Electron and reported 92% smaller installers (18MB vs 250MB) while improving query performance through Rust’s async runtime. Clash for Windows, a proxy client with millions of users, switched to Tauri and achieved startup times under 300ms versus Electron’s multi-second launches. Warp, the AI-powered terminal that raised $23M in funding, built entirely on Tauri to deliver GPU-accelerated rendering and sub-frame input latency impossible in Electron. Logseq, the knowledge graph note-taking app, developed both Electron and Tauri versions, with users consistently preferring Tauri’s responsiveness and battery efficiency.

The ecosystem maturity reached critical mass with Tauri 2.0’s December 2024 release, introducing mobile platform support (iOS/Android), multiwebview capabilities for complex applications, enhanced plugin architecture, and improved IPC performance. The framework now supports nearly every use case previously requiring Electron, with comprehensive documentation, active community support (17,700+ Discord members), and production deployments from startups to enterprises. This maturity makes Tauri not merely a technical curiosity but a pragmatic choice for new desktop projects and serious consideration for migrating existing Electron applications.

The trade-offs merit acknowledgment for balanced evaluation. Tauri’s reliance on system WebViews means behavioral differences across platforms — CSS rendering quirks between WebKit and Blink, JavaScript feature availability variations, and potential bugs in underlying platform implementations. Electron’s bundled Chromium guarantees pixel-perfect consistency regardless of OS, valuable for applications requiring identical appearance everywhere. Additionally, Tauri requires Rust knowledge for backend development, whereas Electron allows pure JavaScript/TypeScript throughout. However, for performance-critical applications, tools users keep running continuously, or scenarios where bundle size matters (bandwidth-constrained regions, frequent updates), Tauri’s advantages clearly outweigh these considerations.

repository: https://github.com/automataIA/wasm-typst-studio-rs

2. Rust-Powered Architecture: Zero Runtime Overhead

Understanding Tauri’s exceptional performance characteristics requires examining its architectural foundations built entirely in Rust with careful separation between native backend logic and web-based frontend presentation. Unlike Electron’s unified JavaScript environment where Node.js and browser contexts share memory and execution models, Tauri implements a strict boundary between Rust backend handling system operations and web frontend managing UI presentation. This separation enables optimal technology choices for each concern while maintaining type-safe communication through modern Inter-Process Communication (IPC) mechanisms.

The Rust backend compiles to native machine code specific to each platform — x86_64/ARM64 on Windows, x86_64/ARM64 on macOS, x86_64/ARM64 on Linux — with zero runtime overhead from interpreters or virtual machines. When users launch a Tauri application, the operating system loads a standard native executable indistinguishable from applications written in C++ or Swift. There’s no Node.js initialization, no V8 engine startup, no JavaScript parsing delay — just immediate execution of optimized native code produced by LLVM’s aggressive optimization passes. This fundamental difference explains Tauri’s sub-500ms startup times versus Electron’s 1–2 second launches.

Rust’s safety guarantees provide security benefits extending beyond marketing claims into concrete vulnerability prevention. The ownership system tracks every memory allocation and ensures exactly one owner exists at any moment, preventing use-after-free errors that constitute significant fractions of security vulnerabilities in C/C++ software. The borrowing checker verifies at compile time that references remain valid throughout their lifetimes, eliminating dangling pointers and null pointer dereferences that crash applications or enable exploitation. For desktop software with elevated privileges accessing sensitive user data, these compile-time guarantees provide foundational security that runtime checks in garbage-collected languages cannot match.

The frontend flexibility proves particularly valuable, enabling developers to use preferred modern frameworks without abandoning familiar tools. Tauri officially supports React, Vue.js, Svelte, SolidJS, Angular, and Preact through standard web development workflows — create-react-app, Vue CLI, Vite, or custom webpack configurations. The framework makes no assumptions about frontend implementation; any technology producing HTML/CSS/JavaScript that runs in browsers works seamlessly in Tauri’s WebView. This architecture future-proofs applications against framework churn, as frontend technology choices remain independent of desktop integration.

For developers embracing Rust throughout the stack, frameworks like Leptos, Yew, and Dioxus enable 100% Rust applications where frontend compiles to WebAssembly. This approach eliminates JavaScript entirely, providing type safety spanning backend and frontend, shared data structures without serialization overhead, and optimal performance from WebAssembly’s near-native execution. Leptos particularly shines with fine-grained reactivity that updates precisely affected DOM nodes without virtual DOM diffing, often outperforming React/Vue while consuming less memory. The ability to share Rust types and logic between frontend and backend reduces duplication and maintains consistency across the application boundary.

The IPC mechanism deserves detailed examination as it handles all communication between web frontend and Rust backend. Tauri 2.0 implements multiple IPC channels optimized for different use cases. The primary mechanism uses command invocation where frontend JavaScript calls Rust functions exposed through the #[tauri::command] attribute. These invocations serialize arguments as JSON, transmit through secure channels, execute in Rust with type validation, and return results to JavaScript—all with automatic type conversion and error handling. For performance-critical scenarios, Tauri provides binary channels bypassing JSON serialization for raw buffer transfers, enabling efficient image processing, video manipulation, or large dataset handling.

Event streams complement command invocations for push-style communication. Backend Rust code emits typed events that frontend listeners receive, enabling reactive architectures where UI updates automatically when backend state changes. This pattern works elegantly for progress indicators during long operations, real-time collaboration features, or system notifications triggering UI updates. Unlike Electron’s IPC which suffers from context bridge overhead and serialization bottlenecks, Tauri’s implementation leverages modern browser APIs and zero-copy optimizations where possible, achieving throughput exceeding 100,000 messages/second for small payloads.

The plugin ecosystem extends Tauri’s core capabilities through well-defined interfaces. Official plugins provide file system access (read/write files, directory traversal, file watching), HTTP client (make requests with progress tracking), notifications (system-native alerts), dialog (native file/folder pickers), clipboard (read/write clipboard), window management (multiple windows, positioning, state), and updater (automatic application updates). Each plugin follows capability-based security requiring explicit declaration in tauri.conf.json, with granular permissions controlling exactly what operations applications can perform. For example, file system access requires specifying allowed directories, preventing applications from reading arbitrary system files.

Custom plugins enable extending functionality for specific requirements. The plugin architecture provides lifecycle hooks for initialization/shutdown, command registration for exposing Rust functions, event emission for pushing data to frontend, and state management for maintaining plugin data. Developers can create plugins wrapping native platform APIs (macOS Keychain, Windows Credential Manager, Linux Secret Service), third-party libraries (database drivers, encryption tools, media codecs), or hardware access (USB devices, Bluetooth, serial ports). The ecosystem includes community plugins for database access, biometric authentication, custom protocol handlers, and system tray management, with active development of new capabilities.

The build system orchestrates compilation of both Rust backend and web frontend into unified distributable packages. During development, cargo tauri dev launches a hot-reloading environment where frontend changes refresh instantly in the WebView while Rust modifications trigger automatic recompilation with incremental builds minimizing wait times. The development experience matches modern web development workflows—edit code, see changes immediately—but with native desktop capabilities readily available. For production, cargo tauri build compiles optimized release builds with maximum optimization levels, link-time optimization (LTO) across all crates, debug symbol stripping, and platform-specific optimizations, generating minimal installers ready for distribution.

Cross-compilation capabilities allow building for multiple platforms from single development machines where feasible. Linux developers can target multiple Linux distributions (Ubuntu, Debian, Fedora, Arch) producing DEB, RPM, and AppImage packages from one command. While cross-compiling for macOS and Windows from Linux remains challenging due to platform-specific toolchain requirements, CI/CD pipelines using GitHub Actions or GitLab CI can build all platforms in parallel, with matrix configurations handling platform-specific build steps. This automation ensures consistent builds across Windows NSIS installers, macOS DMG bundles, and Linux distribution packages.

3. Practical Case: Typst Studio Desktop — Single Codebase, Dual Deployment

Typst Studio exemplifies the compelling value proposition of modern desktop application architecture by maintaining a single Leptos frontend codebase that deploys both as pure web application accessible via URLs and native desktop application distributed through platform-specific installers. This dual-deployment approach eliminates the traditional dilemma forcing teams to choose between web’s universal accessibility and desktop’s native capabilities — Typst Studio delivers both from identical source code, with desktop deployment adding native features without fragmenting the codebase or duplicating development efforts.

The architectural foundation builds on Leptos 0.8 configured for Client-Side Rendering (CSR) where the entire application compiles to WebAssembly and executes locally in users’ browsers or Tauri’s WebView. This CSR architecture enables identical behavior across deployment targets: the same WASM binary, same reactive components, same state management logic, same UI rendering code. The Rust codebase under src/ knows nothing about deployment context; whether running in Chrome via trunk serve or native desktop via Tauri makes no difference to application logic. This architectural purity simplifies maintenance, reduces testing burden, and ensures feature parity across platforms.

The Tauri integration adds a minimal src-tauri/ directory containing platform-specific configuration and optional enhanced capabilities. The tauri.conf.json defines application metadata (name, version, description), window properties (dimensions, resizability, minimum sizes), bundle settings (icons, installers formats, permissions), and security configurations (allowed APIs, CSP policies). The src-tauri/src/lib.rs implements the Tauri application entry point, which in its simplest form requires merely tauri::Builder::default().run() to wrap the web frontend in a native window. This minimal surface area means desktop deployment adds under 100 lines of configuration and boilerplate code—the entire desktop application exists as a thin wrapper around the web frontend.

Size optimization demonstrates Tauri’s efficiency converting 73MB web bundles to 5–10MB desktop installers — a 90–93% size reduction. This dramatic improvement stems from multiple factors. The web deployment bundles the full WASM binary (22MB after wasm-opt optimization) plus assets and HTML, totaling approximately 25MB uncompressed. Browser caching and compression (brotli) reduce effective download to 8–12MB, but the uncompressed size remains 25MB. Desktop deployment benefits from Tauri’s architecture: the WebView handles loading and running WASM efficiently, while the Rust backend compiles to 5–8MB native binary depending on platform. The WebView itself doesn’t count toward application size as it’s a system component, so the final installer contains only the Rust binary plus WASM bundle, compressed into platform-specific packages.

Platform-specific optimizations further reduce sizes. Windows NSIS installers use LZMA compression achieving 70–80% compression ratios, bringing installers to approximately 5MB despite containing both native binary and WASM. The installer optionally downloads WebView2 through a bootstrap installer rather than bundling it (~118MB saved), assuming users either have WebView2 already (Windows 11 includes it by default) or accept a one-time download. Linux AppImage bundles benefit from not including system libraries (WebKitGTK) that users install through package managers, resulting in 10–15MB portable executables. Linux DEB packages are even smaller (3–8MB) as they declare system dependencies handled by apt/dpkg. macOS DMG bundles for universal binaries (ARM64 + x86_64) measure 12–18MB, or 6–10MB for single-architecture builds.

The enhanced capabilities desktop deployment enables extend beyond just packaging differences. Through Tauri’s plugin APIs, Typst Studio Desktop can implement native file dialogs allowing users to open/save documents through familiar OS file pickers rather than HTML file inputs with limited capabilities. Direct file system access enables reading recently opened files, implementing file watchers that detect external modifications, and writing temporary files for compilation processes. System integration possibilities include file type associations (.typ files open in Typst Studio), context menu entries, Quick Look previews on macOS, thumbnail generation, and system tray icons for background operation.

For scientific users, these native capabilities prove particularly valuable. Researchers working with large bibliographies stored in BibTeX or Hayagriva format can configure automatic imports from filesystem paths, with live updates as reference managers modify bibliography files. Template systems can reference common headers, footers, or style sheets from filesystem locations shared across multiple documents. Output files can write directly to project directories with proper permission prompts rather than forcing downloads to browser’s designated folder. These seemingly small conveniences compound into significant workflow improvements for users creating dozens of documents.

The development workflow maintains the excellent hot-reload experience of modern web development while adding desktop testing capabilities. Developers run cargo tauri dev, which launches trunk serve in the background, compiles the Rust backend, and opens a native window displaying the application. Modifying Leptos components or Rust frontend code triggers instant browser-style hot reloading through WebSocket-based refresh. Changing Tauri backend code or configuration recompiles the Rust binary and automatically restarts the application, preserving frontend state where possible. This workflow enables iterating on native features without sacrificing the rapid development cycle web developers expect.

Cross-platform builds from a single codebase work seamlessly once platform-specific toolchains install. On macOS, cargo tauri build produces DMG installers for both ARM64 and x86_64, or universal binaries containing both architectures. On Windows, the same command generates NSIS installers (.exe) and optionally MSI installers for enterprise deployment. On Linux, developers choose target formats through --bundles deb,appimage,rpm flags, producing multiple installer types from one build command. The build process handles platform-specific details—code signing certificates, notarization for macOS, icon generation for different resolutions—through configuration rather than platform-specific code paths.

Testing strategies benefit from the dual deployment. Web deployment allows testing in multiple browsers (Chrome, Firefox, Safari, Edge) to validate WebAssembly compatibility and rendering consistency. Desktop testing validates native integrations — file dialogs, system tray, window management, auto-updates — that don’t exist in web context. However, the core application logic tests once through normal Rust unit tests and Leptos component tests, as behavior remains identical across deployments. This separation of concerns means the majority of code requires no platform-specific testing, with desktop-specific tests covering only the thin integration layer.

The update strategy differs dramatically between deployments. Web deployment inherently provides instant updates — users accessing the URL receive the latest version automatically without intervention. Desktop applications require distribution of new installers and users manually downloading/installing updates. Tauri’s built-in updater plugin solves this through background update checking, delta updates downloading only changed files, cryptographic signature verification ensuring updates come from legitimate sources, and seamless installation prompting users when updates complete downloading. This automated updating restores web deployment’s convenience while maintaining desktop’s offline functionality and native capabilities.

4. Distribution and Deployment: Modern Desktop App Strategies

Desktop application distribution fundamentals have evolved dramatically in recent years, with Tauri embracing modern approaches that balance user convenience, security, and developer control. Unlike web deployments’ simplicity of updating production servers, desktop distribution requires creating platform-specific installers, establishing update mechanisms, implementing security signing, and choosing distribution channels that affect discoverability, trust, and update capabilities. Understanding these considerations shapes successful desktop application strategies that reach users effectively while maintaining security and update cadence.

Platform installer formats reflect distinct ecosystems with different conventions, capabilities, and user expectations. Windows primarily uses NSIS (Nullsoft Scriptable Install System) or WiX Toolset for creating MSI installers. NSIS provides flexibility and small installer sizes (typically 5–15MB) with LZMA compression but limited enterprise management capabilities. MSI integrates with Windows Installer infrastructure enabling Group Policy deployment, administrative installs, and corporate software management tools, though installers tend larger and development complexity higher. Tauri’s Windows plugin generates both formats, with NSIS recommended for general consumer distribution and MSI for enterprise scenarios.

Linux distribution practices vary significantly between desktop users and distribution repositories. AppImage provides universal portable executables that run on any Linux distribution without installation, ideal for users wanting simple downloads and immediate execution. DEB packages integrate with Debian/Ubuntu package managers allowing apt install workflows, dependency resolution, and automatic updates through system update mechanisms. RPM packages serve Fedora/RHEL ecosystems with similar integration. Flatpak and Snap provide sandboxed distribution through application stores, though adoption varies by desktop environment. Tauri generates all formats from unified configurations, enabling comprehensive Linux coverage through multiple distribution strategies.

macOS requires DMG (Disk Image) bundles containing signed .app bundles for manual installation, or optionally PKG installers for managed deployments. DMG format dominates consumer distribution as it provides simple drag-and-drop installation, retains filesystem metadata and permissions, and supports custom backgrounds and layout. However, macOS imposes strict code signing and notarization requirements even for DMG distribution outside the Mac App Store. Applications without valid Developer ID signatures and notarization face aggressive warnings discouraging users from running them. Tauri integrates with Apple's toolchain to handle signing and notarization as part of builds, but developers need Apple Developer Program membership ($99/year) and appropriate certificates.

Code signing extends beyond compliance to establishing chain of trust that users rely on for security. On Windows, Authenticode signatures identify developers and confirm binary integrity, with SmartScreen filters displaying warnings for unsigned applications or developers without established reputation. Extended Validation (EV) certificates bypass SmartScreen immediately but cost $300–400/year versus $100–200/year for standard certificates. On macOS, Developer ID signing enables notarization, while Mac App Store submission requires separate Mac App Distribution certificates. On Linux, package repository signing establishes authenticity, though individual application signing less common. These processes add complexity and cost but prove essential for professional distribution as unsigned applications face user trust barriers.

The auto-update infrastructure transforms desktop applications from fire-and-forget installations into continuously improving software receiving security patches, bug fixes, and new features without user intervention. Tauri’s updater plugin implements background update checking on configurable intervals (daily, weekly, on launch), delta updating where only changed files download rather than complete installers, cryptographic signature verification ensuring updates originate from legitimate servers, and two-stage installation where updates download in background then prompt users to restart and apply. This architecture mirrors browsers’ automatic updating, reducing security vulnerabilities from outdated installations while respecting users’ control over when updates install.

Update server requirements for self-hosted solutions include static hosting for update manifests (JSON files describing current versions, download URLs, signatures) and installer binaries, or integration with services like AWS S3, GitHub Releases, or Cloudflare R2. The update manifest specifies version numbers, download URLs for platform-specific installers, release notes displayed to users, and cryptographic signatures validating authenticity. Tauri’s bundler generates manifest files automatically during builds, with CI/CD pipelines uploading to hosting providers and signing with private keys stored securely. Commercial services like AppCenter, Sparkle (macOS), or Squirrel (Windows) provide hosted solutions handling these complexities.

Distribution channels significantly impact discoverability and trust building. Direct downloads from project websites provide maximum control and zero fees but require driving traffic through marketing, SEO, and community building. Application stores — Microsoft Store, Mac App Store, Ubuntu Software — offer prominent placement and built-in update mechanisms but impose review processes, commission fees (15–30% for paid apps), and sandboxing restrictions potentially limiting functionality. Package repositories like Homebrew (macOS/Linux), Chocolatey (Windows), and Scoop (Windows) provide discovery through familiar developer tooling and automated updates, though mainly relevant for developer-focused tools rather than general consumer applications.

The trade-offs between web and desktop deployment warrant careful consideration when planning distribution strategies. Web deployment offers unmatched simplicity — update production servers and all users receive changes instantly without action. There’s no installer distribution, no update mechanisms to implement, no platform-specific builds, and no code signing costs. Users access applications through URLs without downloads, installations, or permission grants. Discoverability through search engines and direct links works naturally. These advantages explain web-first strategies for applications where browser capabilities suffice.

Desktop deployment provides capabilities impossible in browsers: offline functionality without service workers’ limitations, file system integration with drag-and-drop, file watchers, and arbitrary path access, system tray presence for background operation, native notifications respecting OS preferences, custom protocols allowing deep linking from other applications, elevated privileges for system administration tools, and hardware access to USB devices, Bluetooth, serial ports, and specialized peripherals. For applications requiring these capabilities, desktop distribution’s additional complexity justifies itself through functionality and user experience improvements.

Hybrid strategies combining both deployments maximize reach and capabilities. Typst Studio exemplifies this approach: the web version serves as free tier and trial experience accessible instantly from any device, while the desktop version provides enhanced capabilities for serious users willing to download installers. This strategy captures casual users and enables instant sharing while offering advanced features justifying desktop installation. Similarly, Electron-based applications like Figma and Linear maintain both web and desktop versions from shared codebases, recognizing different users prefer different deployment models based on use patterns and requirements.

Revenue models interact with distribution strategies in ways affecting architecture decisions. Web applications naturally support freemium and subscription models through integrated payment flows and instant access. Desktop applications traditionally used perpetual licenses but increasingly adopt subscriptions requiring license validation, trial periods, and feature unlocking through backend services. These requirements drive applications toward online-first architectures even when desktop-deployed, maintaining internet connectivity for authentication and license checking. Balancing offline functionality users expect from desktop software against online requirements for business models shapes architecture and distribution strategies.

Top comments (0)