@agentskit/react-native — for agents
React Native / Expo binding — same `useChat` contract as `@agentskit/react`, Metro + Hermes safe with streaming polyfill guidance.
#Purpose
React Native binding for the ChatReturn contract from @agentskit/core. Shares the same hook API as @agentskit/react but ships without any DOM dependency, making it safe for Metro bundler and the Hermes JS engine used in React Native and Expo.
#Install
npm install @agentskit/react-native
# peers:
npm install react react-native#Primary exports
useChat(config): ChatReturn— identical contract to@agentskit/react, imported from pure React (no DOM).
#Minimal example
import { useChat } from '@agentskit/react-native'
import { anthropic } from '@agentskit/adapters'
import { View, TextInput, FlatList, Pressable, Text } from 'react-native'
const adapter = anthropic({ apiKey: process.env.ANTHROPIC_KEY, model: 'claude-sonnet-4-6' })
export function Chat() {
const chat = useChat({ adapter })
return (
<View style={{ flex: 1 }}>
<FlatList
data={chat.messages}
keyExtractor={m => m.id}
renderItem={({ item }) => <Text>{item.role}: {item.content}</Text>}
/>
<TextInput value={chat.input} onChangeText={chat.setInput} />
<Pressable onPress={() => chat.send(chat.input)}><Text>Send</Text></Pressable>
</View>
)
}#Common patterns
- Streaming polyfills required: Hermes does not ship
TextDecoderor the Web Streams API. Installreact-native-polyfill-globalsand callpolyfillGlobal('TextDecoder', ...)at the top of your entry file before any AgentsKit import — otherwise streamed responses will silently fail. - No Node built-ins: Metro does not polyfill Node modules (
Buffer,stream,crypto). If an adapter dependency pulls them in, add thereact-nativefield in the adapter'spackage.jsonor use a Metro resolver alias. - Expo managed workflow: add the polyfill in
app/_layout.tsx(orApp.tsx) as the very first import; do not rely on Babel plugins to hoist polyfills after module initialisation. - Keyboard avoiding: wrap the input in
<KeyboardAvoidingView>and useFlatList'sinvertedprop +onContentSizeChangescroll-to-end for a chat-like feel.
#Related
- @agentskit/core —
ChatReturncontract. - @agentskit/adapters — provider adapters.
- @agentskit/react, @agentskit/ink, @agentskit/vue, @agentskit/svelte, @agentskit/solid, @agentskit/angular — sibling bindings.
#Source
- npm: https://www.npmjs.com/package/@agentskit/react-native
- repo: https://github.com/AgentsKit-io/agentskit/tree/main/packages/react-native
Explore nearby
- PeerFor agents — overview
Dense, LLM-friendly reference for every AgentsKit package. Designed to paste into an agent's context window.
- Peer@agentskit/core — for agents
Zero-dependency foundation. Contracts, chat controller, primitives, and a dozen feature subpaths.
- Peer@agentskit/adapters — for agents
Provider adapters (OpenAI-compatible + native) + router + ensemble + fallback + generic factory.