Read rows safely
Create a `profiles` table query that returns `id` and `username` only for the signed-in user. Add a basic RLS policy note in comments.
Cloud / Knowledge library
open-source backend platform on postgres
Supabase gives developers a fast backend stack (database, auth, storage, realtime, and serverless functions) so they can ship apps without building and operating each backend piece from scratch.
2020: Supabase launched publicly as an open-source Firebase alternative built on PostgreSQL. 2020: The company joined Y Combinator (S20), accelerating early adoption. 2021–2023: Core platform expanded with Auth, Storage, Realtime, and Edge Functions. 2024+: Focus increased on production workflows such as branching, observability, and AI-oriented Postgres use cases.
Work through these exercises in order. Try the task before opening a reference.
Create a `profiles` table query that returns `id` and `username` only for the signed-in user. Add a basic RLS policy note in comments.
Implement sign-up, then insert a starter row into `todos` linked to the new user id. Handle and display both auth and insert errors.
Subscribe to inserts on a `messages` table and render new messages live. Unsubscribe on component unmount to avoid leaks.
Write an Edge Function that verifies JWT, validates JSON input, inserts into `orders`, and returns a safe error shape.
Design a private bucket strategy for user uploads with signed URLs and RLS. Explain how anon and service keys are separated.
A boutique retail chain managing high-turnover inventory across multiple physical locations and a web storefront.
The business suffers from overselling items because their legacy database lacks a mechanism to push stock updates to client devices instantly, leading to manual reconciliation costs and customer dissatisfaction.
Supabase provides a managed Postgres database with built-in Realtime functionality, allowing the application to broadcast database changes directly to connected client sessions without polling.
This diagram illustrates how database changes propagate to the client.
Stores inventory rows
Listens for DB changes
Displays live stock
Updates inventory
This code demonstrates subscribing to database changes in the Real-time Inventory Sync for Boutique Retail scenario to update the UI instantly when stock levels change.
const channel = supabase.channel('inventory-updates')
.on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'inventory' }, payload => {
console.log('Stock changed:', payload.new) // Update UI state dynamically
})
.subscribe()The storefront reflects accurate, live inventory counts across all user sessions, effectively eliminating the risk of overselling popular items.
Realtime subscriptions consume database connection slots and memory; developers must monitor the number of active channels to ensure the database remains performant under heavy concurrent load.