Serverless
Supabase
An open source Firebase alternative on PostgreSQL: database, auth, file storage, realtime and Edge Functions.
What it is
Supabase is a backend as a service built on PostgreSQL. With every table you get REST and GraphQL APIs (via PostgREST), plus auth, file storage, realtime subscriptions and Edge Functions on Deno.
The main difference from Firebase: under the hood it is plain Postgres with SQL, extensions (pgvector, PostGIS) and the ability to take your database elsewhere at any time. The project is open source and can be self-hosted.
Data access is protected by Row Level Security (RLS): policies inside the database define which rows a user sees. This is the key thing to configure so a client can safely talk to the database directly.
Use it when
- You need a fast backend for a web or mobile app with relational data.
- You want Postgres and SQL rather than Firebase's NoSQL model.
- You need auth, storage and realtime in one place.
- Self-hosting and no lock-in matter.
Avoid it when
- Complex business logic that is better kept in your own backend than in RLS policies and database functions.
- You need features outside the Postgres-centric model (deep integration with Google services).
- The team is not ready to learn RLS: policy mistakes expose data.
Key concepts
- Row Level Security
- PostgreSQL policies that limit row access depending on the user (
auth.uid()). - PostgREST
- Generates a REST API directly from the Postgres schema.
- Auth
- Email, OAuth, magic links, phone and JWT tokens tied to users in the database.
- Realtime
- Subscriptions to table changes and broadcast channels over WebSocket.
- Edge Functions
- Server-side TypeScript code for Deno that runs close to users.
Example
Interview questions
1. What is Row Level Security and why is it critical in Supabase?
RLS is Postgres policies that filter rows depending on the user. The client key is public, so without policies anyone could read or change data, and RLS is what makes direct access safe.
2. How does Supabase differ from Firebase?
Supabase is built on relational Postgres with SQL and is open source, while Firebase uses NoSQL documents (Firestore) and is a closed Google service. Supabase is easier to migrate away from and to self-host.
3. Which key may be exposed in the client?
The public anon key, because its rights are limited by RLS policies. The service role key bypasses RLS and must live only on the server.
Related technologies
- PostgreSQLA powerful open source relational database with extensions, JSONB, full-text search and strong SQL support.
- FirebaseA backend as a service from Google: Firestore, auth, hosting, Cloud Functions and push messaging.
- PrismaAn ORM for Node.js and TypeScript with a schema file, a generated type-safe client and migrations.
- Next.jsA full-stack React framework: routing, SSR, static generation, API routes and server components.
- JWTA compact signed token in JSON format that carries claims about a user or permissions.
- OAuth 2.0A delegated authorization standard: an app gets limited access to a user's resources without their password.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).