Consumer Authentication

/

Frontend SDKs

/

Headless

/

Session Management

/

Revoke Session

Revoke session

Wraps Stytch's Revoke Session endpoint and revokes the user's current session. This method should be used to log out a user.

While calling this method, we clear the user and session objects from local storage unless the SDK cannot contact the Stytch servers. This behavior can be overriden by using the optional param object.


Response fields


request_idstring

status_codeint
import React, { useCallback } from 'react';
import { useStytch } from '@stytch/react';

export const LogOutButton = () => {
  const stytch = useStytch();

  const logout = useCallback(() => {
    stytch.session.revoke();
  }, [stytch]);

  return <button onClick={logout}>Log out</button>;
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141"
}