Expand description
§pixeluvw_supabase
A production-ready, 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.
§🚀 Quick Start
§A. Setup Environment
Create a .env file (ensure it’s in your .gitignore):
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key§B. Basic Usage
use pixeluvw_supabase::{supabase, SupabaseClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenv::dotenv().ok();
// Initialize the client (automatically loads from env)
let client = supabase!()?;
// Perform a query
let users: Vec<serde_json::Value> = client
.from("users")
.select("*")
.eq("status", "active")
.limit(5)
.execute()
.await?;
println!("Users: {:?}", users);
Ok(())
}§Security
Never hardcode credentials! Use environment variables:
SUPABASE_URL— Your project URLSUPABASE_KEY— Your anon or service key- Add
.envto.gitignore
Modules§
Macros§
- supabase
- Initialize a SupabaseClient with less boilerplate.
Structs§
- Auth
Service - Authentication service for Supabase.
- Bucket
- Client
Config - Configuration for the Supabase client.
- Column
Schema - File
Session Store - A simple file-based session store.
- Functions
Client - Client for invoking Supabase Edge Functions.
- Memory
Session Store - A thread-safe in-memory session store (mostly for testing).
- Query
Builder - A fluent query builder for constructing Supabase PostgREST queries.
- Realtime
Channel - A handle to a subscribed Realtime channel.
- Realtime
Channel Builder - Realtime
Client - Realtime
Message - Request
Context - Middleware context passed through the request lifecycle.
- Schema
- Represents the Database Schema based on PostgREST OpenAPI spec.
- Session
- Authentication session containing tokens and user info.
- Storage
Bucket - A handle to a specific storage bucket.
- Storage
Client - Storage client for Supabase file operations.
- Supabase
Client - Supabase
Client Builder - Builder for
SupabaseClient. - Table
Schema - Uploaded
File - User
- Supabase user profile.
Enums§
- Connection
State - Connection state for realtime channels.
- OtpType
- OTP (One-Time Password) types for authentication.
- Postgres
Event - Provider
- OAuth providers supported by Supabase.
- Sign
UpResult - Result of a sign-up operation.
- Supa
Error - Unified error type for all Supabase SDK operations.
Traits§
- Middleware
- Middleware trait for intercepting requests and responses.
- Session
Store - Trait for persisting sessions.
Type Aliases§
- Result
- A specialized
Resulttype for Supabase operations.