Trigger to update user metadata when some userdata fields update

Right now, I have Supabase setup with a trigger to create an entry in the "userdata" table whenever a new user signs up.

However, I want to also sync some properties from the userdata and into the auth metadata. For example, whether the user has a paid subscription or not.

How would I go about creating a trigger that updates the user's auth metadata when a field in the user's userdata table updates?

As in: If (userdata.plan) changes --> update user metadata.plan
Was this page helpful?