All posts
Published in Latest Articles

Less Backend With Supabase

Profile image of Atakan Demircioğlu
By Atakan Demircioğlu
Fullstack Developer

Less Backend With Supabase

A new generation of libraries and services is trying to fill the gap and simplify coding a backend by not coding it at all. In this article, we will talk about Supabase.

Less Backend With Supabase image 1

Tables Of Contents:

· What’s Supabase?
· What are the services of Supabase?
 ∘ 1- Authentication Service:
 ∘ 2- PostgreSQL:
 ∘ 3- Realtime:
 ∘ 4- Edge Functions
· Summary

What’s Supabase?

In very basic words, it is an open-source cloud service. It provides a PostgreSQL hoster and BaaS.

BaaS in other words (Backend-as-a-Service) offers a comprehensive set of services like auth, database management, edge functions, and storage.

Also, Supabase says;

Supabase is an open source Firebase alternative for building secure and performant Postgres backends with minimal configuration.

What are the services of Supabase?

1- Authentication Service:

Allows you to authenticate your users in several ways:

  • Email & password.
  • Magic links (one-click logins).
  • Social providers. (Google Login, GitHub login, Apple Login and etc..)
  • Phone logins.

2- PostgreSQL:

Database service directly inherited all the bells and whistles of Postgres — tables, views, functions, row-level security (RLS), etc. Also, it provides a good UI for the SQL editor and it is easy to add new RLS rules. You can save your old queries and generate some basic reports.

Less Backend With Supabase image 2

The best feature or addition to PostgreSQL, we can say they have serverless APIs. Every table, view, and function is automatically mapped to a RESTful and a GraphQL (still Beta) API. For a security best practice, you can open RLS and protect your tables from unauthorized access.

Less Backend With Supabase image 3

In this example, if the user_id matches with the current session’s user_id it allows to delete. If not it rejects the request.

Less Backend With Supabase image 4

3- Realtime:

We can basically say; Broadcast, Presence, and Postgres Changes via WebSockets.

Less Backend With Supabase image 5

  • Broadcast: Send ephemeral messages from client to client with low latency.
  • Presence: Track and synchronize shared state between clients.
  • Postgres Changes: Listen to Postgres database changes and send them to authorized clients.

A channel is the basic building block of real-time and narrows the scope of data flow to subscribed clients. You can think of a channel as a chatroom where participants are able to see who’s online and send and receive messages; similar to a Discord or Slack channel.

It was built with Elixir using the Phoenix Framework.

The server does not guarantee that every message will be delivered to your clients.

4- Edge Functions

Edge Functions are server-side TypeScript functions, distributed globally at the edge — close to your users.

They can be used for listening to webhooks or integrating your Supabase project with third parties like Stripe.

Edge Functions are developed using Deno. The best advantage of edge functions are globally distributed for low latency.

One example to get the location of the user; https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/location/index.ts

Summary

Supabase has a lot of advantages. But if you want to continue with superbase, you need to have a good knowledge of PostgreSQL or a lot of energy to find solutions.

In the customization part, you need to write some codes and add some hacky solutions.

But at the end of the day, for fast productivity superbase is a game changer.