Skip to main content

Crono Logout

What Is this?

This custom hook allows you to logout the user from a matchplat application.

useCronoLogout

You can use this custom hook only if the user is logged in. This custom hook returns a js promise

import { useCronoLogout } from "@matchplat/crono";

const MyComponent = () => {
const { logout } = useCronoLogout();

const logoutUser = () => {
//insert a loader if needed
logout().then(() => console.log("logged out"));
};

return <button onClick={() => logoutUser()}>Logout</button>;
};

export default MyComponent;

This hook automatically redirects the user to the login page.

It also manages the difference between dev environment and prod environment by redirecting the user to the relevant login page.

For more information on methods, read Methods