Skip to main content
Version: v2 RC

setSession()

Sets the session data from refresh token and returns current session or an error if the refresh token is invalid.

  const { data, error } = supabase.auth.setSession(refresh_token)

Parameters

  • refresh_tokenrequiredstring

    A refresh token returned by supabase auth.

Notes

  • setSession() takes in a refresh token and uses it to get a new session.
  • The refresh token can only be used once to obtain a new session.
  • Refresh token rotation (see REFRESH_TOKEN_ROTATION_ENABLED) is enabled by default on all projects to guard against replay attacks.
  • You can configure the REFRESH_TOKEN_REUSE_INTERVAL which provides a short window in which the same refresh token can be used multiple times in the event of concurrency or offline issues.

Examples

Refresh the session

Sets the session data from refresh_token and returns current session or an error if the refresh_token is invalid.

  const { data, error } = supabase.auth.setSession(refresh_token)