← Back to Tutorials Chapter 1

Introduction

What is Supabase?

Supabase is an open-source backend-as-a-service (BaaS) that positions itself as a Firebase alternative. Unlike Firebase which uses NoSQL document stores, Supabase is built on PostgreSQL — one of the most powerful and battle-tested relational databases in the world. It gives you a full PostgreSQL database, an auto-generated REST API, realtime subscriptions, authentication, and file storage out of the box.

Because Supabase is open-source, you can self-host it on your own infrastructure or use the managed cloud offering at supabase.com. The project started in 2020 and has grown rapidly, becoming the go-to backend for developers who want the convenience of a BaaS without sacrificing the power of SQL.

How Supabase Works

Every Supabase project is a dedicated PostgreSQL database instance. When you define tables, Supabase automatically generates a REST API using PostgREST, a realtime API using the Realtime engine, and integrates authentication via GoTrue. This means you don't write backend code for basic CRUD operations — the APIs are generated for you.

The workflow is straightforward: define your database schema with SQL or the Table Editor, then use the Supabase client library in your frontend to read and write data. The same database handles your relational data, user sessions, file metadata, and realtime subscriptions.

Supabase vs Firebase

Feature Supabase Firebase
Database Type PostgreSQL (relational) Firestore / Realtime DB (NoSQL)
Query Language SQL + REST API SDK methods only
Open Source Yes (MIT license) No (proprietary)
Self-Hostable Yes No
Realtime WebSocket-based SDK-based
Auth Providers 50+ (GoTrue) 10+ (Firebase Auth)
File Storage S3-compatible Google Cloud Storage
Free Tier 500MB DB, 50MB storage 1GB Firestore, 5GB storage

Architecture Overview

Supabase is a collection of open-source tools working together:

Key Features

PostgreSQL at the Core
PostgreSQL is the backbone of Supabase. Unlike Firebase's NoSQL model, PostgreSQL gives you relational integrity, powerful querying with SQL, and a mature ecosystem of extensions. If you already know SQL, you already know how to work with Supabase. If you don't, learning SQL is one of the best investments you can make as a developer — it transfers across every relational database.

When to Use Supabase

Supabase is a great fit when you need a relational data model, want full control over your backend, or prefer open-source tools. It shines in projects that require complex queries, joins, or transactional integrity — things that are awkward in NoSQL databases. It is also ideal if you want to avoid vendor lock-in since you can export your PostgreSQL database at any time.

Use Supabase for new projects where you want to move fast without writing a dedicated backend. It also works well as a companion to existing PostgreSQL databases, providing an instant API layer on top of your existing data.

Client Initialization

import { createClient } from '@supabase/supabase-js'

const supabaseUrl = 'https://your-project.supabase.co'
const supabaseAnonKey = 'your-anon-key-here'

const supabase = createClient(supabaseUrl, supabaseAnonKey)

The createClient function takes your project URL and anon key, both found in the API settings of your Supabase dashboard. This single client handles database queries, realtime subscriptions, auth, and storage operations throughout your application.

Exercise
Create a new HTML file and initialize the Supabase client with your project URL and anon key. Use a script tag with the CDN import instead of the npm module. Log the client object to the console to confirm it loads correctly.