Building a Tauri Desktop App from a Vue 3 Web Application: 9.1 MB vs 50-100 MB Electron

Tauri desktop application - 9.1 MB vs Electron 50-100 MB comparison

This session covers packaging the Pharmacokinetics Grapher Vue 3 web application as a native Tauri desktop application — a framework that delivers dramatically smaller bundles than Electron (9.1 MB vs 50-100 MB) while maintaining full offline capability and native performance.

Why Tauri Over Electron?

When deciding how to package a lightweight Vue 3 application as a desktop app, the framework choice matters significantly. Here’s why we chose Tauri for this Tauri desktop application project:

  • Bundle Size: 9.1 MB (macOS) vs 50-100 MB for equivalent Electron apps — a 15-30x reduction
  • Memory Usage: 40-60 MB runtime vs 150+ MB for Electron
  • First-Class Vite Integration: Zero configuration needed with our existing build setup
  • OS-Native WebView: Uses Safari on macOS, Edge on Windows, WebKit on Linux (no bundled Chromium)
  • Security-First Defaults: Restrictive by default, explicit allowlist for system access

The trade-off was requiring the Rust toolchain for development — but for a 336 KB Vue frontend, bundling 50+ MB of Chromium was wasteful.

The Setup Journey: What We Did (And What We Learned)

Phase 1: Prerequisites and Initialization

Started by checking for Rust (already present from Homebrew), then installed the Tauri CLI:

npm install --save-dev @tauri-apps/cli
npm exec tauri init -- --ci --app-name "Pharmacokinetics Grapher" ...

This created the src-tauri/ directory structure with Cargo.toml, Rust source files, and configuration templates. The Tauri project structure coexists cleanly with the Vue project — no conflicts.

Phase 2: Configuration Across Four Files

Setting up a Tauri desktop application requires coordinating configuration across multiple files:

1. src-tauri/tauri.conf.json

{\n  "productName": "Pharmacokinetics Grapher",\n  "version": "1.0.0",\n  "identifier": "com.pkgrapher.graphapp"\n}

Learning: The bundle identifier should NOT end with .app (macOS reserved), so we used com.pkgrapher.graphapp instead.

Phase 3: App Icons — Using AI to Generate Platform Assets

Rather than hand-crafting an icon, we used Gemini to generate a professional medical-themed icon (pill + curve pattern), then let Tauri handle the platform conversions.

Phase 4: Building the Production Bundle

Result: 9.1 MB macOS .app bundle (7.9 MB native binary + 327 KB frontend assets)

Problem Encountered: The DMG bundler on macOS failed. Solution: Used the native .app bundle format instead (the standard macOS distribution approach).

Phase 5: Development Testing — Verifying the Tauri Desktop Application Works

The critical test: Does the Vue app work correctly inside Tauri’s WebView?

  • ✅ App window opens at correct size and position
  • ✅ Vue app loads with proper title
  • ✅ PrescriptionForm accepts input correctly
  • ✅ Chart.js graph renders (all assets bundled locally)
  • ✅ localStorage persists data across app restarts
  • ✅ Vue DevTools accessible (right-click → Inspect)
  • ✅ All 675 unit tests pass (zero regressions)
  • ✅ Zero TypeScript errors

Technical Deep Dive: What Makes a Tauri Desktop Application Unique

Offline Capability

All frontend assets are bundled locally in the app binary — zero network requests needed after installation. This is a fundamental advantage of the desktop model.

Data Persistence via localStorage

Users can create prescriptions, close the app, and reopen it — data persists automatically through localStorage (which Tauri’s WebView implements).

Bundle Size Comparison

Tauri: 9.1 MB (native WebView) vs Electron: 50-100 MB (bundled Chromium) = 80-90% smaller

What We Learned from This Tauri Desktop Application Project

  1. Configuration Matters: Getting window sizing, identifier naming, and build paths right upfront prevents cascading issues later
  2. Pragmatism Over Perfection: The DMG bundler failed, but the native .app was already perfect for distribution
  3. AI-Generated Assets Work: Using Gemini to generate the icon was faster than manual design
  4. Testing Validates Everything: Running all 675 tests in Tauri context proved the Vue app works correctly
  5. localStorage Just Works: The existing data persistence layer required zero changes for desktop usage
  6. Vite Integration is Seamless: Our existing build pipeline integrated with Tauri with minimal friction

Current Status and Next Steps

Complete: ✅ Tauri v2 infrastructure, development testing, macOS production bundle, cross-platform icons, automated build pipeline

Next Phases: Offline verification testing, GitHub Release creation, Windows/Linux builds via GitHub Actions CI/CD

Key Takeaways for Building a Tauri Desktop Application

  • Tauri trades a Rust dependency for dramatically smaller bundles and native performance
  • Vue 3 works transparently inside Tauri’s WebView — no framework changes needed
  • Configuration is spread across four files, but each has clear responsibilities
  • Icon generation can be automated with AI tools + Tauri’s platform converter
  • Offline capability is built-in when all assets are bundled
  • Existing web patterns (localStorage, fetch, CSS) work unchanged
«
»

Leave a Reply