Home

Retrieve a user

Gets the current user details if there is an existing session.

  • This method fetches the user object from the database instead of local session.
  • This method is useful for checking if the user is authorized because it validates the user's access token JWT on the server.
  • Should be used only when you require the most current user data. For faster results, getSession().session.user is recommended.
Parameters
  • jwt
    Optional
    string

    Takes in an optional access token jwt. If no jwt is provided, getUser() will attempt to get the jwt from the current session.


const { data: { user } } = await supabase.auth.getUser()