DEV Community

Cover image for Supabase - An OpenSource Firebase Alternative
Somsubhra Das
Somsubhra Das

Posted on

Supabase - An OpenSource Firebase Alternative

Supabase is an OpenSource Firebase Alternative providing Backend as a Service to various applications. It is super easy to setup and runs quickly with multiple frameworks.

Features

Supabase has the following highlighting features:

  • PostgreSQL with RealTime Capabilities with PostgREST API
  • Security and Access control managed by Postgres RLS(Row Level Security)
  • Authentication with multiple services with support of Magic Link authentication
  • File Storage
  • Supabase Client Libraries (Javascript, Python, Dart)
  • Serverless Functions (Coming Soon)

How it works?

At its core, Supabase is a suite of open source tools, stitched together to build a seamless developer experience:

Internal structure
Source: Supabase

Project

A project in Supabase is a wrapper around all your databases, authentication users, policies, tables, file storage. There are multiple regions from which you can choose where to host your project and Supabase officials are continuously adding more locations to reduce latency.

Supabase Project creation

A project creation takes around 2 minutes to complete so get a coffee, sit back and relax.

Project Dashboard

Once your project is created, you will be greeted with a similar dashboard shown below.

Supabase Dashboard

This dashboard contains all details about your project including your database connections, authentication requests, storage space, implementation using client libraries, and much more.

Table Creator/Editor

Supabase uses Relational PostgreSQL as database with RealTime Capabilities and Policy access control by Postgres RLS(Row Level Security).

Supabase allows developers to create a Table and add columns and attributes directly from dashboard.

Supabase Table Creation

Supabase allows developers to edit data directly from the dashboard.

Supabase Table Manager

Authentication

Supabase has a wide range of Authentication Providers such as Google, GitHub, Facebook, Twitter, GitLab etc. These can be enabled through Authentication Panel. It also supports Phone OTP Authentication and also Magic Link Authentication.

Authentication Providers

Once a user authenticates through Supabase, it shows the users' email, last login time on the Auth Dashboard.

Authentication Panel

The magic link works seamlessly which allows users to login/register in your app without a password.

Magic Link

What I like most about the Supabase authentication service is the RLS Policies Feature. We can create policies to restrict access to users from making changes or viewing data from our tables in database.

RLS Policy

Supabase provides some pre written templates for our policies as well. We may choose from them or write our own custom policies through the SQL editor as shown below.

create policy "Users can only update their own items."
  on items for update using (
    auth.email() = email
  );
Enter fullscreen mode Exit fullscreen mode

The above query sets the policy in such a way that only the user who's the owner of the item can update that specific item.

Storage

Supabase provides file storage feature with the option to add access control policies to the files as well.

Bucket Creation

Storage Dashboard

It provides a publicly accessible file link so that it can be shared or embedded in Frontend Apps.

SQL Editor

Supabases gives an online SQL Query CLI right out of the box so that we need not use the CLI to connect to the DBAAS to run our queries. It even saves your queries so that we can go back and check our previous run queries.

SQL Query

Database

From the database tab you may edit your database schemas, add columns to your database, create new tables, delete tables, update database roles etc.

Database Manager

You can even modify the connection pooling of your database.

Alpha Features

A few of the Database features are still in Alpha version.

  • Database Triggers - trigger is a function invoked automatically whenever an event associated with a table occurs.
  • Functions - set of SQL and procedural commands such as declarations, assignments, loops, flow-of-control etc.
  • Function Hooks

Reports

Supabase also has the ability to generate custom reports for your projects. They give a high level overview of your network traffic, user actions, and infrastructure health.

API

Supabase has a wide range of APIs for user Authentication, databases, user management, storage management etc. These APIs are secured by an anonymous API Key.

Check out more on the API reference here.

Client Libraries

Supabase currently supports 3 Client side languages:

  • Javascript
  • Python
  • Dart

The client side sdk has all the functions required for supabase operations to build a Full Stack Application.

Self Hosting

Using Supabase you can even self host the BAAS on your own server. The self-hosted version of Supabase does not include a UI yet. It can be self hosted easily using the Supabase CLI. To get started install the CLI using:

npm install -g supabase
Enter fullscreen mode Exit fullscreen mode

Read more about self-hosting Supabase here.

Is Supabase going to replace Firebase?

So the question you have been looking forward to is this and to this I would straightaway answer "NO!". Supabase is not a 1-to-1 mapping of Firebase. While they are building many of the features that Firebase offers, they are not going about it the same way.

The technological choices are quite different to Firebase. Everything Supabase uses is open source.

Most notably, Supabase uses Postgres rather than a NoSQL store. Currently no other database on the market offers the scalability and functionality required to legitimately compete with Firebase. This is a boon to all those developers who wanted a Backend-As-A-Service(BAAS) with a relational database like PostgreSQL.

But those who still prefer NoSQL structure can go for Firebase as it offers the flexibility of NoSQL store.

Be a part of Supabase

The most beautiful thing about Supabase is it's OpenSource and the code is available publicly on GitHub, so you can easily contribute to it and be a part of Supabase Community.

GitHub
Discord

Discussion (6)

Collapse
appyone profile image
Ewout Stortenbeker

For those looking for a real NoSQL alternative to the Firebase realtime database, check out AceBase which is also free and open source, and can be used as a drop in replacement for the Firebase realtime database with almost no code adjustments

Collapse
somsubhra1 profile image
Somsubhra Das Author

Awesome! :D

Collapse
rahulshaw_dev profile image
Rahul Shaw

Can you explain how can I use realtime database with Supabase please???

Collapse
somsubhra1 profile image
Somsubhra Das Author

You can use the @supabase/realtime-js npm package to achieve the Realtime Database functionalities.

You need to subscribe to the changes of your database or tables shown below:

var usersTable = client.channel('realtime:public:users')
usersTable.on('*', (e) => console.log(e))
usersTable.on('INSERT', (e) => console.log(e))
usersTable.on('UPDATE', (e) => console.log(e))
usersTable.on('DELETE', (e) => console.log(e))
usersTable.subscribe()
Enter fullscreen mode Exit fullscreen mode

Check out the Realtime Supabase docs here.

The python package for Supabase Realtime is not yet implemented.

Collapse
samuelnarciso28 profile image
Samuel Narciso

Wow, it's an amazing alternative. Thank you :D

Collapse
somsubhra1 profile image
Somsubhra Das Author

You're welcome :)