How the pieces connect
An Edge Function is a Deno runtime that boots per request, separate from your Postgres database and from your client app. Three actors talk to each other: the browser (using the anon key under Row Level Security), the function (using the service role key, which bypasses RLS), and Postgres. The function reaches the database with a second createClient call configured with SUPABASE_SERVICE_ROLE_KEY, so writes that the anon client can't make — flipping an order to paid, inserting an audit row — happen server-side. Database webhooks close the loop the other way: an INSERT, UPDATE, or DELETE on a table fires an HTTP POST to the function URL with the changed row in the body, letting Postgres push work out instead of the client polling. Auth Hooks plug into the sign-up and sign-in path itself rather than reacting after the fact.