Skip to main content
FieldValue
Package@cometchat/chat-uikit-react-native
Key classCometChatUrlsFormatter (extends CometChatTextFormatter)
Required setupCometChatUIKit.init(UIKitSettings) then CometChatUIKit.login("UID")
PurposeAuto-detects URLs, emails, and phone numbers in text messages and converts them to clickable links
Sample appGitHub
RelatedCustom Text Formatter · Mentions Formatter · All Guides
CometChatUrlsFormatter extends CometChatTextFormatter to detect URLs, email addresses, and phone numbers in text messages and render them as clickable links using React Native’s Linking API.

Features

FeatureDescription
URL detectionAutomatically detects HTTP/HTTPS URLs
Email detectionDetects email addresses and opens mail client
Phone detectionDetects phone numbers and opens dialer
Custom stylingCustomize link text color and font
Native linkingUses React Native Linking API for native behavior

Usage

The CometChatUrlsFormatter is included by default in the UI Kit. You can also create a custom instance with custom styling:

Customization

Use the setStyle method to customize link appearance:

Style Properties

PropertyTypeDescription
linkTextColorColorValueColor of the link text
linkTextFontTextStyleFont styling for link text (fontSize, fontWeight, etc.)

How It Works

The CometChatUrlsFormatter uses regex patterns to detect:
  1. URLs: HTTP and HTTPS links
  2. Emails: Email addresses (opens mailto: link)
  3. Phone numbers: Phone numbers (opens tel: link)
When a link is tapped, it uses React Native’s Linking API to open the appropriate handler:

Combining with Other Formatters

You can use multiple formatters together. The order matters — formatters are applied in sequence:

Next Steps

Custom Text Formatter

Build custom inline text patterns.

Mentions Formatter

Add @mentions with styled tokens.

All Guides

Browse all feature and formatter guides.

Sample App

Full working sample application on GitHub.