---
description: Sign any message with your customers' Comet wallet.
---

# useSignMessage

Since Comet accounts come with a built-in cloud wallet, you can use this wallet to cryptographically sign messages on behalf of the user using the `useSignMessage` hook. The user will be prompted to log in if necessary, and will be asked to confirm the message to be signed (similar to the flow for Metamask or Phantom wallets).

<figure><img src="https://1022787777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx7UAZZXjPWq0hMTFoRdU%2Fuploads%2F2vWlAoynrW18mQuuaYAk%2FScreenshot%202023-01-31%20at%2011.55.59%20AM.png?alt=media&#x26;token=bde4b745-810d-4b05-a013-8d42f9a7faff" alt=""><figcaption></figcaption></figure>

## API

```javascript
const { signMessage } = useSignMessage({ message: '<MESSAGE>' });
```

`signMessage` is a function that can be called later on, which will bring up the confirmation dialog. It returns a successful `Promise` containing the signed message, or a failed `Promise` if the user clicks "Cancel".

## Example

{% code title="App.js" %}
```tsx
import { useSignMessage } from '@comet-labs/react';

function App() {
  const { signMessage } = useSignMessage({ message: 'gm world' });

  return (
    <div className="App">
      <button onClick={signMessage}>
        click here to sign message
      </button>
    </div>
  );
}
```
{% endcode %}
