Logging users out
To log a user out, use the logout
method from the usePrivy
hook:
Example Logout Button
import { usePrivy } from '@privy-io/react-auth';
function LogoutButton() {
const { logout } = usePrivy();
return <button onClick={logout}>Log out</button>;
}
tip
If a user has connected a wallet to your site, logging the user out will not disconnect their wallet. Users can only disconnect their wallet from your site through their wallet. Similarly, if a user disconnects their wallet from your site manually, Privy will not automatically log the user out.