> ## Documentation Index
> Fetch the complete documentation index at: https://docs.towns.com/llms.txt
> Use this file to discover all available pages before exploring further.

# useSendMessage

Hook to send a message to a stream. Can be used to send a message to a channel or a dm/group dm.

## Imports

```ts theme={null}
import { useSendMessage } from '@towns-protocol/react-sdk'
```

## Definition

```ts theme={null}
function useSendMessage(
  streamId: string,
  config?: ActionConfig<Channel["sendMessage"]>,
): {
    data: {
        eventId: string;
    } | undefined;
    error: Error | undefined;
    isPending: boolean;
    isSuccess: boolean;
    isError: boolean;
    sendMessage: (message: string, options?: {
        threadId?: string;
        replyId?: string;
        mentions?: PlainMessage<ChannelMessage.Post.Mention>[];
        attachments?: PlainMessage<ChannelMessage.Post.Attachment>[];
        appClientAddress?: string;
    } | undefined) => Promise<{
        eventId: string;
    }>;
}
```

**Source:** [useSendMessage](https://github.com/towns-protocol/towns/blob/main/packages/react-sdk/src/useSendMessage.ts)

## Parameters

### streamId

* **Type:** `string`

The id of the stream to send the message to.

### config

* **Type:** `ActionConfig<Channel["sendMessage"]>`
* **Optional**

Configuration options for the action.

## Return Type

The sendMessage action and the status of the action.

```ts theme={null}
{
    data: {
        eventId: string;
    } | undefined;
    error: Error | undefined;
    isPending: boolean;
    isSuccess: boolean;
    isError: boolean;
    sendMessage: (message: string, options?: {
        threadId?: string;
        replyId?: string;
        mentions?: PlainMessage<ChannelMessage.Post.Mention>[];
        attachments?: PlainMessage<ChannelMessage.Post.Attachment>[];
        appClientAddress?: string;
    } | undefined) => Promise<{
        eventId: string;
    }>;
}
```
