react-native-gemini-nano
v0.1.10
Published
React Native Turbo Module for Gemini Nano on-device AI (Android & iOS)
Maintainers
Readme
react-native-gemini-nano
On-device AI for React Native — powered by Gemini Nano (Android) and Apple Foundation Models (iOS 26+)
What is this?
react-native-gemini-nano is a Turbo Module (New Architecture) that brings fully on-device generative AI to your React Native app — no API key, no internet connection, no cloud costs.
| Platform | Engine | Minimum | |----------|--------|---------| | Android | Google AI Edge — Gemini Nano (AICore) | Pixel 8 / 8a / 8 Pro or newer only | | iOS | Apple Foundation Models | iOS 26.0+ |
⚠️ Android device requirement: Gemini Nano runs via Google's AICore, which is only available on Pixel 8 series and above. Samsung Galaxy, OnePlus, Xiaomi, and other Android devices are not supported — Samsung uses its own proprietary Galaxy AI (Samsung Gauss) which does not expose a public SDK.
All inference runs locally on the device. Your users' prompts never leave their phone.
Installation
npm install react-native-gemini-nano
# or
yarn add react-native-gemini-nanoExpo
Add the config plugin to your app.json:
{
"expo": {
"plugins": ["react-native-gemini-nano"]
}
}Then rebuild your dev client:
npx expo prebuild
npx expo run:android
npx expo run:iosNote: This library requires the New Architecture. It does not work with Expo Go — use a development build.
Bare React Native
iOS
cd ios && pod installAndroid
No extra steps. The Google AI Edge SDK is bundled automatically.
Enable New Architecture
// android/gradle.properties
newArchEnabled=true# ios/Podfile
:new_arch_enabled => trueUsage
Check availability
Always check whether the on-device model is available before generating text.
import { isAvailable, generateText } from 'react-native-gemini-nano';
const supported = await isAvailable();
if (!supported) {
console.log('Gemini Nano is not available on this device.');
}Generate text
const response = await generateText('Explain black holes in one sentence.', {
temperature: 0.7, // 0.0 = deterministic, 1.0 = creative (default: 0.7)
maxTokens: 256, // max output tokens (default: 256)
});
console.log(response);Full example
import { useState } from 'react';
import { Button, Text, TextInput, View } from 'react-native';
import { isAvailable, generateText } from 'react-native-gemini-nano';
export default function App() {
const [prompt, setPrompt] = useState('');
const [result, setResult] = useState('');
async function run() {
const ok = await isAvailable();
if (!ok) return setResult('Not available on this device.');
const text = await generateText(prompt, { temperature: 0.8 });
setResult(text);
}
return (
<View>
<TextInput value={prompt} onChangeText={setPrompt} placeholder="Ask anything..." />
<Button title="Generate" onPress={run} />
<Text>{result}</Text>
</View>
);
}API
isAvailable(): Promise<boolean>
Returns true if the on-device model is ready to use on the current device.
| Return | Description |
|--------|-------------|
| true | Model is available — safe to call generateText |
| false | Device not supported or model not downloaded |
generateText(prompt, options?): Promise<string>
Runs inference on-device and returns the generated text.
Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| prompt | string | The input text / instruction |
| options | GeminiNanoOptions | Optional generation settings |
GeminiNanoOptions
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| temperature | number | 0.7 | Controls randomness. 0 = focused, 1 = creative |
| maxTokens | number | 256 | Maximum number of output tokens |
Platform Notes
Android
- Requires Google Pixel 8 / 8a / 8 Pro or newer — AICore is a Google-exclusive feature
- Samsung Galaxy, OnePlus, Xiaomi, and other Android OEMs are not supported
- Samsung devices use Galaxy AI (Samsung Gauss), which is proprietary and has no public developer SDK
- Uses
com.google.ai.edge.aicoreSDK - Model is pre-installed by Google Play Services — no download required
isAvailable()returnsfalsegracefully on unsupported devices
iOS
- Requires iOS 26.0 or later
- Uses Apple's FoundationModels framework (
LanguageModelSession) - On older iOS,
isAvailable()returnsfalsegracefully
New Architecture
This library requires the React Native New Architecture (Turbo Modules + JSI). The legacy bridge is not supported.
Contributing
Contributions are welcome! Please read the development workflow before submitting a PR.
License
MIT © jonadan
