How I Build Applications Faster with Supabase
A practical guide to building faster with Supabase: Postgres with an auto-generated API, auth tied to your tables, realtime changes and storage, all secured with Row Level Security. Covers CLI migrations, safe security definer helpers, Edge Functions vs database functions, connection pooling, plan limits and backups. The SQL was run on Postgres with a stubbed auth schema.

I've built more than my fair share of web applications. For years, that meant stitching together a database provider, an auth service, file storage, a realtime engine and a serverless platform. The glue work could eat a week before any business logic. Then I started using Supabase, and my development speed changed completely. This guide is for full-stack developers who want the same: it shows how the pieces fit, how to secure them and which traps to avoid.
This is part 7 of the Indie Builder Notes series. Part 6, when to pay for tools and when to self-host, explained where Supabase fits in a solo builder's stack. This part shows how to use it.
Key takeaways
- Supabase gives you a full Postgres database with an auto-generated API, auth, realtime and storage that share one security model: Row Level Security.
- Keep every schema change in CLI migration files, and put security definer helpers in a private schema, never in
authorpublic. - Pick connection, backup and plan settings on purpose: the free plan has no daily backups and pauses inactive projects.
What Supabase is
Supabase is a Postgres development platform: every project gets a full Postgres database, plus auth, storage, realtime and Edge Functions built around it. Its docs put it as "a full Postgres database, not a Postgres abstraction." When you use the database, auth, storage and realtime together, they share one security model. That shared model is what saves you time.
The core stack for fast development
You won't use every feature in every project, but four of them form the base of most apps.
Postgres with a generated API
You define tables in SQL or the dashboard. Supabase's REST API is generated by PostgREST and, in the docs' words, "automatically reflected from your database's schema." You don't write CRUD endpoints yourself.
-- A public profile for each user, linked to auth.users
create table public.profiles (
id uuid primary key references auth.users (id) on delete cascade,
username text unique,
avatar_url text
);
alter table public.profiles enable row level security;
-- Reachable through the Data API, for example:
-- GET /rest/v1/profiles?select=*
-- POST /rest/v1/profiles
-- With RLS on and no policies yet, reads return no rows
-- and writes are rejected until you add policies.
Whether a new table is reachable straight away depends on your project's grants. Supabase's "Securing your API" page says existing projects grant new public tables to the API roles by default, and that Supabase is changing the platform default so exposure becomes opt-in. Check your project's Data API settings.
The API alone doesn't decide who sees what. Row Level Security (RLS) does: Postgres policies that decide which rows each user can read or change. Defining access as RLS policies keeps security next to the data, instead of scattering checks across API routes. Handling permissions in application code alone tends to drift out of sync between routes.
Auth that links to your data
Supabase Auth stores users in the auth.users table, in a separate schema. Your own profiles table references that ID with a foreign key, as above. Policies can then call auth.uid() to get the signed-in user's ID from their token.
Syncing user IDs between a separate auth provider and your database is a common source of bugs. Here it's one foreign key: id uuid primary key references auth.users (id).
Realtime changes
Realtime used to mean running a WebSocket server and broadcasting database changes yourself. With Supabase, you subscribe to changes on a table. First add the table to the supabase_realtime publication (a toggle in the dashboard), as the Postgres Changes guide describes.
// Client-side subscription to one team's projects
const channel = supabase
.channel("team-projects")
.on(
"postgres_changes",
{
event: "*", // INSERT, UPDATE and DELETE
schema: "public",
table: "projects",
filter: `team_id=eq.${teamId}`, // narrows events; RLS still decides access
},
(payload) => {
console.log("Change received", payload);
// Update your UI here
}
)
.subscribe((status, err) => {
if (status === "CHANNEL_ERROR" || status === "TIMED_OUT") {
console.error(status, err);
}
});
Checked against @supabase/supabase-js@2.118.0, 2026-10-30, with Node.js 22 (subscription setup only, against a stub URL).
The filter is not a security control. Supabase's docs say filters run on the server so that filtered-out events never leave the database, while RLS is checked for each subscriber. One exception matters: RLS policies are not applied to DELETE events, because Postgres can't check access to a row that no longer exists.
I've used Realtime to build collaborative editors and live dashboards without managing message buses or socket rooms. Know its limits, though. The Postgres Changes guide says it authorizes every event against each subscriber on a single thread. For more than about 3,000 concurrent subscribers on the same changes, they recommend Broadcast instead.
Storage with access control
Supabase Storage uses the same RLS model, through policies on the storage.objects table. The docs say Storage blocks uploads to a bucket until you add RLS policies. Public buckets are readable by anyone with the URL.
Storing a file's URL in your profiles table does not protect the file. Use a private bucket and write policies on storage.objects, for example so each user can upload only into a folder named after their user ID:
create policy "Users upload to their own folder"
on storage.objects for insert
to authenticated
with check (
bucket_id = 'avatars'
and (storage.foldername(name))[1] = (select auth.jwt() ->> 'sub')
);
An earlier version of this post said the profiles table's RLS indirectly controlled access to images. It doesn't; only the bucket type and the storage.objects policies do.
Building for production, not just prototypes
A demo is easy. An app that holds up under real use needs a few habits from day one.
Manage the schema with migrations
The dashboard is great for exploring, but schema changes for a team or production belong in SQL migration files. The Supabase CLI handles this:
supabase init # creates supabase/config.toml
supabase start # runs the local stack
supabase migration new create_projects # creates a timestamped SQL file
supabase db reset # rebuilds the local database from migrations
supabase db push # applies migrations to the linked project
Here is a migration for teams and projects. It enables RLS on every table and adds the policies the app needs:
-- supabase/migrations/<timestamp>_create_projects.sql
create table public.teams (
id uuid primary key default gen_random_uuid(),
name text not null
);
create table public.team_members (
team_id uuid not null references public.teams (id) on delete cascade,
user_id uuid not null references auth.users (id) on delete cascade,
primary key (team_id, user_id)
);
create table public.projects (
id bigint generated by default as identity primary key,
name text not null,
team_id uuid not null references public.teams (id) on delete cascade,
created_at timestamptz not null default now()
);
alter table public.teams enable row level security;
alter table public.team_members enable row level security;
alter table public.projects enable row level security;
create policy "Members can view their teams"
on public.teams for select
to authenticated
using (
id in (
select team_id from public.team_members
where user_id = (select auth.uid())
)
);
-- Without this, the projects policy below can't see any membership rows
create policy "Users can view their own memberships"
on public.team_members for select
to authenticated
using (user_id = (select auth.uid()));
create policy "Users can view projects in their team"
on public.projects for select
to authenticated
using (
team_id in (
select team_id from public.team_members
where user_id = (select auth.uid())
)
);
Two details in this migration are easy to miss. A policy's subquery runs under RLS too, so team_members needs its own select policy, or the projects policy finds no rows. And (select auth.uid()) lets Postgres cache the user ID once per statement, which the RLS guide recommends for performance.
Keeping every schema change in migration files pays off. This practice saved me when I accidentally dropped a column in the UI dashboard during a late-night debugging session. Keep in mind that migrations restore a column's definition, not its data. The data needs a backup, which is covered below.
If you do change something in the dashboard, supabase db diff --schema public prints the SQL for it so you can save it as a migration.
Keep helper functions out of exposed schemas
RLS is non-negotiable: Supabase's RLS guide says to enable it on every table in an exposed schema. Policies stay readable when you move shared logic into a helper function. Put that function in a private schema, not in auth. Since April 2025, Supabase blocks creating functions in the auth, storage and realtime schemas, as its changelog announced. A public function would be callable through the API.
create schema if not exists private;
-- Checks whether the signed-in user belongs to a team
create or replace function private.is_team_member(p_team_id uuid)
returns boolean
language sql
stable
security definer
set search_path = ''
as $$
select exists (
select 1 from public.team_members tm
where tm.team_id = p_team_id
and tm.user_id = (select auth.uid())
);
$$;
revoke execute on function private.is_team_member(uuid) from public;
grant usage on schema private to authenticated;
grant execute on function private.is_team_member(uuid) to authenticated;
-- A cleaner policy using the helper
create policy "Team members can update projects"
on public.projects for update
to authenticated
using (private.is_team_member(team_id))
with check (private.is_team_member(team_id));
The SQL in this post (profiles, storage policy, migration and helper) was run on Postgres (PGlite 0.5.13) with stubbed auth and storage schemas, and the policies were checked as the authenticated role. The CLI commands were not run.
Be careful with security definer. Such a function runs with its owner's privileges, so RLS doesn't limit the queries inside it. Supabase's RLS guide says to keep these functions out of exposed schemas, set search_path = '' and schema-qualify every name. Keep them small, and make them return only a yes or no answer.
Where business logic lives: database or Edge Functions
| Option | Runs | Good for | Trade-off |
|---|---|---|---|
| Database functions (Postgres) | Inside the database | Data-heavy work, joins, logic that must be atomic with a transaction | SQL or PL/pgSQL only; a slow function holds a database connection |
| Edge Functions | Deno, globally distributed | Calling external APIs, webhooks, npm packages | Separate from the database; each data access is a network call |
The docs say Edge Functions are written with Deno and can import npm modules with the npm: prefix. A rule of thumb: if the work touches several rows or tables in one transaction, start with a database function. If it calls the internet or needs a JavaScript library, use an Edge Function.
Common pitfalls and how to avoid them
N+1 queries in client code
The API can fetch related rows in one call through foreign keys, for example select('id, name, team:teams(name)'). PostgREST's docs describe this as including related resources in a single API call. The N+1 problem comes back when your code loops over results and makes one more request per row. Use embedding, or a view or database function for complex joins. Check slow queries with explain in the SQL editor.
Running out of database connections
supabase-js talks to the HTTP Data API, so it doesn't open Postgres connections itself. The limit bites when serverless functions connect to Postgres directly, for example through an ORM. Supabase's connection guide recommends the shared pooler (Supavisor) in transaction mode for serverless and edge functions. Turn off prepared statements, and create the client once at module scope.
Missing Realtime errors
Networks drop. Pass a callback to subscribe() and handle CHANNEL_ERROR and TIMED_OUT, as the JavaScript reference shows. Changes made while a client was offline are not replayed, so as a rule of thumb, refetch the current data after a reconnect.
Fitting Supabase into a larger system
Supabase works well as the core data layer, but most of my projects involve other services too.
Database webhooks send a request to another system when a row is inserted, updated or deleted. Supabase's docs describe them as a wrapper around triggers that uses the pg_net extension, which runs asynchronously so slow requests don't block your writes. A new profile can call an n8n workflow or an AI agent to start onboarding.
Backend services, such as a Python worker using the supabase package, can use a secret key for admin tasks. Supabase's API key docs say a secret key bypasses every RLS policy, and should never go in a browser, a shipped app or source control. Newer projects use sb_publishable_... and sb_secret_... keys; the legacy anon and service_role keys are planned for deprecation by the end of 2026.
Plans and limits to check
These numbers are from Supabase's pricing page on 2026-10-30. Check the page before you choose, because limits change.
| Free | Pro | |
|---|---|---|
| Price | $0 | From $25 a month |
| Database size | 500 MB per project | 8 GB per project, then billed per GB |
| Monthly active users | 50,000 | 100,000, then billed per user |
| File storage | 1 GB | 100 GB, then billed per GB |
| Inactive projects | Paused after 1 week of inactivity | Never paused |
| Daily backups | Not included | Kept for 7 days |
| Point-in-time recovery | Not available | Paid add-on |
Frequently asked questions
Is Supabase production-ready for large applications?
Yes, with planning. The core is standard Postgres, so schema, indexes and queries need the same care as any Postgres database. Supabase runs the infrastructure, but query performance is still your job. Plan connection pooling early, and use Broadcast for very large realtime audiences.
How does Supabase compare to Firebase?
Supabase uses Postgres, a relational database; Firebase's main database, Firestore, is a NoSQL document store. If your data is relational or needs joins and transactions, Supabase fits better. You can also self-host Supabase with Docker Compose, though the docs say self-hosting is community-supported and lacks some managed features such as managed backups.
Can I use Supabase with my existing auth provider?
Yes. Supabase has first-class third-party auth support for Clerk, Firebase Auth, Auth0, AWS Cognito and WorkOS, plus a custom option for any other provider that supports OpenID Connect. Your RLS policies keep working with those users. Moving auth to Supabase Auth is the simpler path if you're starting fresh.
How should I back up my database?
The backups docs say Pro, Team and Enterprise projects get daily backups, and point-in-time recovery is an add-on. Free projects don't get daily backups, and Supabase recommends exporting your data regularly with supabase db dump and keeping copies off-site. Do that on paid plans too for business-critical data.
How do I handle migrations in a team?
Keep every migration in Git and review schema changes in pull requests. Run them against a staging project before production with supabase db push. That gives you review, testing and an audit trail for every change.
The workflow that makes it fast
Start each project with supabase init. Design the schema locally, write RLS policies early, and test everything on the local stack before you deploy. Don't rely on the dashboard alone. Use it for inspecting and monitoring, and keep the schema as code.
That discipline is what turns Supabase from a prototyping tool into a solid production platform. Supabase sped up my development because the time goes into business logic, not into wiring auth or writing basic API routes. Next in the series: GitHub repo hygiene, so the code behind your app looks as maintained as the app itself.
Sources
Verified against the sources below on October 30, 2026. Products and docs change often: check the linked sources if something looks different.
- Supabase Docs: Database overview
- Supabase Docs: REST API
- Supabase Docs: Securing your API
- Supabase Docs: Row Level Security
- Supabase Changelog: Restricting access on auth, storage and realtime schemas
- Supabase Docs: Postgres Changes (Realtime)
- Supabase JavaScript reference: subscribe()
- Supabase Docs: Storage access control
- Supabase Docs: Local development and migrations
- Supabase Docs: Edge Functions
- Supabase Docs: Managing Edge Function dependencies
- Supabase Docs: Connecting to Postgres
- Supabase Docs: Joins and nesting
- PostgREST Docs: Resource embedding
- Supabase Docs: Database webhooks
- Supabase Docs: API keys
- Supabase Docs: Third-party auth
- Supabase Docs: Database backups
- Supabase Docs: Self-hosting
- Supabase: Pricing
All 12 parts in this series
- Part 01Systematic Ideation: How to Engineer Profitable Micro-SaaS Ideas
- Part 0210 Micro-SaaS Ideas Using AI Automation
- Part 03The De-Scoping Algorithm: How to Define an MVP That Actually Ships
- Part 04Pricing 101 for Solo Founders: Stop Undervaluing Your Code
- Part 05The Developer’s Guide to Landing Page Teardowns: Debugging Your Conversion Rate
- Part 06The Pragmatic Automation Stack: When to Pay vs. When to Self-Host
- Part 07How I Build Applications Faster with Supabase
- Part 08Your Code is Good, But Your Repo Looks Abandoned: A Guide to GitHub Hygiene
- Part 09The Feedback Loop: Turning Community Questions into Engineering Assets
- Part 10The Infinite Content Engine: How to Turn 1 Technical Blog Post into 10 Assets
- Part 11Systematizing Creativity: Building an Automated Content Repurposing Pipeline
- Part 12Refactoring My Reality: The Engineer's Guide to Daily Systems
AI Automation Engineer & Salesforce Developer
Salesforce developer since June 2018. I build AI agents, n8n workflows and Salesforce integrations, and write up what holds up in real use.



Comments
Loading comments...