Skip to content
Discussion options

You must be logged in to vote

Hi Kirti,

Yeah, I ran into the same issue when I was building a similar project.
If you’re using Supabase Auth, you can’t directly query the auth.users table from the client-side for security reasons. But you can do it safely using a Supabase server-side function (like with Supabase Admin API).

Here’s how you can do it 👇

Option 1: Using the Supabase Admin API (server-side only)

import { createClient } from '@supabase/supabase-js'

const supabaseAdmin = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL,
  process.env.SUPABASE_SERVICE_ROLE_KEY // Important: Use Service Role key here
)

async function getUserIdByEmail(email) {
  const { data, error } = await supabaseAdmin.auth.admin.getUs…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kirti737
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants