Add an AI chat assistant to your React Native app

Almost every platform is trying to add a ChatGPT-like assistant. To do it, developers have to work through the OpenAI documentation, which takes time. So I packaged the work into my first npm package: a React Native library that brings an AI assistant to your app.
Install
sh
npm i react-native-sparkle-ai-chat @react-native-async-storage/async-storageUse it
Give it a platform, an API key and instructions for the assistant, and brand it with your own name, logo and colours.
AIChatScreen.tsx
import SparkleChat from 'react-native-sparkle-ai-chat';
<SparkleChat
platform="openai"
apiKey={OPENAI_API_KEY}
instruction="You help customers choose from the coffees on our menu."
brand={{ name: 'Coffee Assistant', primaryColor: '#FF5C5C' }}
/>What’s inside
The library is the chat screen from my Sparkle AI app, extracted into a package built with react-native-builder-bob, so it ships CommonJS, ES modules and TypeScript types.
- Streaming over server-sent events with
react-native-sse, so answers appear as they’re written. - History kept in Redux Toolkit and persisted to AsyncStorage, which is why AsyncStorage is a peer dependency.
- Token budget. Older messages are trimmed so the conversation fits the model’s context window.
- Your own backend.
apiBaseUrlandorganizationlet you point it at a proxy or any OpenAI-compatible endpoint instead of shipping a key in the app, andcompletionParamspasses model, temperature and other options straight through.
It is open source, and contributions are welcome on GitHub.