rust_supabase_sdk
An ergonomic, async Rust client for Supabase.
Mirrors the supabase-js surface area where it makes sense and pushes
Rust-native ergonomics elsewhere:
- PostgREST — chainable query builder + typed row queries via
from_row::<T>() - Auth — email / phone / OTP / OAuth / anonymous sign-in, account recovery, admin user management, pluggable session stores
- Storage — buckets, object CRUD, signed URLs, image transforms
- RPC — call Postgres functions with
rpc_call(...) - Edge Functions — invoke deployed functions, streaming responses supported
- Realtime — websocket subscriptions to
postgres_changes, broadcast, and presence (opt-in feature) - Retry — automatic exponential backoff on 429 / 5xx
Installation
[]
= "0.3"
MSRV: Rust 1.75.
Quickstart
use SupabaseClient;
async
Feature flags
| Feature | Default | Notes |
|---|---|---|
postgrest |
✅ | Chainable query builder. |
auth |
✅ | Sign-in flows, OAuth, admin user management. |
storage |
✅ | Buckets + objects + signed URLs. |
functions |
✅ | Edge Functions invocation. |
realtime |
— | Websocket subscriptions (opt-in). |
rustls |
✅ | TLS via rustls (default). |
native-tls |
— | Use OS TLS instead of rustls. |
Enable realtime explicitly:
= { = "0.3", = ["realtime"] }
Customizing the client
use Duration;
use ;
let client = builder
.timeout
.retry
.user_agent
.schema
.build;
SupabaseClient is cheap to clone — internal state is Arc-shared, so a single
configured client can be passed across tasks and modules.
Typed queries
Implement Row for your row type (or generate it — see below) and use
from_row::<T>() for end-to-end type safety:
use Row;
use ;
let rows: = client.
.eq
.await?;
Code generation
The companion cargo-supabase binary introspects a Supabase project's PostgREST
schema and emits Rust row structs (with Row impls) ready for use with
from_row::<T>():
cargo install cargo-supabase
cargo supabase gen types \
--url $SUPABASE_URL \
--apikey $SUPABASE_SERVICE_ROLE_KEY \
--output src/generated.rs
The introspection endpoint requires the service-role key, not the anon key.
Flags:
--only <TABLE>/--exclude <TABLE>— allow/deny lists, repeatable.--schema <NAME>— schema label baked into generated docs (defaultpublic).--uuid— emituuid::Uuidfor UUID columns instead ofString.--no-chrono— emitStringfor timestamps instead ofchrono::*.
Examples
Worked examples for every major surface area:
cargo run --example query
cargo run --example postgrest_typed
cargo run --example auth_email
cargo run --example storage_upload
cargo run --example functions_invoke
cargo run --example realtime_changes --features realtime
All examples read SUPABASE_URL and SUPABASE_API_KEY from the environment.
Documentation
Full API documentation lives on docs.rs.
Contributing
Bug reports, feature requests, and PRs welcome at github.com/Lenard-0/Rust-Supabase-SDK.
License
MIT — see LICENSE.