Open Source

Supabase: Open-Source Firebase Alternative with PostgreSQL

Supabase is an open-source Firebase alternative providing PostgreSQL database, authentication, realtime subscriptions, storage, and edge functions.

Keeping this site alive takes effort — your support means everything.
無程式碼也能輕鬆打造專業LINE官方帳號!一鍵導入模板,讓AI助你行銷加分! 無程式碼也能輕鬆打造專業LINE官方帳號!一鍵導入模板,讓AI助你行銷加分!
Supabase: Open-Source Firebase Alternative with PostgreSQL

For years, Firebase was the default choice for developers who wanted a backend without managing servers. It provided authentication, database, storage, and hosting in a single package — but at a cost: vendor lock-in to Google’s proprietary ecosystem, NoSQL data modeling that broke down for relational data, and a pricing model that became expensive at scale.

Supabase emerged as the answer to every Firebase frustration. It wraps PostgreSQL — the world’s most advanced open-source relational database — with a Firebase-like developer experience. Authentication, realtime subscriptions, file storage, and serverless functions are all built on PostgreSQL’s native capabilities. The result is a backend platform that offers the convenience of Firebase with the power and flexibility of relational databases.


How Does Supabase Replace Firebase’s Services?

Supabase matches Firebase’s service catalog feature-for-feature while replacing each proprietary component with open-source alternatives. The database — Supabase’s core — is PostgreSQL, accessed through a REST API (PostgREST) that auto-generates endpoints from your database schema. Every table, view, and function becomes an API endpoint automatically.

Authentication in Supabase is built on PostgreSQL’s Row-Level Security (RLS). When a user signs up through Supabase Auth (which supports email/password, OAuth, magic links, and phone auth), they receive a JWT. The JWT identifies the user to PostgreSQL, and RLS policies — written as standard SQL — control which rows each user can read, insert, update, or delete. This eliminates the need for a middleware layer to enforce authorization.

ServiceFirebaseSupabase
DatabaseFirestore (NoSQL)PostgreSQL (Relational)
APIFirebase SDK (proprietary)REST + GraphQL (PostgREST + pg_graphql)
AuthFirebase AuthGoTrue (built on PostgreSQL RLS)
RealtimeFirestore listenersPostgreSQL replication + WebSockets
StorageFirebase StorageS3-compatible (MinIO)
FunctionsCloud Functions (Node.js)Edge Functions (Deno)
HostingFirebase HostingNot included (Vercel, Netlify)

The open-source architecture means each Supabase component can be used independently or self-hosted. Many organizations run Supabase Auth or Supabase Realtime with existing PostgreSQL databases, adopting the components they need without migrating everything.


What Makes Supabase’s Realtime System Different?

Supabase Realtime takes a fundamentally different approach to realtime data synchronization than Firebase. Instead of requiring client-side listeners that connect to a proprietary realtime database, Supabase leverages PostgreSQL’s built-in logical replication.

When you enable Realtime for a table, Supabase creates a replication publication in PostgreSQL. Every INSERT, UPDATE, or DELETE on that table generates a change event through the replication slot. The Realtime server picks up these events and broadcasts them over WebSocket connections to subscribed clients. The result is true server-driven realtime — changes propagate to clients automatically, regardless of which client or server process made the change.

This architecture means any client application — web, mobile, or server — can subscribe to database changes without polling. A dashboard that displays live metrics, a chat application, a collaborative document editor — all benefit from changes propagating as they happen, not at polling intervals.


How Do Row-Level Security Policies Work in Supabase?

Row-Level Security is the foundation of Supabase’s authorization model. It moves access control from application code to the database layer, where it cannot be bypassed by client-side modifications.

An RLS policy is a SQL expression that PostgreSQL evaluates for each row when a query executes. The policy has access to the current user’s ID (from the JWT), the row being accessed, and any application-defined context. If the policy evaluates to true, the row is accessible; if false, it is filtered out or the operation is rejected.

A typical RLS policy for a multi-tenant application might check that the organization_id on the requested row matches the organization_id in the user’s profile. Supabase Auth automatically injects the authenticated user’s ID into PostgreSQL, and RLS policies reference this through the auth.uid() function.

Use CaseRLS Policy LogicImplementation
User owns resourceuser_id = auth.uid()Single SQL expression
Multi-tenant accessorg_id IN user_orgs()SQL function returns array
Admin has full accessauth.role() = 'admin'Built-in role check
Public read, auth writeAuthenticated check on writeSeparate INSERT/UPDATE policy
Time-based accessNOW() BETWEEN start AND endSQL timestamp comparison

The elegance of RLS is that it applies uniformly regardless of how data is accessed — via REST API, GraphQL, direct database connection, or server-side code. This eliminates a common security vulnerability where authorization logic is inconsistently applied across different access paths.


When Should You Choose Supabase Over Firebase?

The choice between Supabase and Firebase often comes down to data modeling requirements and long-term architectural preferences. Supabase excels in applications that benefit from relational data — joins, foreign keys, transactions, and complex queries. Firebase works well for applications with simple document-oriented data structures and a strong preference for Google Cloud integration.

Applications with complex reporting requirements strongly favor Supabase. PostgreSQL’s analytical capabilities — window functions, CTEs, materialized views — enable sophisticated data analysis that would require significant application code with Firestore. Similarly, applications requiring data integrity guarantees (financial systems, inventory management) benefit from PostgreSQL’s ACID transactions and referential integrity.

The self-hosting option is often the deciding factor for organizations with data residency requirements or compliance obligations. Supabase’s entire stack is open source and deployable on any infrastructure, while Firebase is exclusively a Google Cloud service.


FAQ

What is Supabase and how does it compare to Firebase? Supabase is an open-source Firebase alternative built on PostgreSQL. It offers relational data modeling, standard SQL, migrations, and transactions — all accessible with any SQL tool, unlike Firebase’s proprietary NoSQL system.

Does Supabase support realtime functionality? Yes. Supabase Realtime uses PostgreSQL replication to broadcast database changes to connected clients over WebSockets instantaneously as rows are inserted, updated, or deleted.

Can I use my existing PostgreSQL database with Supabase? Yes. Supabase is built on standard PostgreSQL, not a fork. You can migrate existing databases or connect Supabase services to an external PostgreSQL database.

How does Supabase handle authentication? Supabase Auth supports email/password, magic link, OAuth providers, phone auth, and anonymous sign-ins, with Row Level Security policies controlling data access per user.

Is Supabase free to use? Supabase offers a generous free tier including unlimited API requests, 500MB database, and 50,000 monthly active users. Paid plans start at $25/month and self-hosting is available for complete control.


References

TAG
CATEGORIES