naystack - v1.5.10
    Preparing search index...

    Function useLogout

    • Returns a logout function that clears the token in context and sends DELETE to the auth endpoint with credentials. The token is cleared immediately (optimistic), and the DELETE request runs in the background.

      Returns (data?: object) => Promise<void>

      A function (data?) => Promise<void>. Call with optional body (forwarded to the server's onLogout callback). Token is cleared immediately.

      import { useLogout } from "naystack/auth/client";

      function SettingsPage() {
      const logout = useLogout();
      const router = useRouter();

      return (
      <button onClick={() => { logout(); router.push("/login"); }}>
      Log out
      </button>
      );
      }