getUser()

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

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

Parameters#

  • jwtoptional
    string

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

Notes#

  • This method gets the user object from the current session.
  • Fetches the user object from the database instead of local session.

Examples#

Get the logged in user with the current existing session#

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

Get the logged in user with a custom access token jwt.#

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