A function that runs automatically when a specific database event happens, like inserting, updating, or deleting a row.
A database trigger is a function that runs automatically when a specific event happens in your database — like an INSERT, UPDATE, or DELETE on a table.
Triggers are powerful because they let you automate backend logic without writing any frontend code. For example, in Threadly's notifications system, a trigger fires every time a comment is inserted. It automatically creates a notification for the post author — no API call needed.
A trigger has two parts:
Triggers run inside the database, so they're fast and reliable. They use Supabase's service role to bypass RLS when needed (like creating a notification for another user).
Triggers work alongside migrations (you create them via SQL), foreign keys (triggers often reference related tables), and RLS policies (triggers can bypass RLS using the service role).
Learn the concepts, fix things with confidence, and ship real products with AI beside you. No coding background required, and we're with you from the first idea to launch.
Free to start. No card. Leave whenever you want.