Telerik blogs

Two database platforms battle it out in head-to-head comparisons in several categories. Which one will come out king?

When choosing a database platform, there are many questions you need to answer. First and foremost, Firebase is not a database, nor is Supabase—they are both database platforms.

Which one is better? Which one is faster? Which one is more powerful? Let’s take a look.

Database

Postgres

Supabase logo

Supabase uses an SQL relational database made to scale. It is incredibly powerful, supports JSON and Vector datatypes, has the ability to write triggers in pure SQL, or even in JavaScript with the plv8 extension. It has roles, row level security and, most importantly, the ability to query normalized data with joins.

Firestore / Firebase Realtime Database

Firebase logo

The core database in Firebase is the Firestore noSQL database.

Firebase Realtime Database (RTDB) was the first version that allowed you to store a giant JSON tree of data in a document database, and query it with real-time subscriptions.

There are certain niche cases where the Firebase Realtime Database may be a better option, but Firestore is way more powerful. They both are document databases. Firestore stores limited document sizes in unlimited collection sizes, while Firebase RTDB stores data in one unlimited JSON document. Firestore charges by reads, while Firebase RTDB charges by data transfer. They both are built to scale.

Winner

This is the easiest winner to pick. Supabase with Postgres is invariably the best. I have read several articles that say you can data model anything in noSQL that you can in SQL. This is simply wrong. Try making a scalable follower feed or a related post query.

Searching

Supabase

Postgres has built-in support for searching, although it isn’t always intuitive. You can use %like regular expressions, and simple sql searching techniques to find exact values. Fuzzy searching can be accomplished using vectors, but getting the write algorithm may take a bit. There isn’t really a one-size-fits-all method, and some people still prefer outside databases meant only for searching.

Firebase

Firebase has no built-in searching capabilities other than exact searching. I have written a package for this, but it may require some extra megabytes.

Winner

Supabase wins this, but I must admit I wish Postgres had a better built-in fuzzy search so that you don’t have to write complex algorithms to get what you want done, faster.

Query SDK Abilities

Firebase SDK

Every possible query you can do can be done with the Firebase SDK. It has come a long way in the past few years and now allows complex OR queries (if you have indexes).

There are still so many issues. You can’t query complex inequalities, and you can’t do joins as we know. You can store references to other documents. Inner joins are emulated by copying documents to a denormalized form using cloud functions.

PostgREST

While Supabase looks like Firebase V8 when you query, it is actually making a REST API call. PostgREST is extremely powerful. You can do all sorts of joins just like a graph database. One feature I wish it had was the ability to add nested data, but you can create a custom function to do this. Pretty cool.

Winner

Supabase wins—however, Firebase does allow every single possible query on the frontend.

Price

Supabase

Free: There is a free version of Supabase with no support that gets paused after a week of inactivity. This could be perfect for starter projects as long as you make sure to use the database weekly.

Pro: The pro version is $25 a month with email support and no pausing. I have found email support to be very limited in my experience.

Team: The team version starts at $599 a month and includes priority support along with security compliance standard certifications.

Firebase

Spark Plan: Firestore generally charges by reads and writes. This plan is free and can offer up to 20k writes and 50k reads a day. However, there is no Cloud Function access.

Blaze Plan: The blaze plan charges you after 1MB of storage (including your database), and gives you access to Cloud Functions. You have to tie your account to a credit card to start using this.

Winner

While this can greatly depend, for small projects the clear winner is Firebase. For medium projects, it is probably Supabase. And for large products, it just depends.

Authentication

Supabase Auth

Supabase has a built-in authentication with provider logins like Google, Apple, etc. There are also pre-made packages for server side authentication.

Firebase Authentication

Firebase has all the features of Supabase plus the ability to log in anonymously, delete your account, add and remove providers, and it is completely free. Server-side authentication is also possible, but may require a bit more setup.

Winner

The clear winner hear is Firebase. However, for most use cases, Supabase Auth works just fine. There are also feature requests for all of these items.

Authorization

Row Level Security

With Postgres’s Row Level Security (RLS), Supabase is extremely powerful. You may still need Trigger Functions to handle certain use cases. You can also easily create and add them via the Supabase dashboard.

Firebase Security Rules

Firebase Security Rules are also quite powerful. They don’t handle loops, and there are certain edge uses cases that are hard to draw up. However, Firebase Cloud Functions can usually handle these use cases as well. You do get charged for reads inside Security Rules.

Winner

While RLS is probably more powerful, I’m going to give this a tie. A relational database just needs more complex rules.

Functions

Firebase Cloud Functions

Cloud Functions allow you to create triggers based on database events (create, update, delete). You also have access to Cloud Storage and Firebase Authentication events. Alternatively, you could create callable functions. They can be written in several languages including TypeScript or Go.

Supabase Edge Functions

Supabase Edge Functions are written in TypeScript and run on Deno. You can call these functions just like Firebase, or you can set them up with webhooks.

Winner

Again, while Supabase Edge Functions are technically more powerful, I’m going to give this another tie. For the sake of comparing products, they do the same thing.

Speed

Supabase

Supabase supposedly performs 4x as quickly as Firebase according to the benchmark.

Firebase

I suspect part of this performance gain is due to Firebase’s large package. Firebase has optimistic updates, caching and offline-viewing built in. With great power comes potential speed loss.

Winner

Supabase.

Realtime Updates

Postgres Changes

Supabase has the ability to subscribe to changes to your database built into its SDKs. There are currently only seven filters you can use, and you must resubscribe manually if there are errors. The SDK is not user-friendly, but you can work around these limitations if you’re an advanced user who knows how to use Triggers and database denormalization techniques. It also is secure and works with RLS. I also wrote a package j-supabase to make this easier.

onSnapShot

Firebase subscriptions are clear as day. You subscribe to the changes you want, including all filters. It supports optimistic updates, does the initial fetch first, and auto reconnects when there are problems. Every database SDK should work like this.

Winner

The clear winner here is Firebase, but Supabase is not bad to use if you know how to structure your database to do what you want it to.

Types

JSON Data

Firebase is schemeless. You don’t need to configure anything to get started. Just connect and go. You can make rules later to enforce your schema.

SQL Rows and Columns

Supabase requires you to configure SQL types for every variable stored in the database. This is arguably a great thing, but definitely impedes your development time when you start a new app.

Winner

Firebase. I’m a big fan of adding schema rules later down the line.

TypeScript Support

Supabase Generating Types

There is something magical about the way Supabase can generate types for you. The caveat is that you must have a local hosted version. Then you simply run supabase gen types typescript to generate a fully loaded TypeScript file with all your database’s types ready to go! You can also supply a custom type inside .single() and .returns() statements (among others) to pass in custom types.

Firestore Data Converter

Firestore has a data converter that lets you return and pass in your custom types. You can also select certain fields and modify them as needed. While not intuitive at first, it is quite powerful.

Winner

The type generator in Supabase is hands-down amazing and saves you hours of headaches.

Local Hosting

Supabase Local Development

With the Supabase CLI, you can locally host a Supabase project. In fact, I highly recommend you develop this way. Not all the features of the cloud version are available, but you can pretty much test out your whole site with RLS, storage, migrations, triggers, auth and more. You can also technically self-host Supabase.

Firebase Emulator Suite

Firebase has an emulator suite you can use to test your app locally. You can write your functions locally, test auth, real-time, storage, etc. It uses a CLI as well and is extremely powerful. Supabase probably got the local idea from Firebase.

Winner

This is again one of those where Supabase is probably more powerful, considering you can self-host Supabase—however, I’m giving this one a tie.

Vendor Lock-in

Firebase

You’re stuck with Firebase forever once you start using it. You better be happy with Google Cloud as well.

Supabase

Supabase can be self-hosted, although it may not be easy. Then again, is self-hosting a database ever easy?

Winner

Clear winner is Supabase.

Storage

Firebase Cloud Storage

Firebase cloud storage is extremely powerful and allows the ability to easily upload and download files via a pre-written package in your desired language.

Supabase Storage

I find Supabase slightly easier to use. However, it didn’t have the ability to subscribe to the upload and download status, although you could write this JavaScript code manually.

Winner

I’m giving this one a tie too. Supabase is easier to use and will have probably all necessary features later in the game.

Client Libraries

Supabase

Supabase supports Dart and JavaScript, and there are community libraries for C#, Go, Kotlin, Python, Ruby, Swift and Godot Engine.

Firebase

Google has libraries for Java, Python, Node.js, Go, PHP, C#, and Ruby. However the Firebase Admin libraries are only available in Java, Python, Node.js and Go.

Winner

I give this a tie due to the unavailability of the Firebase Admin SDKs. If you’re a Java dev, better stick with Firebase.

Support

Supabase

Supabase has email support for $25 tiers, and high-level support for teams and enterprises.

Firebase

Firebase has an FAQ and a support form. However, I suspect extremely high-paying Google Cloud users have some access to Firebase support directly.

Winner

Clear winner is Supabase.

Community

Both communities are extremely active. There are Slack, Discords, YouTubes and Reddits for both:

The team on both projects seem to be very active and lively.

Winner

Tie.

Other Features

Google Cloud

Firebase has all the Google Cloud features plus Remote Config, App Check, Analytics, Hosting and more.

Supabase

Supabase has database migrations and is currently working on Branching!

Winner

You can’t compete with the entirety of Google Cloud, so I have to give this to Firebase. However, I personally find my needed features with Supabase.

And the Winner Is …

The truth is I’m very bullish on Supabase. All data is relational, so I wish noSQL databases really didn’t exist. Supabase is so powerful and has so many features that make it worth it. However, it still comes down to JOINS for me. You always need them.

I do love the schemeless app creation time of Firebase. You also can’t beat Firebase for subscribing to real-time data updates.

All in all, if you’re building anything bigger than a todo list, you need the complexities and power Supabase provides. I think most people who use Firebase in production are managing multiple databases. This is a no-go for me.

One day we shall have schemeless graph databases in the mainstream. Until then, Supabase is the best database platform out there for web developers.


About the Author

Jonathan Gamble

Jonathan Gamble has been an avid web programmer for more than 20 years. He has been building web applications as a hobby since he was 16 years old, and he received a post-bachelor’s in Computer Science from Oregon State. His real passions are language learning and playing rock piano, but he never gets away from coding. Read more from him at https://code.build/.

 

 

Related Posts

Comments

Comments are disabled in preview mode.