AI Agent Component Spec
AI Agent Component Spec
- Package:
@cometchat/chat-uikit-react - Key class:
CometChatUrlsFormatter(extendsCometChatTextFormatter) - Required setup:
CometChatUIKit.init(UIKitSettings)thenCometChatUIKit.login("UID") - Purpose: Auto-detects URLs in text messages and converts them to clickable links
- Sample app: GitHub
- Related: Custom Text Formatter | All Guides
Overview
CometChatUrlsFormatter is a specialized subclass of CometChatTextFormatter designed to automatically detect URLs in text messages and convert them into clickable links, allowing users to navigate to the web addresses effortlessly within your CometChat application.

Usage
CometChatUrlsFormatter utilizes regular expressions to identify URLs and applies styles to make them visually distinct as clickable links. Here’s an example of how to extend the CometChatTextFormatter to create a URL text formatter:
- TypeScript
Customize
When implementing the CometChatUrlsFormatter, you can customize the appearance of links and the behavior when clicked:- Modify the onRegexMatch method to wrap detected URLs in a span element with custom classes for styling.
- In registerEventListeners, define the onUrlClick method to handle opening URLs, tracking analytics, or other custom behavior upon click.
Style
Apply CSS to style your clickable links, for example:Handling Click Events
Implement the onUrlClick method within your formatter class to define custom logic for when a link is clicked:Next Steps
Custom Text Formatter
Build custom inline text patterns.
Message List
Render real-time message threads.
All Guides
Browse all feature and formatter guides.
Sample App
Full working sample application on GitHub.