Supabase - An OpenSource Firebase Alternative
Tags: supabase, opensource, database, postgres
Published: 2021-08-06 05:26:28

[Supabase](https://supabase.io/) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iia440lw66u2qbooom43.png)
Source: [Supabase](https://supabase.io/docs)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pd43u8tyezf6ops85rxm.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b0mff88ha7gd4hrm9f1b.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzztvby4v9tuhae8wude.png)

Supabase allows developers to edit data directly from the dashboard.

![Supabase Table Manager](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l2397tflqdac4xezn359.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cydh135dlev702uzqn23.png)

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

![Authentication Panel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gve3y7x5hwutadzfbiil.png)

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

![Magic Link](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lly0rmc4ouafdthdhj7o.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9unplkiz13k22q8wkl4o.png)

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.

```sql
create policy "Users can only update their own items."
  on items for update using (
    auth.email() = email
  );
```
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2qj0vkgs6w9dcifpaogq.png)

![Storage Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zvclt8s7srml41apbyul.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l3uadjog066ys1if509y.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j6teaa55t9hq4efqx734.png)

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](https://supabase.io/docs).

## 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:

```sh
npm install -g supabase
```
Read more about self-hosting Supabase [here](https://supabase.io/docs/guides/self-hosting).

## 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](https://github.com/supabase/supabase)
[Discord](https://discord.com/invite/AYybku5cUz)