---
sidebar_position: 2
title: Socket Listening Guide
sidebar_label: Listening
---

# Listening

Use the `listen` method to start the listening for incoming events.

```tsx
type ChatMessageType = {
  message: string;
};

const onChatMessage = socketInstance.createListener<ChatMessageType>()({
  name: "chat-message", // name of the event
});

onChatMessage.listen((message) => {
  console.log(message); // ChatMessageType
});
```
