Supabase gives developers a PostgreSQL database, authentication, instant APIs, real-time subscriptions, storage, and more - all through a unified interface. It’s designed to be easy to use while providing the features and flexibility that developers need.
Supabase is an open-source Firebase alternative that provides all the backend services you need to build a modern web application. It combines the power of PostgreSQL, a robust relational database, with a suite of developer-friendly tools to help you build scalable applications quickly.
Step 1: Create a Supabase project
Go to database.new and create a new Supabase project.
When your projects is up and running, go to the Table Editor, create a new table and insert some data.
or use SQL Editor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
-- Create the table create table persons ( id bigintprimary key generated always asidentity, name text not null ); -- Insert some sample data into the table insert into persons (name) values ('Yousuf Johns'), ('Oliwia Lindsey'), ('Theo Solis'), ('Hardy Hu');
alter table persons enable row level security;
Make the data in your table publicly readable by adding an RLS policy.
1 2 3 4
create policy "public can read persons" on public.persons forselectto anon using (true);
Let’s build a simple todo application to demonstrate how Supabase works in practice.
Step 1: Create a supabase project
1 2 3 4 5 6 7
-- Create the table CREATE TABLE todos ( id UUID PRIMARY KEYDEFAULT uuid_generate_v4(), created_at TIMESTAMPTZ DEFAULT now(), task TEXT NOT NULL, is_complete BOOLEANDEFAULTfalse );
Supabase is built on top of PostgreSQL, one of the world’s most reliable relational databases. This means you get all the power of SQL with extensions like PostGIS for geospatial data, full-text search, and more.
2. Authentication
Supabase provides a full authentication system out of the box. You can easily set up:
Email & password authentication
Magic link sign-ins
Social logins (Google, GitHub, Facebook, etc.)
Phone authentication
3. Auto-generated APIs
One of the most powerful features of Supabase is its ability to automatically generate RESTful and GraphQL-like APIs based on your database schema. No need to write backend code for basic CRUD operations.
4. Real-time Subscriptions
Supabase allows you to listen to changes in your database in real-time, making it perfect for building collaborative applications, live dashboards, and chat applications.
5. Storage
Store and serve large files like images, videos, and documents with Supabase Storage, which includes access controls tied to your authentication system.
6. Edge Functions
Write and deploy serverless functions without having to manage infrastructure.
How It Works
Let’s break down the key parts of this example:
Setting up the Supabase client: We initialize a connection to our Supabase project using our URL and anonymous key.
Authentication: While not shown in this basic example, Supabase makes it easy to add user authentication with just a few lines of code.
Database operations: We’re using Supabase’s automatically generated APIs to:
Fetch todos with supabase.from('todos').select('*')
Add a new todo with supabase.from('todos').insert([{...}])
Update a todo with supabase.from('todos').update({...}).eq('id', id)
Delete a todo with supabase.from('todos').delete().eq('id', id)
Real-time subscriptions: We set up a subscription to receive real-time updates when the todos table changes, ensuring the UI always displays the latest data.
Beyond the Basics
This simple todo app just scratches the surface of what Supabase can do. You can extend it with:
User authentication to make personal todo lists
Row-level security to protect user data
Storage for file attachments
Edge functions for custom server-side logic
Conclusion
Supabase provides a comprehensive backend solution that allows frontend developers to build full-stack applications without having to write and manage complex backend code.
Its open-source nature, PostgreSQL foundation, and developer-friendly tools make it an excellent choice for projects of all sizes.
Whether you’re building a small side project or a large-scale application, Supabase offers the flexibility and features you need to bring your ideas to life quickly.