User Management
View, delete, and export user information.
You can view your users on the Users page of the Dashboard. You can also view the contents of the Auth schema in the Table Editor.
Accessing user data via API
For security, the Auth schema is not exposed in the auto-generated API. If you want to access users data via the API, you can create your own user tables in the public schema.
Make sure to protect the table by enabling Row Level Security and only granting the necessary privileges for each role. Reference the auth.users table to ensure data integrity. Specify on delete cascade in the reference. For example, a public.profiles table might look like this:
create table public.profiles ( id uuid not null references auth.users on delete cascade, first_name text, last_name text, primary key (id));-- Grant the privileges the roles needGRANT SELECT ON public.profiles TO anon;GRANT SELECT, INSERT, UPDATE, DELETE ON public.profiles TO authenticated;GRANT SELECT, INSERT, UPDATE, DELETE ON public.profiles TO service_role;-- Enable row level security for the tablealter table public.profiles enable row level security;Only use primary keys as foreign key references for schemas and tables like auth.users which are managed by Supabase. Postgres lets you specify a foreign key reference for columns backed by a unique index (not necessarily primary keys).
Primary keys are guaranteed not to change. Columns, indices, constraints or other database objects managed by Supabase may change at any time and you should be careful when referencing them directly.
To create a row in your public.profiles table every time a user signs up, set up a trigger. If the trigger fails, it could block signups, so test your code thoroughly.
-- inserts a row into public.profilescreate function public.handle_new_user()returns triggerlanguage plpgsqlsecurity definer set search_path = ''as $$begin insert into public.profiles (id, first_name, last_name) values (new.id, new.raw_user_meta_data ->> 'first_name', new.raw_user_meta_data ->> 'last_name'); return new;end;$$;-- trigger the function every time a user is createdcreate trigger on_auth_user_created after insert on auth.users for each row execute procedure public.handle_new_user();Put the schema in front of every table, function, and type in this function that isn't built in, such as public.profiles. The function sets search_path = '', so Postgres can't find a name like profiles without its schema. The trigger then fails, and every sign-up fails with Database error saving new user. To learn why the search path stays empty, see Security definer vs invoker.
Don't insert the profile from the client after sign-up. The trigger already creates it, and the table has no insert policy, so a client insert fails with new row violates row-level security policy for table "profiles". The trigger can insert the row because the function is security definer: it runs as its owner. A function created in the Dashboard or by a migration is owned by postgres, which bypasses Row Level Security.
With RLS enabled and no policies, the anon and authenticated roles can't read or change any row of public.profiles. The following policies let each signed-in user read and update only their own profile:
-- Each user can read their own profilecreate policy "Users can view their own profile"on public.profiles for selectto authenticatedusing ( (select auth.uid()) = id );-- Each user can update their own profilecreate policy "Users can update their own profile"on public.profiles for updateto authenticatedusing ( (select auth.uid()) = id )with check ( (select auth.uid()) = id );auth.uid() returns the ID of the user making the request. In the update policy, using limits which rows a user can update, and with check stops them from changing the row's id to another user's.
For other patterns, such as profiles that everyone can read, see the Row Level Security guide.
Adding and retrieving user metadata
You can assign metadata to users on sign up:
import { createClient } from '@supabase/supabase-js'const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!)// ---cut---const { data, error } = await supabase.auth.signUp({ email: 'valid.email@supabase.io', password: 'example-password', options: { data: { first_name: 'John', age: 27, }, },})final res = await supabase.auth.signUp( email: 'valid.email@supabase.io', password: 'example-password', data: { 'first_name': 'John', 'age': 27, },);try await supabase.auth.signUp( email: "valid.email@supabase.io", password: "example-password", data: [ "first_name": .string("John"), "age": .integer(27), ])val data = supabase.auth.signUpWith(Email) { email = "valid.email@supabase.io" password = "example-password" data = buildJsonObject { put("first_name", "John") put("age", 27) }}var session = await supabase.Auth.SignUp("valid.email@supabase.io", "example-password", new SignUpOptions{ Data = new Dictionary<string, object> { { "first_name", "John" }, { "age", 27 } }});User metadata is stored on the raw_user_meta_data column of the auth.users table. To view the metadata:
import { createClient } from '@supabase/supabase-js'const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!)// ---cut---const { data: { user },} = await supabase.auth.getUser()let metadata = user?.user_metadatafinal User? user = supabase.auth.currentUser;final Map<String, dynamic>? metadata = user?.userMetadata;let user = try await supabase.auth.user()let metadata = user.userMetadataval user = supabase.auth.retrieveUserForCurrentSession()//Or you can use the user from the current session:val user = supabase.auth.currentUserOrNull()val metadata = user?.userMetadatavar user = supabase.Auth.CurrentUser;var metadata = user?.UserMetadata;Users can edit their own user metadata, so a role or tenant ID stored there lets a user grant themselves access. Any signed-in user can add, overwrite, or remove fields in their user_metadata, and Supabase Auth doesn't check the values. In JavaScript, that's updateUser() with data. Don't use user metadata, including the user_metadata claim in the JWT, in RLS policies or authorization logic.
Store values that users must not change in app_metadata, which is saved in the raw_app_meta_data column. Users can't change it themselves. Set it from a trusted server with your project's secret key, for example with auth.admin.updateUserById(). For more information about both fields, see the user object and auth.jwt() in the Row Level Security guide.
Deleting users
You may delete users directly or via the management console at Authentication > Users. Note that deleting a user from the auth.users table does not automatically sign out a user. As Supabase makes use of JSON Web Tokens (JWT), a user's JWT will remain "valid" until it has expired.
You cannot delete a user if they are the owner of any objects in Supabase Storage.
You will encounter an error when you try to delete an Auth user that owns any Storage objects. If this happens, try deleting all the objects for that user, or reassign ownership to another user.
Removing account access
When the goal is to remove an account so it can no longer access your app, delete the auth user with auth.admin.deleteUser(). With the default shouldSoftDelete: false, this removes the row from auth.users, which cascades to auth.sessions and invalidates the user's refresh tokens — so the account can no longer mint new access tokens.
A few things are not a substitute for deleting the user:
- A temporary ban only blocks sign-in for its duration and does not revoke existing sessions.
- Marking the account as deleted only in your own application tables leaves the
auth.usersrow intact, so it can still authenticate and refresh.
Deleting the user still cannot retroactively invalidate an access token that was already issued. Supabase access tokens are stateless JWTs, so a token already in the user's hands stays valid until its exp claim passes, and during that window the account can still call the API. You have two ways to handle this window:
- Bound it: keep the access token (JWT) expiry short, so any outstanding token expires soon after you delete the user.
- Close it for sensitive operations: validate the
session_idclaim against theauth.sessionstable on those operations. Because deleting the user removes the session row, an outstanding token fails this check — but only on the requests where you perform it; other API calls still accept the token untilexp.
See User sessions for details.
Exporting users
As Supabase is built on top of Postgres, you can query the auth.users and auth.identities table via the SQL Editor tab to extract all users:
select * from auth.users;You can then export the results as CSV.