# Event Handling

### **Custom Event Handler**

There are many pages and actions on social.plus UIKit. Pages can be nested inside others and it would be hard to override events on the nested pages. In order to solve this problem, we provide EkoEventHandler which is a behavior controller for actions that happen in UIKit.

### **Supported Events**

| **Event**          | **Parameter** | **Condition**                                                                                                                                                             |
| ------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| onChangePage       | pageName      | onChangePage is called right before UIKit changes the page type which should be rendered. If handler is passed, UIKit relies on it instead of its internal implementation |
| onClickCategory    | categoryId    | Category display name is clicked                                                                                                                                          |
| onClickCommunity   | communityId   | Community display name is clicked                                                                                                                                         |
| onClickUser        | userId        | User avatar or user display name is clicked                                                                                                                               |
| onCommunityCreated | communityId   | New community is created                                                                                                                                                  |
| onEditCommunity    | communityId   | Edit community button is clicked                                                                                                                                          |
| onEditUser         | userId        | Edit user button is clicked                                                                                                                                               |

### **Usage**

To pass handlers into UIKit you need to set the ‘actionHandlers’ prop for AmityUiKitProvider. All handlers are optional. If any is not passed, UIKit will use its own internal implementation.

```javascript
import { AmityUiKitProvider } from '@amityco/ui-kit';

function MyApp() {
  return (
    <AmityUiKitProvider
      actionHandlers={{
        onChangePage: customOnChangePageHandler,
        onClickCategory: customOnClickCategoryHandler,
        onClickCommunity: customOnClickCommunityHandler,
        onClickUser: customOnClickUserHandler,
        onCommunityCreated: customOnCommunityCreatedHandler,
        onEditCommunity: customOnEditCommunityHandler,
        onEditUser: customOnEditUserHandler,
      }}
    >
       ...
    </AmityUiKitProvider>
  );
}
```

You can access any action handler using the `useAmityNavigation`hook.

```javascript
import { useAmityNavigation } from '@amityco/ui-kit';

function MyComponent() {
  const { onClickUser } = useAmityNavigation();

  return (
    <button onClick={() => onClickUser('myUser')}>
       Show My User page
    </button>
  )
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/social-plus-uikit/uikit-3/web/event-handling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
