React Native Nitro module for Apple's Foundation Models (Apple Intelligence). Enables AI capabilities in React Native applications using Apple's on-device model, with tool calling support and streaming responses on iOS 26.0+.
- iOS 26.0 or later
- Apple Intelligence enabled in Settings > Apple Intelligence & Siri
- Compatible Apple devices (Apple Silicon Macs, recent iPhones/iPads)
- React Native with Nitro modules support
npm install react-native-apple-ai react-native-nitro-modules
yarn add react-native-apple-ai react-native-nitro-modules
bun add react-native-apple-ai react-native-nitro-modulesimport { LanguageModelSession } from 'react-native-apple-ai';
const session = new LanguageModelSession({
instructions: 'You are a helpful assistant'
});
// Stream responses
await session.streamResponse('Hello, how are you?', (response) => {
console.log('Streaming response:', response);
});import { useLanguageModel } from 'react-native-apple-ai';
function ChatComponent() {
const { send, response, loading, error, isSessionReady } = useLanguageModel({
instructions: 'You are a helpful coding assistant',
onResponse: (response) => console.log('Got response:', response),
onError: (error) => console.error('Error:', error)
});
const handleSendMessage = async () => {
if (isSessionReady) {
await send('Explain React hooks');
}
};
return (
<View>
<Text>{response}</Text>
<Button onPress={handleSendMessage} disabled={loading} title="Send" />
</View>
);
}import { createTool, LanguageModelSession } from 'react-native-apple-ai';
import { z } from 'zod';
const weatherTool = createTool({
name: 'weather_tool',
description: 'Get current weather for a city',
arguments: z.object({
city: z.string(),
}),
handler: async (args) => {
const response = await fetch(`/weather?city=${args.city}`);
const res = await response.json();
return res.data
},
});
const session = new LanguageModelSession({
instructions: 'You are a weather assistant',
tools: [weatherTool]
});Core class for managing AI conversations.
constructor(config?: {
instructions?: string;
tools?: Tool[];
})React hook for session management with automatic lifecycle handling.
Returns:
session- The current session instanceresponse- Latest AI responseloading- Whether a request is in progresserror- Any error that occurredsend(prompt)- Send a message to the AIreset()- Reset the conversation stateisSessionReady- Whether the session is ready to use
Lower-level hook for streaming responses.
Check if Apple Intelligence is available on the device.
This project uses a workspace structure with:
package/- The nitro module source codeexample/- Example app demonstrating usage
bun install
bun run buildcd example
bun start # Start Expo dev server
bun ios # Run on iOSNote: Android is not supported as this module requires Apple's Foundation Models framework.