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

react-native-ai-chat

v0.1.5

Published

An unopinionated, highly customizeable AI Chat component for React Native.

Downloads

9

Readme

react-native-ai-chat

An unopinionated, highly customizeable AI Chat component for React Native.

Easily add an AI chat experience to your app in 1 line of code.

* Backend is required. Examples available in the examples directory

Installation

$ npm install react-native-ai-chat --save

or

$ yarn add react-native-ai-chat

Usage

Basic

import { AiChat } from "react-native-ai-chat";

function App() {
  <>
    <AiChat apiUrl="http://192.168.1.120:5000/chat" />
  </>;
}

UI Components

You can use components from

import { AiChat } from "react-native-ai-chat";
import { Avatar, Button, TextInput, Message } from "ui-component-library";

function App() {
  <>
    <AiChat
      apiUrl="http://192.168.1.120:5000/chat"
      AvatarComponent={Avatar}
      ButtonComponent={Button}
      MessageComponent={Message}
      TextInputComponent={(props) => <TextInput extraProp={false} {...props} />}
    />
  </>;
}

Component Props

interface AiChatProps {
  // URL of the server endpoint to call
  apiUrl: string;

  // Id of the current chat (can be used to sync data with the backend)
  chatId?: string;

  // Send chatId with API Call
  sendChatId?: boolean;
  // Send message string with API Call
  sendMessage?: boolean;
  // Send messages array with API Call
  sendMessages?: boolean;

  // React-Native style object to style the avatar
  avatarStyle?: ViewStyle;
  // Size of the avatar component
  avatarSize?: number;
  // Text initials to use in the avatar of the AI
  avatarAiInitials?: string;
  // Text initials to use in the avatar of the user
  avatarUserInitials?: string;

  /* Overwrite background color of the component */
  backgroundColor?: string;

  // React-Native style object to style the send button
  buttonStyle?: ViewStyle;
  // React-Native style object to style the send button text
  buttonTextStyle?: TextStyle;
  // Text color of the send button
  buttonTextColor?: string;
  // Height of the send button
  buttonHeight?: number;
  // Width of the send button
  buttonWidth?: number;

  // React-Native style object to style the outer container
  containerStyle?: ViewStyle;
  // React-Native style object to style the chat container
  chatContainerStyle?: ViewStyle;
  // React-Native style object to style the form container
  formContainerStyle?: ViewStyle;

  // Component to use when the chat is empty
  emptyState?: React.ReactNode;

  // Default border radius TextInput and send Button
  radius?: number;
  // Default padding around the AiChat component
  padding?: number;
  // Default spacing between components in the chat
  spacing?: number;

  // External control to set the API sending state
  sending?: boolean;

  // Text to concatinate before the typed message
  preMessageText?: string;
  // Text to concatinate after the typed message
  postMessageText?: string;

  // Component to use replace the Avatar component
  AvatarComponent?: React.ComponentType<AvatarComponentProps>;
  // Component to use replace the Send Button component
  ButtonComponent?: React.ComponentType<TouchableOpacityProps>;
  // Component to use replace the TextInput component
  TextInputComponent?: React.ComponentType<TextInputProps>;
  // Component to use replace the Message bubble component
  MessageComponent?: React.ComponentType<ViewProps>;

  // React-Native style object to style the text input container
  textInputContainerStyle?: ViewStyle;
  // Height of the text input
  textInputHeight?: number;
  // React-Native style object to style the text input
  textInputStyle?: TextStyle;
  // Text to use as the text input placeholder
  textInputPlaceholder?: string;
  // React-Native props to pass to the TextInput component
  textInputProps?: React.ComponentProps<typeof TextInput>;
}

Backend

A backend is required to use this component.

The backend can make a call to any AI service and return the response to the component.

Request

The backend is called via XMLHttpRequest with a POST method matching the following interface for the post body:

interface ApiRequestBody {
  // Id of the current chat (can be used to sync data with the backend)
  chatId?: string;
  // Message string of the last message typed
  message?: string;
  // Messages array of all messages between user an AI from oldest to newest
  messages?: ChatMessage[];
}

interface ChatMessage {
  content: string;
  sender: Sender;
}

export type Sender = "user" | "ai";

Each of chatId, message or messages can be disabled from sending via the component props.

Response

The response expected is simply the last message from the AI as a string.

Examples

Current backend examples available:

  • OpenAI + Express

Testing

Coming Soon™