Implementing sign out
- ReactJS
- Angular
- Vue
The signOut
method revokes the session for the user.
import Session from "supertokens-auth-react/recipe/session";
async function logout () {
await Session.signOut();
window.location.href = "/";
}
The signOut
method revokes the session on the frontend and backend.
import React from "react";
import { signOut } from "supertokens-auth-react/recipe/thirdpartyemailpassword";
function NavBar() {
async function onLogout() {
await signOut();
window.location.href = "/";
}
return (
<ul>
<li>Home</li>
<li onClick={onLogout}>Logout</li>
</ul>
)
}
The signOut
method revokes the session for the user.
import Session from "supertokens-auth-react/recipe/session";
async function logout () {
await Session.signOut();
window.location.href = "/";
}
- We do not provide any UI for a Sign-out button
- 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.