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.
refresh_tokenrequired
string
No description provided.
Properties
Notes#
- This method will refresh the session whether the current one is expired or not.
- Both examples destructure
user
andsession
fromdata
. This is not required; soconst { 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 })