New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cohere-react-native

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cohere-react-native

test

  • 0.1.12
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Cohere React Native

cohere-react-native is a React Native library that allows you to easily integrate the Cohere voice chat widget into your React Native applications. The library provides the CohereProvider, useCohere, and CohereWidget components to help you manage user identification, context, and the rendering of the chat widget.

Installation

To install the cohere-react-native library, use the following command:

npm install cohere-react-native react-native-webview
npx pod-install

Usage

Here's how you can use the CohereProvider, useCohere, and CohereWidget components in your React Native application:

import { CohereProvider, useCohere, CohereWidget } from 'cohere-react-native';

export default function App() {
  return (
    <CohereProvider apiKey="[EXAMPLE]">
      <Cohere />
    </CohereProvider>
  );
}

const Cohere = () => {
  const { identify } = useCohere();
  const [open, setOpen] = useState(false);

  useEffect(() => {
    identify('123', { displayName: 'John Doe' });
  }, [identify]);

  return open ? (
    <CohereWidget
      onClose={() => {
        setOpen(false);
      }}
    />
  ) : (
    <SafeAreaView>
      <Button title="Open support" onPress={() => setOpen(true)} />
    </SafeAreaView>
  );
};

Components

CohereProvider

The CohereProvider component provides the context for the Cohere integration. It requires the apiKey prop for authorization and takes in children to render its child components.

Props:

  • apiKey: string: The API key used to authorize the Cohere voice chat widget.
  • children: React.ReactNode: The child components to render within the provider.

useCohere

The useCohere hook provides access to the Cohere context and functions. It must be used within a CohereProvider. This hook allows you to access the identify function to provide user identification information.

identify

The identify function is used to provide user identification information to the Cohere voice chat widget. It takes two arguments:

  • userId: string: The unique identifier for the user.
  • options?: UserAttrs: An optional object containing additional user attributes such as displayName, email, and any other custom attributes.

CohereWidget

The CohereWidget component renders the Cohere voice chat widget. It requires the onClose prop which is a callback function that gets called when the chat widget is closed by the user.

Props:

  • onClose: () => void: The callback function to be called when the chat widget is closed.

License

cohere-react-native is licensed under the MIT License. See the LICENSE file for more information.

Keywords

FAQs

Package last updated on 17 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc