> For the complete documentation index, see [llms.txt](https://docs.cometh.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cometh.io/integrations/react-hooks/session-keys/usesessionkeysigner.md).

# useSessionKeySigner

## Returns:

| Property  | Type                                               | Description                                                                   |
| --------- | -------------------------------------------------- | ----------------------------------------------------------------------------- |
| data      | SafeSigner<"safeSmartSessionsSigner"> or undefined | The session key signer if it was successfully created, otherwise undefined.   |
| error     | Error or null                                      | An error object if the signer creation failed, otherwise null.                |
| isPending | boolean                                            | A boolean indicating whether the signer is currently being created.           |
| isSuccess | boolean                                            | A boolean indicating whether the session key signer was successfully created. |
| isError   | boolean                                            | A boolean indicating whether an error occurred during the signer creation.    |

## Usage Example:

```typescript
import { useSessionKeySigner } from "path/to/hook";

const Component = () => {
  const { data: sessionKeySigner, error, isPending, isSuccess, isError } =
    useSessionKeySigner({
      sessionData: { permissionIds: [...], action: "...", sessions: [...] },
      privateKey: "0xYOUR_PRIVATE_KEY",
    });

  if (isPending) return <p>Initializing session key signer...</p>;
  if (isError) return <p>Error: {error?.message}</p>;

  return (
    <div>
      {isSuccess && <p>Session Key Signer Initialized!</p>}
      <button
        onClick={() => {
          if (sessionKeySigner) {
            // Example usage: signing an operation
            console.log("Session Key Signer:", sessionKeySigner);
          }
        }}
      >
        Use Session Key Signer
      </button>
    </div>
  );
};
```

## How It Works:

The hook follows these steps to create the session key signer:

1\. Uses the smartAccountClient obtained from useSmartAccount.

2\. Extends the client using smartSessionActions and erc7579Actions.

3\. Converts the smart account into a session signer using the toSmartSessionsSigner utility.

4\. Returns the signer, which can then be used to sign permissioned operations.

Example of Expected Response:

```typescript
{
  "type": "safeSmartSessionsSigner",
  "signer": "Signer instance with session capabilities"
}
```

## Error Handling:

If an error occurs during the creation of the session key signer, the error object will provide information about what went wrong. This can be used to display helpful error messages to the user.

## Customization:

The query is controlled using wagmi’s useQuery. You can pass additional options (e.g., enabling/disabling the query dynamically) as needed.
