0
Challenge · 46Auth: Who Is Asking?
auth.users vs profiles & the new-user trigger
Authused in ~95% of apps
Every Supabase app needs a users table with a username, a bio, an avatar — and Supabase already gives you a users table. The trap is reaching for it: auth.users is a schema you do not own, cannot alter, and should barely touch, and the moment you try to join it into a normal query you find out the hard way. The fix is one small, completely automatic piece of database plumbing that most tutorials wave at and few actually explain: a trigger that watches auth.users and quietly builds the table you actually wanted, the instant a person signs up.
Core idea. auth.users is Supabase-managed: only its id (a stable uuid) is guaranteed not to change shape under you, so you never build app features directly against it. Instead you keep your own public.profiles table, keyed 1:1 to auth.users(id), and you populate it automatically with an AFTER INSERT trigger on auth.users that runs a SECURITY DEFINER function — because the role that actually performs a signup has no privileges on your public schema at all, so only a function running as its owner can bridge the two.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
on_auth_user_created trigger
auth.usersSupabase-managed
empty
public.profilesyour table
empty
AFTER INSERT trigger
Click Sign up. Supabase's Auth service inserts one row into auth.users — a schema your migrations don't own.
↑ play a little first, then dig in