React Native package for Vercel AI integration in universal apps
Top 94.3% on sourcepulse
This package enables the use of Vercel AI's useChat
and useCompletion
hooks within React Native and Expo universal applications. It addresses the limitation of React Native's fetch API not supporting streaming, providing a workaround for mobile clients while maintaining full streaming functionality on the web.
How It Works
The library bridges Vercel AI's functionality to React Native by abstracting the streaming behavior. For web environments, it seamlessly integrates with the existing ai/react
package. On React Native mobile platforms, it bypasses the streaming aspect of the API calls, returning the complete response directly. This is achieved by conditionally disabling streaming in the backend API based on the user agent.
Quick Start & Requirements
npm install react-native-vercel-ai
unstable_enablePackageExports = true
to metro.config.js
.Highlighted Details
useChat
, useCompletion
) in React Native.ai/react
behavior on the web.Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The primary limitation is the lack of streaming support on React Native mobile, which is a core feature of the Vercel AI package. The solution relies on a backend API to detect and serve non-streamed responses to mobile clients.
1 year ago
1 week