Remote session termination
A user wants to sign out a previously used laptop or phone without accessing that device.
Better Auth · Module
revokeSession manually ends a specific Better Auth session by using its session token. It is useful for terminating a session from a signed-in device other than the one currently in use.
Call the client method with the token belonging to the session that should end. This provides a way to terminate a particular session manually, while broader methods handle other or all sessions.
authClient.revokeSession({ token: string })| Name | Type | Description |
|---|---|---|
token | string | The session token identifying the session to revoke. |
revokeSession to manually terminate a selected session.import { authClient } from "@/lib/auth-client";
await authClient.revokeSession({
token: "session-token",
});Pass the target session's token to revoke that session from a device where the user is signed in.
A user wants to sign out a previously used laptop or phone without accessing that device.
An application provides a security screen listing active sessions and lets the user end one selected entry.
A suspicious or compromised session must be invalidated after the user identifies its token.
Call authClient.revokeSession and provide an object containing the target session token. This manually ends that specific session from a device where the user is signed in.
Follow-up: How would you terminate every session instead? Use authClient.revokeSessions() rather than supplying one token.
revokeSession require?The method identifies the session through its token, so the token must be passed in the token property. It is intended for ending a selected session manually.
Follow-up: How would you revoke every session except the current one? Call authClient.revokeOtherSessions().
Signing out already ends the session automatically, but revokeSession is useful when a user needs to end a session on another device. The caller supplies that session's token.
Follow-up: What persistence detail matters after revocation? With preserveSessionInDatabase enabled, the database row remains instead of being deleted.
revokeOtherSessionsrevokeSessionspreserveSessionInDatabasesignOut