npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lorikeetai/react-native-sdk

v3.2.0

Published

LorikeetCX React Native SDK: the chat widget in a WebView, and in-app voice calls

Readme

@lorikeetai/react-native-sdk

SDK containing embeddable React Native components that renders the LorikeetCX web widget inside a react-native-webview.

Resume, storage and token refresh are host responsibilities; see Resuming a conversation and Identity.

Installation

The three native modules are peer dependencies, so install them alongside the SDK. Name them explicitly rather than relying on your package manager to add them for you: npm and pnpm auto-install peers, but neither Yarn Classic nor Yarn Berry does, and neither fails the install. Classic prints has unmet peer dependency, Berry prints YN0002 ... doesn't provide, and both exit successfully, and the failure surfaces later, when Metro cannot resolve the module. Metro reports one missing module at a time, so install all three at once.

3.x is on latest, so a bare install resolves it. A host already on 1.x or 2.x stays there until it asks for the new major, because no earlier range reaches it.

pnpm add @lorikeetai/react-native-sdk \
  react-native-webview@^13.15.0 \
  react-native-safe-area-context@^5.6.0 \
  react-native-svg@^15.13.0

These are native modules, so rebuild rather than just restarting the bundler: pod install for iOS, a Gradle sync for Android.

The peer ranges are bounded to the major versions this release is built and tested against, so an unpinned install cannot silently resolve to an untested major. Widening them is a change that needs testing, not a version bump.

Upgrading from 2.x

  • The page's header shows by default. hideHeader now defaults to false, so customers get the header that minimises, ends and shows who is answering.
  • The widget draws no header of its own. With hideHeader: true there is no Lorikeet header at all, so hide the page's only under a title bar of your own. Keeping the 2.x header shows how to put the old one back.
  • The page runs under the status bar and home indicator. See The status bar and home indicator. If your screen pads the widget for the safe area itself, stop: the widget does it now, and only for the part of the screen it covers.
  • styles does nothing. It styled the old header's title.
  • "Reopen chat" and "Start new chat" are drawn in your theme, in a bar where the page's header was.

Upgrading from 1.x

Read Upgrading from 2.x as well.

  • Peer dependencies. The three modules above used to arrive transitively. Declare them yourself, and rebuild native.
  • webviewProps now reach the WebView. The drop-in previously discarded them. If you were passing props that silently did nothing, they take effect now.

Basic Usage

import { LorikeetWidgetView } from '@lorikeetai/react-native-sdk'

export default function Screen() {
  return (
    <LorikeetWidgetView
      publicKey="your-public-key"
      authToken="your-auth-token"
      onWebViewMessage={(event) => console.log(event.nativeEvent.data)}
    />
  )
}

Props:

  • publicKey (required): The public key issued for your Lorikeet account. Use the value you were given rather than matching a shape: the format has changed over time, and keys issued under earlier ones keep working
  • authToken (required): Authentication token for the user
  • baseUrl (optional): Base URL for the Lorikeet API (defaults to https://chat.lorikeetcx.ai)
  • customisations (optional): Widget customisation options. Exported as Customisations from this package, so there is nothing else to install
  • language (optional): The language to show the widget in, such as de or pt-BR. Defaults to the device's language. See Language
  • styles (optional): Deprecated. Does nothing since 3.0, because the widget draws no header of its own
  • statusBarStyle (optional): 'light' or 'dark' status bar text while the page's header runs under it. See The status bar and home indicator
  • manageStatusBar (optional): Whether the widget may set the status bar style. Defaults to true. Pass false while its screen is out of sight. See The status bar and home indicator
  • onEvent (optional): What the page reported, as typed events. See Events
  • onWebViewMessage (optional): Handler for raw messages from the webview. Deprecated in favour of onEvent, and still called
  • ticketId (optional): Resume this conversation instead of starting a new one
  • session (optional): The session token that authorises ticketId
  • metadata (optional): Arbitrary context attached to the conversation, for routing or for the agent to read. Survives a resume
  • webviewProps (optional): Forwarded to the underlying WebView. The SDK's defaults for media playback, scaling and the loading state can all be overridden; onMessage is additive, so the SDK reads the bridge first and then calls yours
  • avoidKeyboard (optional): Pads the widget clear of the keyboard. Defaults to true. See The keyboard

The keyboard

Android apps drawn edge to edge, the default for current Expo and React Native apps, no longer resize their window for the keyboard. adjustResize in the manifest does not change that. Nothing shrinks the WebView, so the keyboard covers the composer and the page is never told the keyboard is there.

LorikeetWidgetView handles this itself: it wraps its content in a KeyboardAvoidingView with behavior="padding" on both platforms, and measures its own position so it works below a navigation header or tab bar. On iOS the same padding keeps the page's header on screen. If your screen already makes room for the keyboard, pass avoidKeyboard={false}, or the widget is padded twice.

If you compose the parts yourself, the keyboard is yours. Wrap them in a KeyboardAvoidingView with behavior="padding" on both platforms, and set keyboardVerticalOffset to their distance from the top of the screen. apps/rn-widget-demo/src/components/WidgetPane.tsx shows how: measureInWindow on iOS, and on Android the larger of measureInWindow and measure's pageY, because the first can leave out the status bar and the second stops at the React root. Check it on an Android device: an iOS simulator will not show the problem.

Which header you get

LorikeetWidgetView shows the chat page's own header. It carries the customer's way to minimise or end the conversation, and who is answering. Which controls it offers, and what they are called, depends on the account. Build against "the page's own controls" rather than a fixed set, and ask us what your account serves before reproducing them.

hideHeader: true hides it, and the widget draws nothing in its place. Use it only under a title bar of your own, and give the customer a way out there.

Keeping the 2.x header

2.x hid the page's header by default and drew its own: the title and a new chat icon. To keep that, hide the page's header and render LorikeetWidgetHeader above the widget. New chat is yours to wire: remount the widget with a new key, and clear your stored ticketId and session first if you pass them.

const [chat, setChat] = useState(0)

return (
  <SafeAreaView edges={['top']} style={{ flex: 1 }}>
    <LorikeetWidgetHeader
      onIconPress={() => setChat((previous) => previous + 1)}
      title="Support"
    />
    <LorikeetWidgetView
      authToken={authToken}
      customisations={{ hideHeader: true }}
      key={chat}
      publicKey="your-public-key"
    />
  </SafeAreaView>
)

The status bar and home indicator

The widget draws the chat page under the status bar and the home indicator, or Android's gesture bar, so the page's header reaches the top of the screen in its own colours. It tells the page how much of each it covers, and the page pads its header and footer by that much.

It does this only once the page asks, so a page that cannot pad itself keeps the widget's padding instead. A page asks again every time it loads, and the widget pads it in between. With hideHeader: true the page never asks, and the widget stays below the status bar.

Only the part of the screen the widget covers counts. Below a navigation bar it leaves the top alone, and above a tab bar it leaves the bottom alone. While the keyboard is up the page's footer stops clearing the home indicator, because the keyboard already covers it.

While the page is under the status bar, the widget sets the status bar text to match the header's text, which the page reports from your theme. After a minimise or an end, it matches the bar the widget draws in the header's place. It hands the status bar back as it was when the page stops asking or the widget unmounts.

React Native keeps a status bar style until the component that set it unmounts. If the widget's screen stays mounted out of sight, as a tab in React Navigation does, pass manageStatusBar={false} while it's hidden, or the chat's style stays over the next screen:

const isFocused = useIsFocused()

return <LorikeetWidgetView manageStatusBar={isFocused} {...props} />

On iOS the WebView's form bar is hidden once the page asks, because that page closes the keyboard on a tap on the conversation. An older page keeps the form bar and its Done button. webviewProps.hideKeyboardAccessoryView overrides both.

The page cannot see inside a headerBackground gradient. If yours needs different text behind the status bar than behind the title, for example a gradient that is light at the top and dark under the title, pass statusBarStyle:

<LorikeetWidgetView
  authToken={authToken}
  customisations={{
    theme: { headerBackground: 'linear-gradient(#f4f1ea, #0b6b52)' },
  }}
  publicKey="your-public-key"
  statusBarStyle="dark"
/>

Language

The widget shows its own text, such as buttons, placeholders and system messages, in one of the languages enabled for your account. By default it follows the device, and the platforms differ in how much they tell the page:

  • Android sends the device's whole language list, and the page picks the first one your account has enabled.
  • iOS sends one language, usually the first in the device's list. A customer whose first language your account has not enabled sees your default language, even when a later one in their list is enabled.

If no language matches, the widget uses your account's default language.

If your app has its own language setting, or you want iOS to look past the first language, pass language, a BCP 47 tag:

<LorikeetWidgetView
  publicKey="your-public-key"
  authToken="your-auth-token"
  language="pt-BR"
/>
  • A regional tag falls back to its base language, so pt-BR shows pt where only pt is enabled.
  • A language your account has not enabled is ignored, and the widget follows the device as if you had passed nothing.
  • Changing language reloads the page in the new language. The conversation is kept.
  • language does not translate the voice call screen, LorikeetCallView, which is in English.

If you compose LorikeetWidgetWebView yourself, pass language to LorikeetClient and it is added to the URL that getWebviewUrl builds:

const client = new LorikeetClient({ public_key: publicKey, language: 'de' })

Resuming a conversation

Without ticketId, every mount loads /widget, and /widget mints a new ticket. A customer who closes the app and comes back gets an empty chat while their previous ticket stays open.

The widget reports what you need to resume over the WebView bridge. Store both values, scoped to the customer, somewhere that survives an app restart, and pass them back on the next mount:

const [resume, setResume] = useState<{ ticketId?: string; session?: string }>(
  {},
)

useEffect(() => {
  void loadResumeForCustomer(customerId).then(setResume)
}, [customerId])

return (
  <LorikeetWidgetView
    publicKey="your-public-key"
    authToken={token}
    ticketId={resume.ticketId}
    session={resume.session}
    onWebViewMessage={(event) => {
      const message = JSON.parse(event.nativeEvent.data)
      if (message.type === 'persistLorikeetTicketId') {
        void saveResumeForCustomer(customerId, { ticketId: message.ticketId })
      }
      if (message.type === 'persistLorikeetSession') {
        void saveResumeForCustomer(customerId, { session: message.session })
      }
    }}
  />
)

Pass both or neither. session authorises exactly the ticket it was issued for, and a resume without it fails with CUSTOMER_ID_MISSING.

The SDK does not store these for you, and it does not clear them. On logout, clear your own copy and call the widget's logout(); see Logging out.

While ticketId is set, the header's new-chat icon reloads that conversation rather than starting a new one. To start a new one, clear your stored ticketId and session and let the next mount fall back to /widget.

Events

onEvent reports what the page said, as a LorikeetWidgetEvent:

| Event | Means | | -------------------- | -------------------------------------------------------------------------- | | ready | The conversation is usable | | ticket_created | A ticket this page load created. Once per ticket, never a resume | | customer_message | The customer sent something | | agent_message | The agent replied. markUnread is the page asking for an unread indicator | | close | The page hid itself, with a reason of ended_by_customer or minimised | | conversation_ended | It ended without the customer ending it | | new_chat | The page is asking for a replacement conversation | | persist_ticket_id | Store this, with the session, to resume later | | persist_session | The other half of that pair | | logged_out | /logout cleared this frame. See Logging out | | logout_failed | /logout did not confirm. The widget stays unavailable | | error | A page-level failure. LORIKEET_ERROR_CODES lists the codes |

Names match the web SDK's wherever it has one, so a host integrating both does not learn two vocabularies.

preload_complete is in the union but cannot reach React Native: the preload page posts it to a web parent only. Do not wait on it.

Minimise, end and new chat

close means the page hid itself. It may carry a reason: a minimise keeps the conversation and offers a control that reopens it, an end offers one that starts a replacement. Treat an absent reason as an end, because that is what the widget does.

Do not unmount on close. The end and any CSAT rating are still in flight, and tearing the page down cancels them. The widget hides the chat itself.

After a minimise the widget shows "Reopen chat" where the page's header was, and after an end "Start new chat", both in the header's colours from your theme.

While ticketId is set, the new-chat control reloads that conversation rather than replacing it. To start a new conversation, clear your stored ticketId and session and stop passing them, so the next load falls back to /widget.

The widget handle

Pass a ref to LorikeetWidgetView to reach these.

const widget = useRef<LorikeetWidgetHandle>(null)

widget.current?.getConversation() // { minimised, ticketId?, session? } | null
widget.current?.logout()
widget.current?.reopen()
  • getConversation() reports the conversation the widget is on, which is not always the one the host passed in: a refused resume is replaced, and a new chat replaces the conversation before it. It returns null until the page has reported a ticket, and it can report a ticket with no session, so it supplements the persistence events rather than replacing them.
  • logout() clears this customer's chat from the device. See Logging out.
  • reopen() shows a minimised conversation again, exactly as the customer left it. Nothing reloads and nothing is reported. A no-op unless the widget is minimised, so a host with its own launcher can call it unconditionally.

Logging out

Clearing your own stored ticketId and session is not enough. The chat keeps cookies and its own storage inside the WebView, which native code cannot reach, so the next person on the device can reopen the previous customer's conversation. Only the chat's /logout page can clear those, and only if the WebView is navigated to it.

With the drop-in, call logout() on its ref:

const widget = useRef<LorikeetWidgetHandle>(null)

return (
  <>
    <LorikeetWidgetView {...props} ref={widget} />
    <Button
      onPress={() => {
        widget.current?.logout()
        void clearResumeForCustomer(customerId)
      }}
      title="Sign out"
    />
  </>
)

The widget stays on that page until the chat confirms, and nothing you pass it in the meantime changes that: handing it the next customer's credentials while the clear is still running would unmount the page mid-clear and leave the last customer's cookies on the device. Pass them once logged_out has arrived and the next chat starts normally.

Before that page loads, a conversation that holds a session signs it out on the server, out of sight, since /logout runs in a WebView of its own and can't read it. That takes up to six seconds more. If the conversation reports a session it couldn't sign out, or doesn't answer in time, the logout reports logout_failed and keeps the conversation, out of sight, so calling logout() again asks it again. The third failure clears the device anyway and reports logout_failed with reason: 'signed_in_on_server': the session works until it expires, and the next customer's credentials start their chat as after logged_out.

On iPhone, call logout() while the widget is on screen. iOS runs nothing in a WebView that is off screen and drops the request. So a logout made from another screen, or while the app is in the background, fails every time. The third failure clears the device with the session still live on the server until it expires. If your app logs out from a settings screen, show the widget first, or call logout() again once it is on screen.

A logout that does not confirm within ten seconds of /logout loading reports logout_failed and leaves the widget unavailable rather than opening a chat on a device the previous customer's credentials still unlock. Call logout() again to retry.

That obligation outlives the component. The SDK stores nothing, so a widget unmounted before the clear confirmed, by a screen change or an app restart, comes back with no memory of it and opens a chat normally, on a device whose cookies were never cleared.

So persist the logout before you start it, rather than recording that it failed. Write down the baseUrl, publicKey and cookie-store webviewProps you are clearing, read it at launch, and delete it only once the page has confirmed: logged_out, or logout_failed with reason: 'signed_in_on_server', which arrives only on that confirmation. Keeping the record past either would have the next launch clear the next customer's cookies. A logout_failed without a reason is not enough on its own: unmounting cancels its timer, so an app that dies inside the ten seconds reports nothing at all.

Recovery then has to clear that recorded target rather than whatever the next launch happens to configure. The page drops only that public key's entry, and settings such as sharedCookiesEnabled decide which cookie store it reaches, so clearing another account or another store reports logged_out just the same.

It does not need the customer who left, though. The page needs no authToken, so a host that no longer holds the departed customer's, which after a restart is the normal case, can still clear the device by navigating a WebView to getLogoutUrl() and waiting for its confirmation, as below. Do not reach for the drop-in's logout() here: it clears for whichever credentials are in props and then will not open a chat for them until they change, so calling it with the next customer's props locks that customer out instead of the last one.

If you compose the parts yourself, build the URL and navigate to it:

const client = new LorikeetClient({ public_key: publicKey, api_base: baseUrl })

setUri(client.getLogoutUrl())

Either way, wait for logged_out before treating the device as clean. The WebView's load event does not prove anything: an error page fires it too.

The anonymous customer's long-lived token is deliberately not among these events. It identifies the same anonymous customer for a year, this SDK offers no way to hand one back, and the web SDK keeps the same message inside the frame. A host that genuinely needs it can read the raw bridge, but storing it is storing a credential.

Identity

The public key, base URL and auth token are one unit, and a conversation belongs to the credentials that created it. Never take some of the three from one source and the rest from another, even briefly during a render.

When any of them change, which includes logout and switching environment, clear your stored ticketId and session at the same time. Keeping them across a credential change either resumes the previous customer's conversation on a shared device or sends a ticket id to a backend that has never heard of it.

Anything you load or persist asynchronously needs to be discarded if the credentials moved on while it was in flight; a write that lands late will otherwise put the old conversation back.

App lifecycle

The drop-in handles two failures that a WebView does not recover from on its own:

  • Renderer death. When the OS kills the WebView's content process, the view goes permanently blank with no error. The SDK detects this on both platforms and remounts.
  • A stale stream after a long background. The chat page gives its message stream ten attempts with backoff capped at 30s, then stops trying. If the app was backgrounded past that budget, the SDK remounts on return rather than showing a conversation whose stream is dead. Shorter absences are left alone, so an app switch does not cost the customer a draft message.

In both cases the remount resumes the conversation that was on screen. The SDK watches the bridge for the live ticket and its session, so a conversation created by a mount that had no ticketId is not lost, which is what a naive reload would do: it would load /widget again and mint a second ticket. That memory lasts for the life of the component and is scoped to the credentials that produced it; surviving a process death is still your storage's job.

If you compose the parts yourself rather than using LorikeetWidgetView, both are yours to handle.

Customisation encoding

customisations is serialised as base64 of its UTF-8 bytes, which is what the chat page decodes. Any Unicode is safe, including emoji and typographic punctuation. Earlier versions used the global btoa, which accepts Latin-1 only: a title such as Self's AI Agent with a typographic apostrophe threw during render.

Headless components

Use these to compose the widget yourself. Your layout then owns the safe area, the status bar and the keyboard: the edge-to-edge handling above is LorikeetWidgetView's alone.

LorikeetWidgetHeader

Header component for the widget.

<LorikeetWidgetHeader title='Testing' style={{ fontFamily: 'Inter' ... }} />

Props:

  • title (required): The title text to display
  • style (optional): Style for the header text
  • icon (optional): Clickable icon to be rendered on the right side of the header. Defaults to a new chat icon
  • onIconPress (optional): Callback when the header icon is pressed.

LorikeetWidgetWebView

WebView component that handles the widget content.

<LorikeetWidgetWebView
  uri={url}
  webviewProps={{
      scalesPageToFit: true,
      startInLoadingState: true,
      style: ...
  }}
/>

Props:

  • uri (required): The URI that the web view will load
  • baseUrl (optional): Base URL for the Lorikeet API (defaults to https://chat.lorikeetcx.ai)
  • webviewProps (optional): Passed through to the webview component. The SDK adds external-link handling on onNavigationStateChange and then calls yours

Voice calls (beta)

@lorikeetai/react-native-sdk/voice runs a Lorikeet voice call inside your app with native audio, so the customer can keep talking while the app is in the background. It is a beta, so expect its API to change before it is stable.

Nothing here touches the chat widget. Only the voice entry point loads LiveKit, so an app that never imports it installs nothing new and needs no native rebuild.

Install

The LiveKit packages are optional peer dependencies, so install them yourself:

pnpm add @lorikeetai/react-native-sdk \
  @livekit/react-native@^3.1.0 \
  @livekit/react-native-webrtc@^150.1.0 \
  livekit-client@^2.20.0

@livekit/react-native depends on @livekit/components-react, which needs react-dom. Install the react-dom version that matches your react, or the package manager may pick a newer one that your react does not satisfy.

Do not install @livekit/krisp-noise-filter. The call does not use it, and its license is not open source.

Voice requires React Native 0.79 or later, though the chat widget's peer range is unchanged. The voice subpath is in the package's exports map, and 0.79 ships the first Metro (0.82) that reads that map by default. TypeScript reads it with moduleResolution set to bundler or node16, and Expo's base tsconfig uses bundler.

Native setup

These are native modules. Expo Go does not include them, so use a development build on Expo, and rebuild native code after installing.

With Expo SDK 56 or later, add the two config plugins, the iOS microphone string and audio background mode, and the Android audio permissions to app.json, then run expo prebuild:

npx expo install @livekit/react-native-expo-plugin @config-plugins/react-native-webrtc
{
  "expo": {
    "platforms": ["ios", "android"],
    "plugins": [
      "@livekit/react-native-expo-plugin",
      "@config-plugins/react-native-webrtc"
    ],
    "ios": {
      "infoPlist": {
        "NSMicrophoneUsageDescription": "Talk to our support team.",
        "UIBackgroundModes": ["audio"]
      }
    },
    "android": {
      "permissions": [
        "android.permission.RECORD_AUDIO",
        "android.permission.MODIFY_AUDIO_SETTINGS"
      ]
    }
  }
}

Set platforms to iOS and Android. Expo treats an app with react-dom installed as web-capable, so expo export would also try a web bundle, which LiveKit's native modules cannot build.

Use version 1.1.0 or later of @livekit/react-native-expo-plugin. It adds the livekit/podspecs CocoaPods source, which LiveKit's iOS pods need once CocoaPods trunk stops accepting new pods on 2 December 2026.

Without Expo, follow LiveKit's installation steps. Add the livekit/podspecs source to your Podfile, call LiveKitReactNative.setup in MainApplication and LivekitReactNative.setup in AppDelegate, and add the same permissions and background mode as above.

On Android, the microphone keeps working in the background only while your app runs a foreground service of type microphone, which the SDK does not start for you. Without one, the agent can still be heard, but the customer's microphone goes silent when the app leaves the foreground.

Usage

Your backend creates the session with POST /v1/conversation/voice/web/create, using your API credentials, and returns its { conversationId, wsUrl, token } to the app. Never put your API credentials in the app.

Call screen

LorikeetCallView draws the web Voice Widget's call screen, with its copy. It shows the logo, the title, the call status and clock, the call wave, and the start, mute, speaker and end buttons. Every control has an accessibility label, and screen readers hear each change in the call.

import { LorikeetCallView } from '@lorikeetai/react-native-sdk/voice'

const getSession = async () => {
  const response = await fetch('https://api.example.com/support/call', {
    method: 'POST',
  })
  if (response.status === 404) return null
  if (!response.ok) throw new Error(`Call session: ${response.status}`)
  return response.json()
}

export function SupportCallScreen() {
  return (
    <LorikeetCallView
      customisations={{
        title: 'Acme support',
        theme: { brandColor: '214 100% 50%' },
      }}
      getSession={getSession}
    />
  )
}

The view runs the call itself, so the call ends when the view unmounts. To keep a call going across screens, run useLorikeetCall above them and build the screen yourself.

It takes the hook's getSession and onError, a style for its outer view, and these customisations, as the chat widget reads them:

  • title: the heading. Defaults to "Lorikeet AI Agent".
  • logoUrl: the image above the heading, PNG, JPEG or SVG. Defaults to the Lorikeet mark. An SVG is drawn only when the URL's path ends in .svg.
  • useSubtleBranding: hides "Powered by Lorikeet".
  • theme: colorMode, brandColor, brandAccentColor, subtleBrandColor, backgroundColor, textColor and inverseTextColor, as the web Voice Widget reads them. background and headerBackground apply when they are plain colours. React Native cannot draw a CSS gradient, so a gradient falls back to backgroundColor or brandAccentColor. fontFamily and fontUrl do not apply.

Your own call screen

useLorikeetCall runs the call without any UI.

import { Button, Text, View } from 'react-native'

import { useLorikeetCall } from '@lorikeetai/react-native-sdk/voice'

export function SupportCall() {
  const call = useLorikeetCall({
    getSession: async () => {
      const response = await fetch('https://api.example.com/support/call', {
        method: 'POST',
      })
      if (response.status === 404) return null
      if (!response.ok) throw new Error(`Call session: ${response.status}`)
      return response.json()
    },
    onError: (cause) => console.warn('Support call failed', cause),
  })

  return (
    <View>
      <Text>{call.state}</Text>
      {call.state === 'idle' || call.state === 'error' ? (
        <Button title="Start call" onPress={() => void call.start()} />
      ) : (
        <Button title="End call" onPress={call.end} />
      )}
    </View>
  )
}

useLorikeetCall({ getSession, onError }) returns:

  • state: idle, starting, connecting, active or error, as in the web Voice Widget. starting covers asking for the microphone and fetching the session, and connecting covers joining the call.
  • error: why the call is in error. microphone_denied means the customer refused the microphone, or it is off for the app in the device's settings. not_available means getSession returned null. failed is anything else, and onError receives its cause. microphone_system_denied is the web Voice Widget's code for a browser blocked by the operating system, and a mobile device never reports it.
  • start(): start a call from idle or error. The hook asks for microphone access before it calls getSession, so a refusal starts no conversation.
  • end(): hang up, or abandon a call still starting. The call also ends, and returns to idle, when the agent leaves.
  • ended: whether the last call ended after it began connecting.
  • microphoneMuted and setMicrophoneMuted(muted): mute the customer.
  • speakerMuted and setSpeakerMuted(muted): mute the agent.

The call has no live transcript. The conversation is in Lorikeet under its conversationId.

If your app already calls LiveKit's registerGlobals(), the hook leaves your configuration alone. Otherwise the hook calls it when the first call starts.

The hook owns the native audio session for the length of a call and stops it when the call ends. An app that runs its own LiveKit call at the same time should not use the hook.

Development

This package is outside the root pnpm workspace, on its own lockfile, so run these from packages/react-native-widget after pnpm install there.

  • Build: pnpm build
  • Test: pnpm test
  • Typecheck: pnpm typecheck
  • Lint: pnpm lint. It uses the root's oxlint and oxfmt, so run pnpm install at the repository root first.

To release, bump version in package.json and add its CHANGELOG.md section in the same pull request. See docs/engineering/sdk-releases.md.

License

MIT