getUser()

Gets the current user details.

This method is called by the GoTrueClient update where the jwt is set to this.currentSession.access_token and therefore, acts like getting the currently authenticated user

1const { user, error } = await supabase.auth.api.getUser(
2  'ACCESS_TOKEN_JWT',
3)

Parameters#

  • jwtrequired
    string

    A valid, logged-in JWT. Typically, the access_token for the currentSession

Notes#

  • Fetches the user object from the database instead of local storage.
  • Note that user() fetches the user object from local storage which might not be the most updated.
  • Requires the user's access_token.

Examples#

Fetch the user object using the access_token jwt.#

1const { user, error } = await supabase.auth.api.getUser(
2  'ACCESS_TOKEN_JWT',
3)