Skip to main content

supabase_rust/
lib.rs

1//! # supabase-rust
2//!
3//! An unofficial Rust client for [Supabase](https://supabase.com).
4//!
5//! Provides typed access to Supabase Auth and PostgREST (database) APIs.
6//!
7//! ## Quick start
8//!
9//! ```rust,no_run
10//! use supabase_rust::{Supabase, AuthResponse, Error};
11//!
12//! # async fn run() -> Result<(), Error> {
13//! let client = Supabase::new(
14//!     Some("https://your-project.supabase.co"),
15//!     Some("your-api-key"),
16//!     None,
17//! )?;
18//!
19//! // Sign in
20//! let auth: AuthResponse = client
21//!     .sign_in_password("user@example.com", "password")
22//!     .await?;
23//! println!("access token: {}", auth.access_token);
24//!
25//! // Query the database
26//! let response = client
27//!     .from("todos")
28//!     .select("*")
29//!     .eq("user_id", &auth.access_token)
30//!     .execute()
31//!     .await?;
32//! # Ok(())
33//! # }
34//! ```
35
36use reqwest::Client;
37
38pub mod auth;
39pub mod db;
40pub mod error;
41mod client;
42
43pub use auth::{AuthResponse, Claims};
44pub use db::QueryBuilder;
45pub use error::Error;
46
47/// The Supabase client. Entry point for all operations.
48#[derive(Clone, Debug)]
49pub struct Supabase {
50    client: Client,
51    url: String,
52    api_key: String,
53    jwt: String,
54    bearer_token: Option<String>,
55}