refreshSession()

Returns a new session, regardless of expiry status. Takes in an optional current session. If not passed in, then refreshSession() will attempt to retrieve it from getSession(). If the current session's refresh token is invalid, an error will be thrown.

1const { data: { user, session }, error } = await supabase.auth.refreshSession()

Parameters#

  • currentSessionoptional
    object

    The current session. If passed in, it must contain a refresh token.

      Properties
    • refresh_tokenrequired
      string

      No description provided.

Notes#

  • This method will refresh the session whether the current one is expired or not.
  • Both examples destructure user and session from data. This is not required; so const { data, error } = is also valid.

Examples#

Refresh session using the current session#

1const { data: { user, session }, error } = await supabase.auth.refreshSession()

Refresh session using a passed-in session#

1const { data: { user, session }, error } = await supabase.auth.refreshSession({ refresh_token })