Logging out a user ends their authenticated session, removing their access credentials from the device and requiring them to authenticate again to access protected resources.
To log a user out, use the logout method from the usePrivy hook:
Copy
Ask AI
import { usePrivy } from '@privy-io/react-auth';function LogoutButton() { const { ready, authenticated, logout } = usePrivy(); // Disable logout when Privy is not ready or the user is not authenticated const disableLogout = !ready || (ready && !authenticated); return ( <button disabled={disableLogout} onClick={logout}> Log out </button> );}