getUserById()

Get user by id.

1const { data, error } = await supabase.auth.admin.getUserById(1)

Parameters#

  • uidrequired
    string

    The user's unique identifier

    This function should only be called on a server. Never expose your service_role key in the browser.

Notes#

  • Fetches the user object from the database based on the user's id.
  • The getUserById() method requires the user's id which maps to the auth.users.id column.

Examples#

Fetch the user object using the access_token jwt.#

1const { data, error } = await supabase.auth.admin.getUserById(1)