How I connected Supabase auth.users to my own public.users table
Hello engineers, For the past few days Iāve been trying to set up Supabase as my backendāasāaāservice. It turns out itās a bit more complicated than I expected (surprise :)). The goal is to set up a solid foundation for future development. I want to create tables for users and tenants. Supabase already has a table for users ā auth.users. That table is for authentication: when a user registers in the app, a record is created there. But if I want to connect that user to other tables, I need to access the userās id from the auth.users table, and it looks straightforward: just use auth.users(id). For example, if I want to create a table public.users (for storing additional data for each user), I can do this: CREATE TABLE IF NOT EXISTS public.users ( id UUID PRIMARY KEY REFERENCES auth.users (id) ON DELETE CASCADE, -- additional data for a user full_name TEXT, avatar_url TEXT, created_at TIMESTAMPTZ DEFAULT NOW(), updated_at TIMESTAMPTZ DEFAULT NOW(), tenant_id UUID REFERENCES public.tenants (id) ON DELETE CASCADE ); Now the user is fully linked to the app logic, while still being backed by Supabase Auth.