React Native Usage
Embed CredibleMind in a React Native app with @crediblemind/embeddable-react-native.
@crediblemind/embeddable-react-native shows CredibleMind inside a WebView. It uses the same embedding as the web components, with a mobile-friendly layout chosen for you.
Quickstart
Install the package
It needs react-native-webview:
npm install @crediblemind/embeddable-react-native react-native-webviewRender it in a screen
import CMEmbeddable from '@crediblemind/embeddable-react-native'
export default function WellbeingScreen() {
return <CMEmbeddable clientIdentifier="YOUR_CLIENT_IDENTIFIER" env="demo" components="topics" />
}Verify it works
Run the app and open the screen. The CredibleMind topics browser loads, and tapping a topic opens it inside the screen. If you see Benovo content, clientIdentifier is missing.
Always set clientIdentifier
If clientIdentifier is left out, the package shows the demo client benovo instead of failing, which is easy to miss before release.
Change env to "production" when you go live, as on the web.
Previewing the new experience
To try the upcoming CredibleMind experience in a test build, install the beta and set env="demo":
npm install @crediblemind/embeddable-react-native@beta react-native-webviewIt takes the same props and shows the preview site, embedded.crediblemind.com. It also adds allowsBackForwardNavigationGestures (iOS: swipe from the edge to go back or forward). Keep the current release with env="production" in builds you ship.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
clientIdentifier | string | "benovo" | Your client identifier. |
env | "demo" | "production" | "production" | Which CredibleMind site to show. See env. |
components | string | The page to show, for example "topics" or "topics/anxiety". A single string, not an array. | |
subBrand | string | Sub-brand within your organization. | |
urlParams | string | Extra query parameters for the page, for example "view=carousel&hideheader=true" for list options. | |
showNavigationButtons | boolean | false | Show built-in Back and Forward buttons below the content. |
onNavigationStateChange | ({ canGoBack, canGoForward }) => void | Called when the user navigates, so you can enable your own navigation controls. |
The package fixes the layout for mobile: the bare layout without CredibleMind's header and footer, no sidebar, no listing filters, no hero banner, and 20px 15px padding. The web properties type, styles and controls are not available.
Methods
Pass a ref to call these:
| Method | Description |
|---|---|
goBack() | Go back, if possible. |
goForward() | Go forward, if possible. |
canGoBack() | Whether going back is possible. |
canGoForward() | Whether going forward is possible. |
Custom navigation buttons
Track navigation state with onNavigationStateChange and call the methods through a ref:
import { useRef, useState } from 'react'
import { Button, SafeAreaView, View } from 'react-native'
import CMEmbeddable from '@crediblemind/embeddable-react-native'
export default function WellbeingScreen() {
const embed = useRef(null)
const [nav, setNav] = useState({ canGoBack: false, canGoForward: false })
return (
<SafeAreaView style={{ flex: 1 }}>
<CMEmbeddable
ref={embed}
clientIdentifier="YOUR_CLIENT_IDENTIFIER"
env="demo"
onNavigationStateChange={setNav}
/>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 10 }}>
<Button title="Back" disabled={!nav.canGoBack} onPress={() => embed.current?.goBack()} />
<Button title="Forward" disabled={!nav.canGoForward} onPress={() => embed.current?.goForward()} />
</View>
</SafeAreaView>
)
}For the simplest case, set showNavigationButtons instead.