Skip to main content

If you are using our backend SDK that is lesser than the following versions, please visit the older documentation link here.

Implementing sign out

The signOut method revokes the session on the frontend and on the backend. Calling this function without a valid session also yields a successful response.

import Session from "supertokens-web-js/recipe/session";

async function logout () {
await Session.signOut();
window.location.href = "/auth"; // or to wherever your logic page is
}
  • On success, the signOut function does not redirect the user to another page, so you must redirect the user yourself.
  • The signOut function calls the signout API exposed by the session recipe on the backend.
  • If you call the signOut function whilst the access token has expired, but the refresh token still exists, our SDKs will do an automatic session refresh before revoking the session.

See also#

Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI