What Is Supabase?
Supabase is a backend-as-a-service built on PostgreSQL. It gives you a database, auth, file storage, realtime subscriptions, edge functions, and vector search β all open-source. 78K+ GitHub stars.
Supabase vs Firebase
| Feature | Supabase | Firebase |
|---|---|---|
| Database | PostgreSQL (relational) | Firestore (NoSQL) |
| Auth | β (GoTrue) | β |
| Storage | β (S3-compatible) | β |
| Realtime | β (PostgreSQL CDC) | β |
| Edge Functions | β (Deno) | β (Node.js) |
| Vector search | β (pgvector) | β |
| SQL queries | β Full SQL | β |
| Self-hosted | β | β |
| Vendor lock-in | None (itβs just Postgres) | High |
| Pricing model | Per-project | Pay-per-read/write |
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββ
β Supabase Platform β
β β
β ββββββββββββ ββββββββββββ βββββββββββββ β
β β PostgRESTβ β GoTrue β β Storage β β
β β (API) β β (Auth) β β (S3) β β
β βββββββ¬ββββββ ββββββ¬ββββββ βββββββ¬ββββββ β
β β β β β
β βββββββΌββββββββββββββΌββββββββββββββΌββββββ β
β β PostgreSQL β β
β β + pgvector + pg_cron + pg_net β β
β ββββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββ ββββββββββββ βββββββββββββ β
β β Realtime β β Kong β β Edge β β
β β (CDC) β β(Gateway) β β Functions β β
β ββββββββββββ ββββββββββββ βββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββSelf-Host on Kubernetes
# docker-compose for local dev / small deployments
services:
db:
image: supabase/postgres:15.6.1
environment:
POSTGRES_PASSWORD: your-super-secret-password
volumes:
- pgdata:/var/lib/postgresql/data
auth:
image: supabase/gotrue:v2.151.0
environment:
GOTRUE_DB_DRIVER: postgres
GOTRUE_DB_DATABASE_URL: postgres://supabase_auth_admin:password@db:5432/postgres
GOTRUE_JWT_SECRET: your-jwt-secret
rest:
image: postgrest/postgrest:v12.2.0
environment:
PGRST_DB_URI: postgres://authenticator:password@db:5432/postgres
PGRST_JWT_SECRET: your-jwt-secret
storage:
image: supabase/storage-api:v1.0.6
environment:
STORAGE_BACKEND: s3
GLOBAL_S3_BUCKET: your-bucket
realtime:
image: supabase/realtime:v2.28.32
environment:
DB_HOST: db
DB_PORT: 5432Key Use Cases
1. AI Applications (pgvector)
-- Enable vector extension
CREATE EXTENSION vector;
-- Store embeddings alongside data
CREATE TABLE documents (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
content TEXT,
embedding vector(1536),
metadata JSONB
);
-- Semantic search
SELECT content, 1 - (embedding <=> query_embedding) as similarity
FROM documents
ORDER BY embedding <=> query_embedding
LIMIT 5;2. Row-Level Security (Multi-tenant)
-- Each user sees only their data
ALTER TABLE projects ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Users see own projects"
ON projects FOR SELECT
USING (auth.uid() = user_id);
CREATE POLICY "Users insert own projects"
ON projects FOR INSERT
WITH CHECK (auth.uid() = user_id);3. Realtime Subscriptions
const channel = supabase
.channel('orders')
.on('postgres_changes', {
event: 'INSERT',
schema: 'public',
table: 'orders',
}, (payload) => {
console.log('New order:', payload.new);
})
.subscribe();Why PostgreSQL Matters
Unlike Firebaseβs proprietary NoSQL, Supabase is just PostgreSQL:
- Migrate away anytime with
pg_dump - Use any PostgreSQL tool (DBeaver, pgAdmin, psql)
- Join tables, use CTEs, window functions β real SQL
- 40 years of battle-tested reliability
- Extensions: PostGIS, pgvector, pg_cron, timescaledb