🦀 Supabase-rust
supabase-rust is a light Rust wrapper around the Supabase REST API.
Features
- Client creation
- Sign-in email/pass
- Signup email/pass
- Signup phone/pass
- Token refresh
- Logout
- Verify one-time token
- Authorize external OAuth provicder
- Password recovery
- Resend one-time password over email or SMS
- Magic link authentication
- One-time password authentication
- Retrieval of user's information
- Reauthentication of a password change
- Enrollment of MFA
- MFA challenge and verify
- OAuth callback
- All SSO
- All Admin
- Database support (CRUD operations with fluent query builder)
Quickstart
Add the following dependency to your Cargo.toml:
[]
= "0.1.2"
= { = "1", = ["full"] }
= { = "1.0", = ["derive"] }
Client Initialization
You can initialize the client with explicit values or via environment variables:
use Supabase;
// Option 1: Using environment variables
// Set SUPABASE_URL, SUPABASE_API_KEY, and optionally SUPABASE_JWT_SECRET
let client = new;
// Option 2: Explicit configuration
let client = new;
Usage
Authentication
use Supabase;
async
Database Operations
The library provides a fluent query builder for PostgREST database operations:
use Supabase;
use ;
async
Available Filter Methods
| Method | Description | PostgREST Equivalent |
|---|---|---|
eq(col, val) |
Equal | col=eq.val |
neq(col, val) |
Not equal | col=neq.val |
gt(col, val) |
Greater than | col=gt.val |
gte(col, val) |
Greater than or equal | col=gte.val |
lt(col, val) |
Less than | col=lt.val |
lte(col, val) |
Less than or equal | col=lte.val |
like(col, pattern) |
Pattern match (use * as wildcard) |
col=like.pattern |
ilike(col, pattern) |
Case-insensitive pattern match | col=ilike.pattern |
in_(col, &[vals]) |
Value in list | col=in.(v1,v2,v3) |
is_null(col) |
Is null | col=is.null |
not_null(col) |
Is not null | col=not.is.null |
Query Modifiers
| Method | Description |
|---|---|
order(col) |
Order by column (use col.desc for descending) |
limit(n) |
Limit number of rows |
offset(n) |
Skip first n rows |
Combining Filters
Filters can be chained to create complex queries:
let response = client
.from
.select
.gte
.lte
.neq
.in_
.order
.limit
.execute
.await?;
Tips
The Supabase team has an outline of their OpenAPI specs over in this yaml file.
License
Supabase-rust is available under the MIT license, see the LICENSE file for more information.