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
Creates a new space at the given path
Opens an existing space
Returns current space path or null
Closes the current space
File System Operations
Lists files and directories
Reads a text file with metadata
Writes a text file atomically
Creates a directory
Renames/moves a file or directory
Deletes a file or directory
Search & Index
Rebuilds the SQLite full-text search index
Full-text search across all notes
Advanced search with filters
Lists all tags with usage counts
Finds notes linking to a given note
AI Commands
Starts an AI chat conversation
Lists configured AI provider profiles
Lists available models for a provider
Tasks
Queries tasks by bucket (inbox, today, upcoming)
Toggles task completion
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