> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.openfort.io/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# `useSignOut`

Sign out users and reset the provider state. Calling `signOut` ends the Openfort session, then clears the cached user, linked accounts, and embedded-account state. When an Ethereum connector is attached, it is disconnected and reset too, so no external wallet stays bound to the previous user.

## Usage

```tsx
import { useSignOut } from '@openfort/react';

function LogoutButton() {
  const { signOut, isLoading } = useSignOut();

  const handleSignOut = async () => {
    const result = await signOut();
    if (result.error) return console.error(result.error.shortMessage);
    // result is {} on success
  };

  return (
    <button onClick={() => void handleSignOut()} disabled={isLoading}>
      {isLoading ? 'Signing out...' : 'Sign out'}
    </button>
  );
}
```

## Return value

| Property | Type | Description |
| :--- | :--- | :--- |
| `signOut` | `(options?: OpenfortHookOptions) => Promise<{ error?: OpenfortError }>` | Signs the user out. Resolves to `{}` on success and `{ error }` on failure. |
| `isLoading` | `boolean` | True while a `signOut` call is in flight. |
| `isError` | `boolean` | True when the last call failed. |
| `isSuccess` | `boolean` | True when the last call succeeded. |
| `error` | `OpenfortError \| null \| undefined` | The error from the last failed call, `undefined` before any failure. |

## Parameters

Both `useSignOut(hookOptions?)` and `signOut(options?)` take the same shape. Hook-level callbacks run first, then the per-call ones.

```ts
type OpenfortHookOptions<T = { error?: OpenfortError }> = {
  onSuccess?: (data: T) => void
  onError?: (error: OpenfortError) => void
}
```

`onSuccess` receives an empty object — sign-out returns no data. A callback that throws or rejects is logged and never changes the result of the operation.

## Errors

`signOut` never rejects, so a `try`/`catch` around it catches nothing. Failures arrive as `{ error }` and through `onError`. The error is an `AuthenticationError` with `shortMessage: 'Failed to sign out.'`; the original failure is kept on `error.cause`, and its message on `error.details`.

```tsx
const { signOut } = useSignOut({
  onError: (error) => {
    console.error(error.shortMessage, error.details);
  },
});
```

:::warning
Success is only reported once the session is actually revoked. Don't redirect on the click — await `signOut` and branch on the result, or the user can land on a signed-out route while the session is still live.
:::

## Related

* [useUser](https://www.openfort.io/docs/products/embedded-wallet/react/hooks/useUser)
* [useGuestAuth](https://www.openfort.io/docs/products/embedded-wallet/react/hooks/useGuestAuth)
* [useOpenfort](https://www.openfort.io/docs/products/embedded-wallet/react/hooks/useOpenfort)
