Overview
Tauri commands are the IPC (inter-process communication) layer between the React frontend and Rust backend. All commands are:- Typed on both sides (Rust + TypeScript)
- Async by default
- Serialized via JSON (serde)
Command Flow
Defining Commands
Step 1: Implement Rust Command
src-tauri/src/space_fs/read_write/text.rs
Step 2: Register in lib.rs
src-tauri/src/lib.rs
Step 3: Add TypeScript Types
src/lib/tauri.ts
Step 4: Invoke from Frontend
Command Categories
Space Lifecycle
File System Operations
Writes a text file atomically
Search & Index
AI Commands
Tasks
Queries tasks by bucket (inbox, today, upcoming)
Error Handling
Rust Side
Always returnResult<T, String>:
Frontend Side
Use try/catch withTauriInvokeError:
State Management
Tauri State
Global state accessible to all commands:src-tauri/src/lib.rs
Type Safety
Enforcing Type Consistency
TheTauriCommands interface ensures TypeScript types match Rust:
src/lib/tauri.ts
invoke() helper enforces these types:
- Pass wrong argument types
- Forget required arguments
- Expect wrong return type
Performance Tips
Batch Operations
Instead of N individual calls:Bad
Good
Streaming Large Data
For large results, use events instead of return values:Next Steps
Indexing
Learn about SQLite indexing
Storage
Content-addressed file storage