# EventHandlers UNIQUE\_HANDLER\_ID

**URL:** <https://community.sendbird.com/t/eventhandlers-unique-handler-id/7994>\
**Category:** Miscellaneous\
**Tags:** react-native\
**Created:** [August 4, 2023, 12:24pm UTC](https://community.sendbird.com/t/eventhandlers-unique-handler-id/7994 "2023-08-04T12:24:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerald\_Campana](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/gerald_campana/32/4295_2.png) [@Gerald\_Campana](https://community.sendbird.com/u/Gerald_Campana)\
**Post date:** [August 4, 2023, 12:24pm UTC](https://community.sendbird.com/t/eventhandlers-unique-handler-id/7994/1 "2023-08-04T12:24:15Z")

</div>

Hello regarding [Add or remove a channel event handler | Chat JavaScript SDK | Sendbird Docs](https://sendbird.com/docs/chat/sdk/v4/javascript/event-handler/managing-channel-event-handlers/add-or-remove-a-channel-event-handler). How do we define a UNIQUE\_HANDLER\_ID? is it the user id? or just a random unique string? and I also know what is the UNIQUE\_HANDLER\_ID for? how sendbird matches the UNIQUE\_HANDLER\_ID when it published an event.

---

<div class="post-metadata">

**Author:** ![Chinmaya\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/chinmaya_gupta/32/1021_2.png) [@Chinmaya\_Gupta](https://community.sendbird.com/u/Chinmaya_Gupta)\
**Post date:** [August 7, 2023, 8:27am UTC](https://community.sendbird.com/t/eventhandlers-unique-handler-id/7994/2 "2023-08-07T08:27:36Z")

</div>

Hello @Gerald_Campana

Welcome to the Sendbird community!

The UNIQUE\_HANDLER\_ID is a unique identifier that you define for each channel event handler. It can be any string value that you choose. The purpose of the UNIQUE\_HANDLER\_ID is to distinguish between different event handlers that you register.

When an event occurs in a channel, Sendbird uses the UNIQUE\_HANDLER\_ID to match the event with the corresponding event handler. This allows the event handler to receive and handle the event appropriately.

For example, if you register multiple channel event handlers with different UNIQUE\_HANDLER\_ID values, each event handler will only receive events that are matched with its corresponding UNIQUE\_HANDLER\_ID. This allows you to have different event handlers for different purposes or components in your application.

---

<div class="post-metadata">

**Author:** ![Gerald\_Campana](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/gerald_campana/32/4295_2.png) [@Gerald\_Campana](https://community.sendbird.com/u/Gerald_Campana)\
**Post date:** [August 7, 2023, 1:00pm UTC](https://community.sendbird.com/t/eventhandlers-unique-handler-id/7994/3 "2023-08-07T13:00:02Z")

</div>

How Sendbird know which UNIQUE\_HANDLER\_ID it will be sent to? or should I don’t care about it?

---

<div class="post-metadata">

**Author:** ![Chinmaya\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/chinmaya_gupta/32/1021_2.png) [@Chinmaya\_Gupta](https://community.sendbird.com/u/Chinmaya_Gupta)\
**Post date:** [August 7, 2023, 2:46pm UTC](https://community.sendbird.com/t/eventhandlers-unique-handler-id/7994/4 "2023-08-07T14:46:04Z")

</div>

To define a UNIQUE\_HANDLER\_ID, you can assign any unique identifier of your choice. This identifier is used to distinguish between different event handlers when registering multiple concurrent handlers.

When you add a channel event handler using the SendbirdChat.addChannelHandler() method in the Sendbird Chat JavaScript SDK, you need to provide the UNIQUE\_HANDLER\_ID as a parameter. This allows Sendbird to associate the handler with the specified identifier.

You should ensure that each event handler has a unique identifier so that Sendbird can correctly route events to the appropriate handler. It is important to choose a unique identifier to avoid conflicts and ensure that events are delivered to the correct handler.

---

<div class="post-metadata">

**Author:** ![Gerald\_Campana](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/gerald_campana/32/4295_2.png) [@Gerald\_Campana](https://community.sendbird.com/u/Gerald_Campana)\
**Post date:** [August 7, 2023, 2:58pm UTC](https://community.sendbird.com/t/eventhandlers-unique-handler-id/7994/5 "2023-08-07T14:58:56Z")

</div>

I see. so i just need to provide a unique identifier then sendbird will manage that?
