list all auth users from supabase

i want to list all auth users from supabase it looks like its not like a regular resource and i dont know how to get it with refine hooks
3 Replies
kapa.ai
kapa.ai4w ago
Hi @danyalutsevich. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To list all authenticated users from Supabase using Refine, you're correct that it's not handled like a regular resource. The auth.users table in Supabase is not directly accessible for security reasons. However, Refine provides a workaround for this using a shadow table called public.users. Here's how you can list all authenticated users: 1. First, make sure you have created a public.users table as described in the Refine Pixels tutorial (https://refine.dev/blog/refine-pixels-3/#22-publicusers-table). 2. Once you have the public.users table set up, you can use the standard Refine hooks to list the users. Here's an example using the useList hook:
import { useList } from "@refinedev/core";

const UserList = () => {
const { data, isLoading } = useList({
resource: "users",
});

if (isLoading) {
return <div>Loading...</div>;
}

return (
<ul>
{data?.data.map((user) => (
<li key={user.id}>{user.email}</li>
))}
</ul>
);
};
import { useList } from "@refinedev/core";

const UserList = () => {
const { data, isLoading } = useList({
resource: "users",
});

if (isLoading) {
return <div>Loading...</div>;
}

return (
<ul>
{data?.data.map((user) => (
<li key={user.id}>{user.email}</li>
))}
</ul>
);
};
This approach allows you to list all users while maintaining the security of the auth.users table. Remember to set up the public.users table and the trigger to automatically create entries in this table when new users sign up, as described in the Refine Pixels tutorial (https://refine.dev/blog/refine-pixels-3/#22-publicusers-table). If you need more detailed user information that's not available in the public.users table, you might need to use Supabase's server-side functions or adjust your database structure to include the necessary information in the public.users table. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@447478993101389824> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
absent-sapphire
absent-sapphireOP4w ago
@kapa.ai it says that this resourse does not exits "relation "public.users" does not exist" @kapa.ai it says that this resourse does not exits "relation "public.users" does not exist"

Did you find this page helpful?