Crate supabase

Source
Expand description

§Supabase Rust Client

A comprehensive Rust client library for Supabase that provides:

  • Authentication (sign up, sign in, JWT handling)
  • Database operations (CRUD via REST API)
  • Storage (file upload, download, management)
  • Realtime subscriptions (WebSocket-based)

§Quick Start

use supabase::Client;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
struct Post {
    id: i32,
    title: String,
    content: String,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new("your-project-url", "your-anon-key")?;

    // Authenticate
    let _user = client.auth()
        .sign_in_with_email_and_password("user@example.com", "password")
        .await?;

    // Query database with proper type annotation
    let _posts: Vec<Post> = client.database()
        .from("posts")
        .select("*")
        .execute()
        .await?;

    Ok(())
}

Re-exports§

pub use client::Client;
pub use error::Error;
pub use error::Result;
pub use auth::Auth;
pub use database::Database;
pub use realtime::Realtime;
pub use storage::Storage;

Modules§

auth
Authentication module for Supabase
client
Main Supabase client
database
Database module for Supabase REST API
error
Error handling for the Supabase client
prelude
Re-exports of commonly used types and traits
realtime
Realtime module for Supabase WebSocket subscriptions
storage
Storage module for Supabase file operations
types
Common types and data structures for Supabase operations