tauri-ipc

Implements type-safe Tauri v2 IPC with invoke calls and Rust commands.

Updated Sep 3, 2024
One-click install
npx skills add https://github.com/eminboydak/duckTerm --skill tauri-ipc-eminboydak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tauri-ipc
Source: https://github.com/eminboydak/duckTerm/tree/main/.agents/skills/tauri-ipc
Command: npx skills add https://github.com/eminboydak/duckTerm --skill tauri-ipc-eminboydak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building communication between a Tauri frontend and Rust backend often results in untyped invoke calls, inconsistent error handling, and mismatched request/response contracts that break at runtime. ## Core Features & Use Cases - Typed IPC Contracts: Define Rust commands and register them in the Tauri builder with typed request/response payloads. - Type Generation Guidance: Apply tauri-specta or official generators to eliminate any-typed IPC between frontend and backend. - Error Handling Patterns: Establish validation and error response contracts for command failures. - Use Case: When adding a serial port read command to a Tauri 2.x app, use this Skill to define the Rust command, generate TypeScript bindings, and call it from Svelte with full type safety. ## Quick Start Ask the assistant to create a type-safe Tauri command with typed invoke bindings for your frontend feature.

Frequently Asked Questions about tauri-ipc

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call Rust commands from a Tauri frontend?

Use the invoke function from @tauri-apps/api/core with the command name and a typed payload object. The Rust command must be registered in the Tauri builder via generate_handler, and it returns a Promise resolving to the command's serialized result.

How to get type-safe IPC in Tauri v2?

Use tauri-specta or the official type generation tools to derive TypeScript bindings from your Rust command signatures. This removes any-typed invoke calls and keeps frontend types synchronized with backend definitions automatically.

Does tauri-specta work with Tauri v2?

Yes, tauri-specta supports Tauri v2 for generating type-safe bindings between Rust commands and the frontend. Ensure the specta and tauri-specta crate versions match your Tauri major version to avoid API incompatibilities.

How do I send events from Rust to the Tauri frontend?

Use the emit or emit_to methods on the AppHandle or Window to push events from Rust. On the frontend, subscribe with the listen function from @tauri-apps/api/event to receive the event payloads.

Why does my Tauri invoke call fail with a serialization error?

Serialization errors occur when payload types do not implement Serialize/Deserialize or when field names mismatch between Rust and TypeScript. Verify both sides use compatible types and consistent casing conventions such as camelCase or snake_case.