The first step to using embedded Komo content involves fetching the card metadata.
Use the useFetchCardMetadata hook and the Native embed URL copied from the platform to fetch the CardEmbedMetadata.
The CardEmbedMetadata has the information required to render the cover image (imageUrl) and the URL (embedUrl) that the ExperienceModal needs to render the embedded experience.
Note: you can use your own data-fetching patterns if you require more advanced data fetching handling. So long as it produces a CardEmbedMetadata, you can pass that to the other components that you want to use.
import { useFetchCardMetadata } from '@komo-tech/react-native-widgets';// ... rest of your componentconst { data, isLoading, isError } = useFetchCardMetadata({ embedMetaUrl: KomoCardNativeEmbedUrl});// ... use the data.
Render a Card Cover
The CardCover component is used to display the cover image of a Komo card.
It handles loading states, error states, and button display.
The component requires an onClick handler and isLoading state.
The imageUrl and imageAspectRatio props are typically obtained from the CardEmbedMetadata.
import { CardCover } from '@komo-tech/react-native-widgets';// ... rest of your component<CardCover imageUrl={metadata?.imageUrl} imageAspectRatio={metadata?.imageAspectRatio} isLoading={isLoading} isError={isError} onClick={() => doSomethingOnCoverClicked()} metaButtonStyle={metadata?.buttonStyle} containerStyle={{ borderRadius: 8 }}/>;
Using the Experience Modal
The ExperienceModal component is used to display the full Komo experience in a modal overlay.
It handles loading states, error states, and communication with the embedded experience.
The component requires an isOpen state and onClose handler.
A valid embedUrl prop is required for the experience modal to function, and this is typically obtained from the CardEmbedMetadata.
If you have forced OAuth enabled, you also need to pass through the embedAuthUrl from CardEmbedMetadata.
import { ExperienceModal } from '@komo-tech/react-native-widgets';// ... rest of your component<ExperienceModal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)} embedUrl={metadata?.embedUrl} embedAuthUrl={metadata?.embedAuthUrl} loadingTimeoutMs={15000} // Optional: customize loading timeout appId="my-app" // Optional: identify where the content is embedded/>;
Experience Modal example without Card Cover
You can use whichever components you want to build your desired experience.
For example, you can trigger the ExperienceModal without rendering our CardCover.
// ... rest of your componentconst { data, isLoading } = useFetchCardMetadata({ isEnabled, embedMetaUrl: EmbedMetaUrlFromKomoPortal});const [modalOpen, setModalOpen] = useState(false);// other code, e.g. some element that calls setModalOpen(true) after isLoading returns false<ExperienceModal isOpen={modalOpen} onClose={() => { setModalOpen(false); }} embedUrl={data?.embedUrl}/>;
Listening for events from the embedded experience
You can listen for events from the embedded experience by using the onWindowMessage or onKomoEvent props on the ExperienceModal or KomoCardWidget.
The onWindowMessage prop exposes any window.postMessage events from the embedded experience.
Note: User Interaction Events will also appear in the onWindowMessage callback. onKomoEvent is a more convenient way to listen for Komo User Interaction Events from the embedded experience.
Pass custom query parameters (like UTM tracking parameters) to your embedded experiences. This is useful for campaign attribution, A/B testing, and analytics tracking.
import { Platform } from 'react-native';import { KomoCardWidget } from '@komo-tech/react-native-widgets';<KomoCardWidget embedMetaUrl={embedUrl} queryParams={{ utm_source: 'react-native', utm_medium: 'app', platform: Platform.OS, // 'ios' or 'android' app_version: DeviceInfo.getVersion() }}/>;
Technical Details
Query parameters are added directly to the webview URL (no prefix)
All values must be strings
Parameters are available to analytics tools in the embedded experience
Can be combined with formPrefillValues and extensionDataValues
Supports standard UTM parameters and custom parameters
Auth0 Session Transfer
The KomoCardWidget component supports Auth0 authentication through the authPassthroughParams prop.
The ExperienceModal component supports Auth0 authentication through the embedAuthUrl and authPassthroughParams props.
The embedAuthUrl is typically obtained from the CardEmbedMetadata.
Pre-requisites:
Auth0 SSO must be configured on the Komo Hub, and “Force Embed Auth” must be enabled under Embed SDK settings on the hub.
Pass a fresh session transfer token to the authPassthroughParams prop, e.g. session_transfer_token: 'ABC123'.
With this setup, the user will be redirected to Auth0 to authenticate when the experience modal is opened, before being redirected back to the embedded experience.
The session transfer token must be obtained immediately before opening the experience modal, since it has a short 60 second lifespan.
Recommended: Specify webViewProps={{ incognito: true }} to ensure user session state is cleared correctly when changing between different authenticated users.
<KomoCardWidget embedMetaUrl={KomoCardNativeEmbedUrl} authPassthroughParams={new URLSearchParams({ session_transfer_token: 'ABC123' })} webViewProps={{ incognito: true }}/>// or if using the ExperienceModal directly<ExperienceModal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)} embedUrl={metadata?.embedUrl} embedAuthUrl={metadata?.embedAuthUrl} authPassthroughParams={new URLSearchParams({ session_transfer_token: 'ABC123' })} webViewProps={{ incognito: true }}/>
Error handling
If the session_transfer_token passed to Auth0 is used, invalid, or expired, then the users will end up being shown the ExperienceModal errorDisplay, which includes a built-in retry button.
If you don’t provide an errorDisplay override, the retry function will just attempt to reload the experience with the current parameters and will most likely fail again.
We recommend that you provide a custom errorDisplay so that you can handle session_transfer_token regeneration before trying to load the content again.
API Reference
ButtonStyle
Name
Type
Description
Required
text
string?
Text to display on the button
Optional
backgroundColor
string?
Background color of the button
Optional
color
string?
Text color of the button
Optional
CardCover Props
Name
Type
Description
Required
onClick
() => void
The callback for when the cover is clicked
Required
isLoading
boolean
Whether the cover is loading
Required
isError
boolean?
Whether the cover is in an error state
Optional
loader
ReactNode?
Override the default skeleton loader
Optional
errorDisplay
ReactNode?
Override the default error display
Optional
metaButtonStyle
ButtonStyle?
The button style returned from the embed metadata endpoint
Optional
overrideButtonStyle
StyleProp<ViewStyle>?
Override the button style
Optional
overrideButtonTextStyle
StyleProp<TextStyle>?
Override the button text style
Optional
containerStyle
StyleProp<ViewStyle>?
Override the container style
Optional
coverImageStyle
StyleProp<ImageStyle>?
Override the cover image style
Optional
hideCoverButton
boolean?
Whether to hide the cover button
Optional
imageUrl
string?
The url of the cover image
Optional
imageAspectRatio
number?
The aspect ratio of the cover image
Optional
CardEmbedMetadata
Name
Type
Description
Required
title
string?
The title of the card
Optional
imageUrl
string?
URL of the card’s cover image
Optional
imageHeight
number?
Height of the cover image in pixels
Optional
imageWidth
number?
Width of the cover image in pixels
Optional
imageAspectRatio
number?
Aspect ratio of the cover image
Optional
embedUrl
string?
URL for the embedded experience
Optional
embedAuthUrl
string?
URL used to OAuth user before showing the embedded experience
Optional
buttonStyle
ButtonStyle?
Styling for the card’s button
Optional
ExperienceModal Props
Name
Type
Description
Required
isOpen
boolean
Whether the modal is open
Required
onClose
() => void
Callback for when close is requested
Required
embedUrl
string
The URL of the embedded card experience
Required
modalHeader
ReactNode
Override the default modal header
Optional
shareClickUrl
string
Override the url that redirects a user when clicking on a share link
Optional
appId
string
An identifier for the embedded Komo content
Optional
formPrefillValues
Record<string, string>
Prefill values for the form within the experience
Optional
extensionDataValues
Record<string, string | number | boolean | object>
Extension data values for the experience
Optional
loadingIndicator
ReactNode
Override the default loading indicator
Optional
modalProps
ModalProps
Override the default modal props
Optional
loadingTimeoutMs
number
Timeout in milliseconds before showing error state. Defaults to 15000ms