Tauri Specta

Generate fully type-safe TypeScript bindings for your Tauri commands and events.

Library
Cargo
v2.0.0-rc.25
779stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
76/100Good
Development Activity80
Maintenance84
Community48
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture82
Code Quality80
Innovation78
Learning Curve72

Tauri Specta is a Rust crate that connects Tauri’s IPC command/event system to Specta’s type-reflection engine, automatically generating matching TypeScript types and typed invoke wrappers for every #[tauri::command] and event in a Tauri application. Instead of hand-writing TypeScript interfaces that mirror your Rust structs and manually keeping them in sync, you annotate commands with a derive macro and export a single generated .ts file the frontend imports directly.

Built by the Specta project (also behind rspc), Tauri Specta targets Tauri v2 apps and eliminates an entire class of frontend/backend type-drift bugs common in Tauri projects, where the Rust command signature and the JS invoke() call can silently fall out of sync.

What You Get

  • A #[specta::specta]-compatible builder API (Builder::new().commands(...).events(...)) that registers commands/events for export
  • Automatic TypeScript type + function-signature generation for every registered Tauri command, matching Rust struct/enum shapes exactly
  • Type-safe event emission and listening helpers generated alongside commands
  • Optional JavaScript (untyped) export mode alongside the default TypeScript mode via feature flags
  • Integration with the broader Specta ecosystem (specta, specta-typescript) for consistent type generation across multiple Rust-to-TS tools

Common Use Cases

  • Generating a single source-of-truth TypeScript API surface for a Tauri v2 desktop app’s Rust backend commands
  • Keeping frontend event listeners type-safe when the Rust backend emits typed events to the webview
  • Avoiding manual duplication of Rust DTOs as hand-written TypeScript interfaces in a Tauri + React/Vue/Svelte app
  • Powering internal tooling or plugin ecosystems built on Tauri where multiple frontends consume the same typed command surface

Under The Hood

Architecture: The crate builds around a Builder (src/builder.rs) that collects registered commands (src/commands.rs) and events (src/event.rs), each described via the specta crate’s type-reflection derive; a language-backend abstraction (src/lang.rs, src/lang/) then renders that collected schema into TypeScript (or JS) source, keeping code generation decoupled from the type-collection step. Tech Stack: Pure Rust, built on top of the specta and specta-typescript crates from the same organization, tauri v2 (with the specta feature) for command/event registration, and serde/serde_json for schema serialization; a companion tauri-specta-macros crate supplies the derive-feature proc macros. Code Quality: tests/ covers command signature generation, option-type references, and identifier casing (casing.rs) via cargo test --all --all-features, with an examples/app Tauri project serving as an integration/manual-test target; the workspace uses shared lints ([lints] workspace = true) for consistency across crates. API Design: The public surface is a fluent builder (Builder::new().commands(collect_commands![...])) plus attribute macros on existing #[tauri::command] functions, requiring minimal changes to an existing Tauri command’s signature to opt into type generation, with a single generated .ts file consumed like any other frontend module.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search