# Supabase
Supabase is an open-source Backend-as-a-Service (BaaS) platform built on top of [[PostgreSQL]]. Often described as an "open-source Firebase alternative," it provides a full backend stack including database, authentication, storage, real-time subscriptions, and edge functions.
Unlike Firebase (which uses a proprietary NoSQL database), Supabase uses PostgreSQL—giving developers the full power of [[SQL]], joins, and relational data modeling while still offering real-time capabilities.
## Core Features
### Database (PostgreSQL)
- Full PostgreSQL database with all features
- Table editor UI for visual database management
- SQL editor for direct queries
- Database branching for development workflows
- Automatic API generation from schema
### Authentication
- Email/password, magic links, phone auth
- OAuth providers (Google, GitHub, Apple, etc.)
- Row Level Security (RLS) integration
- JWT tokens and session management
- Multi-factor authentication (MFA)
### Storage
- S3-compatible object storage
- Image transformations and resizing
- CDN for fast delivery
- Access policies tied to authentication
- Resumable uploads for large files
### Real-time
- Subscribe to database changes via WebSockets
- Broadcast messages between clients
- Presence tracking (who's online)
- Works with Row Level Security
### Edge Functions
- Serverless functions at the edge (Deno runtime)
- TypeScript/JavaScript support
- Low-latency execution globally
- Invoke from client or webhooks
### Vector/AI
- pgvector extension for embeddings
- Semantic search capabilities
- AI/ML workflow integration
## Auto-Generated APIs
Supabase automatically generates APIs from your database schema:
### REST API (PostgREST)
```javascript
const { data, error } = await supabase
.from('users')
.select('*')
.eq('active', true)
```
### GraphQL
```graphql
query {
usersCollection {
edges {
node {
id
name
}
}
}
}
```
## Row Level Security (RLS)
PostgreSQL policies that restrict data access at the database level:
```sql
-- Users can only see their own data
CREATE POLICY "Users can view own data"
ON users FOR SELECT
USING (auth.uid() = user_id);
-- Users can only update their own profile
CREATE POLICY "Users can update own profile"
ON profiles FOR UPDATE
USING (auth.uid() = id);
```
## Client Libraries
- JavaScript/TypeScript: `@supabase/supabase-js`
- Python: `supabase-py`
- Flutter/Dart: `supabase_flutter`
- Swift: `supabase-swift`
- Kotlin: `supabase-kt`
## Self-Hosting
Supabase can be self-hosted using Docker:
```bash
git clone https://github.com/supabase/supabase
cd supabase/docker
cp .env.example .env
docker compose up
```
## Supabase vs Firebase
| Feature | Supabase | Firebase |
|---------|----------|----------|
| Database | [[PostgreSQL]] (relational) | Firestore (NoSQL) |
| Query language | [[SQL]] | Proprietary |
| Open source | Yes | No |
| Self-hosting | Yes | No |
| Joins | Native | Manual/denormalized |
| Real-time | Yes | Yes |
| Vendor lock-in | Low | High |
## References
- Official website: https://supabase.com/
- Documentation: https://supabase.com/docs
- GitHub: https://github.com/supabase/supabase
## Related
- [[PostgreSQL]]
- [[Database]]
- [[SQL]]
- [[Relational Databases (RDBMS)]]