© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
5 replies
Talajax

Using supabase and React Query

Hi, i've just started using React Query and i'm a bit confused about how i should use it with supabase. If someone who already have an experience with it could help me, i would be very much appreciated.

I getting the current user like this

export const getUser = async () => {
  const onFetch = await supabase.auth.getUser();
  const userId = onFetch.data.user?.id;
  let { data, error } = await supabase
    .from("profiles")
    .select()
    .eq("id", userId);
  return error ? error : data;
};

export const useUser = () => {
  return useQuery(["user"], () => getUser());
};
export const getUser = async () => {
  const onFetch = await supabase.auth.getUser();
  const userId = onFetch.data.user?.id;
  let { data, error } = await supabase
    .from("profiles")
    .select()
    .eq("id", userId);
  return error ? error : data;
};

export const useUser = () => {
  return useQuery(["user"], () => getUser());
};


And at the profile screen i'm trying to display the user as
  const { data, isLoading } = useUser();
  const { data, isLoading } = useUser();


But when i try to display any info typescript throws an error. How should i get user info?
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Issues with Login Conditional Using Supabase and React
SupabaseSSupabase / help-and-questions
3y ago
Supabase query
SupabaseSSupabase / help-and-questions
4y ago
Get supabase project name using SQL query
SupabaseSSupabase / help-and-questions
4y ago
row level security and react query
SupabaseSSupabase / help-and-questions
4y ago