pixeluvw_supabase
A high-performance Rust SDK for Supabase.
Designed for reliability and improved developer experience, this crate provides a strongly-typed, fluent interface for interacting with the entire Supabase stack (Database, Auth, Realtime, Storage, and Edge Functions).
Note: This SDK is currently in Beta. APIs are stable but may evolve.
✨ Features
- 🚀 Database: Full PostgREST support with a fluent query builder, 25+ filters, and strong typing.
- 🔮 Schema Introspection: Unique capability to fetch remote schema metadata at runtime and generate Rust structs.
- 🔐 Auth: Complete authentication suite including Email/Password, OAuth, OTP, MFA, and Admin API.
- ⚡ Realtime: Robust WebSocket client for listening to database changes (INSERT, UPDATE, DELETE), presence, and broadcast.
- 📦 Storage: Simple API for file uploads, downloads, and signed URL generation.
- serverless Functions: Invoke Edge Functions seamlessly.
- 🛡️ Enterprise Ready: Built-in middleware support, automatic retries with exponential backoff, and robust error handling.
📦 Installation
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
= { = "1", = ["derive"] }
= "1"
= "0.15"
🚀 Quick Start
1. Setup Environment
Create a .env file in your project root (ensure it's in your .gitignore):
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key
2. Basic Usage
use ;
use json;
async
📚 Guides
Database
The query builder allows you to construct complex queries with ease.
// Select with multiple filters and ordering
let items = client
.from
.select
.eq
.is_
.order // descending
.execute
.await?;
// Insert new data
client
.from
.insert
.execute
.await?;
// Update existing data
client
.from
.update
.eq
.execute
.await?;
Supported Filters
eq, neq, gt, gte, lt, lte, like, ilike, is_, in_, contains, contained_by, range_gt, range_gte, range_lt, range_lte, range_adjacent, overlaps, text_search, match_, filter, not, or, and.
Authentication
Handle user sessions securely.
// Sign in with email and password
let session = client.auth.sign_in_with_password.await?;
// The client automatically attaches the access token to subsequent requests!
// You can also access the user object:
println!;
// Sign out
client.auth.sign_out.await?;
OAuth Login:
let url = client.auth.sign_in_with_oauth?;
// Redirect your user to `url`
Realtime
Subscribe to database changes instantly.
use PostgresEvent;
use StreamExt;
let mut channel = client
.realtime
.channel
.on_postgres_changes
.subscribe
.await?;
// Listen for messages
while let Some = channel.next.await
Storage
Manage user files.
let bucket = client.storage.from;
// Upload a file
bucket.upload.await?;
// Get a public URL
let url = bucket.get_public_url?;
⚙️ Configuration
You can customize the client behavior using ClientConfig.
use ;
let config = ClientConfig ;
let client = with_config?;
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License.