­čÄäSupabase and FireBase - You might not need a backend­čîč

Dec 8, 2023

Back to 2023 Advent Calendar

Static websites

First, let's build on the idea of static websites. We talked about that in one of the previous Advent 2023 posts. And the benefits of Static websites are:

  1. they are fast
  2. they are secure
  3. they are cheap to host
  4. they are easy to deploy

Static websites with dynamic content

But what if you want to have dynamic content on your website? Then, there are couple options:

  1. you can use a static site generator like Next.js or Gatsby and regenerate a site with a new content.
  2. you can use a headless CMS like Contentful or Sanity and fetch content from there.

What if you want user authentication?

Then, you can use

  1. Auth0
  2. Netlify Identity.
  3. Firebase Auth
  4. Supabase Auth

What if you want to store data?

Then, again, you can store the data directly from your browser to Firebase or Supabase.

But what about security????

That is actually an interesting part. With Firebase or Supabase you pass keys from the browser. However, you can restrict access to the database to only authenticated users. And data is usually scoped to a specific user.

Firebase achieves it using hierarchical data structure. Where you'd have a root node for a user; and all user data would be stored under that node. Then you'd setup rules to allow access to that node only to the authenticated user (owner of the data).

Supabase achieves it using row level security. Where you'd have a table with a user id column. And you'd setup rules to allow access to the table only to the authenticated user (owner of the data).

What are other things I Can do with Firebase or Supabase?

You can do a lot of things with Firebase or Supabase:

  1. you can store data and files (images, videos, etc)
  2. you can send emails
  3. you can authenticate users