Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseβ€’5mo agoβ€’
59 replies
Light

Can't get auth trigger working

I can't seem to get the auth trigger working... I feel like an idiot and I see that a lot of other people are running into the same issue as me.

I tried checking out some of the solutions on here, and I tried following the example from your YouTube channel, but I'm having no luck. No errors, no nothing... I don't even know how to debug this
Video I referenced - https://www.youtube.com/watch?v=tNhg-DhvyC8&

This is the code I was trying to use:
CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS TRIGGER AS $$
BEGIN
  INSERT INTO public.profiles (id, email, full_name, avatar_url)
  VALUES (
    NEW.id,
    NEW.email,
    COALESCE(NEW.raw_user_meta_data->>'full_name', NEW.raw_user_meta_data->>'name', split_part(NEW.email, '@', 1)),
    NEW.raw_user_meta_data->>'avatar_url'
  );
  RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.handle_new_user();
CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS TRIGGER AS $$
BEGIN
  INSERT INTO public.profiles (id, email, full_name, avatar_url)
  VALUES (
    NEW.id,
    NEW.email,
    COALESCE(NEW.raw_user_meta_data->>'full_name', NEW.raw_user_meta_data->>'name', split_part(NEW.email, '@', 1)),
    NEW.raw_user_meta_data->>'avatar_url'
  );
  RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.handle_new_user();


Any help would be greatly appreciate and I'm sorry for this repeated question. Clearly this is an issue a lot of people are having so maybe there is an easier way?
YouTubeCodewithguillaume
Triggers with @Supabase β€” Course part 13
NEW WEBSITE!!!! πŸ‘‰ https://guillaume.ceo

πŸ‘‡

X πŸ‘‰ https://dub.sh/codewithg-x
Repos πŸ‘‰ https://dub.link/repos
Newsletter πŸ‘‰ https://dub.link

πŸ‘‡

😈 Avatar πŸ‘‰ https://codeg.link/headshotpro
πŸ–‡οΈ Forms πŸ‘‰https://codeg.link/tally
🎨 Colors πŸ‘‰ https://codeg.link/colors
πŸ”— Short links πŸ‘‰ https://codeg.link/dub
...
Triggers with @Supabase  β€” Course part 13
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements
Next page

Similar Threads

Can't get SvelteKit + Supabase Auth Working πŸ™
SupabaseSSupabase / help-and-questions
3y ago
Auth.trigger
SupabaseSSupabase / help-and-questions
6mo ago
Auth trigger didn't run locally
SupabaseSSupabase / help-and-questions
10mo ago
Can't get auth to work locally
SupabaseSSupabase / help-and-questions
4y ago