On-device LLMs in React Native (2026): Xybrid vs llama.rn vs React Native ExecuTorch
Compare Xybrid, llama.rn and React Native ExecuTorch for running an LLM offline in React Native or Expo: install, models, platforms, speech, tool calling.
To run an LLM on-device in React Native, use one of three libraries. Use llama.rn for direct llama.cpp control over a GGUF file. Use React Native ExecuTorch (react-native-executorch) for React hooks and a broad catalog of pre-exported .pte vision and speech models. Use Xybrid (@xybrid/react-native) for one API across LLM, speech-to-text and text-to-speech that loads models by id or from GGUF and matches Xybrid's Swift, Kotlin, Flutter and Unity SDKs. All three need the New Architecture and an Expo development build (not Expo Go).
Last verified: 2026-11-14. Versions checked that day: @xybrid/react-native 0.18.0, llama.rn 0.13.0-rc.11 (release candidate; last stable 0.12.9), react-native-executorch 0.11.0, expo-ai 0.2.0 (alpha).
Which on-device LLM library should I use in React Native?
Choose Xybrid (@xybrid/react-native) if:
- You need more than chat: the same
Model/EnvelopeAPI runs LLMs, Whisper speech-to-text (batch and live), text-to-speech and vision models. - You want to start from a registry id (
qwen3.5-0.8b) and still be free to load your own GGUF from Hugging Face or a file, with nomodel_metadata.jsonto write. - Your team also ships native iOS, Android, Flutter or Unity apps and wants one SDK design across them.
- You want an optional cloud fallback for devices that can't run the model, without changing the call site.
Choose llama.rn if:
- You want low-level llama.cpp parameters (
n_ctx,n_gpu_layers, sampling, LoRA adapters, session save/load). - You need GPU or NPU offload on Android: it offers OpenCL on Adreno 700+ GPUs and an experimental Hexagon NPU backend.
- You are fine finding, downloading and managing GGUF files yourself.
Choose React Native ExecuTorch if:
- You want ready-made React hooks (
useLLMChatSession,useSpeechToText,useTextToSpeech) with download and caching handled for you. - You need computer vision as well: it has the broadest vision catalog of the three (OCR, detection, segmentation, classification, text-to-image and more).
- You are fine with
.ptemodels from Software Mansion's Hugging Face collection or your own ExecuTorch export.
Consider expo-ai instead only if every target device has Apple Intelligence or Gemini Nano and the built-in system model is good enough. It can't load a model you choose.
Comparison table
Xybrid (@xybrid/react-native) |
llama.rn | React Native ExecuTorch | expo-ai (system model only) | |
|---|---|---|---|---|
| Latest version (date) | 0.18.0 (2026-11-13) | 0.13.0-rc.11 (RC, 2026-11-12); stable 0.12.9 | 0.11.0 (2026-10-27) | 0.2.0, alpha (2026-11-03) |
| License | Apache-2.0 | MIT | MIT (per package.json) |
MIT |
| Engine | Rust core: llama.cpp (GGUF) + ONNX Runtime (ONNX) | llama.cpp | ExecuTorch | Apple Foundation Models / Gemini Nano (ML Kit Prompt API) / browser Prompt API |
| Model formats | GGUF, ONNX, registry bundles | GGUF | .pte |
None (system model) |
| Where models come from | Registry by id, Hugging Face, local file, bundle or directory | You supply the GGUF | Software Mansion HF collection or your own export | The OS |
| Bring your own model | Yes (a GGUF needs no model_metadata.json) |
Yes | Yes (export to .pte) |
No |
| Min React Native / architecture | 0.76+, New Architecture | New Architecture (since v0.10); no minimum RN version stated | 0.83+, New Architecture | Expo modules; docs target the next Expo SDK |
| Min iOS | 16.0 | 13.0 (podspec) | 17.0 | App target 16.4+; generation needs iOS 26+ with Apple Intelligence |
| Min Android | API 29 (Android 10) | minSdkVersion 23 by default (package build files) |
minSdkVersion 26 |
minSdk 26, plus a device with Gemini Nano via AICore |
| Expo | SDK 52+ with a development build | Development build; ships a config plugin | SDK 55+ with a development build | Development build |
| Expo Go | No | No | No | No |
| GPU / NPU | iOS: Metal (physical devices). Android: CPU only (llama.cpp ARM NEON variants picked at runtime) | Metal; OpenCL (Adreno 700+); Hexagon NPU (experimental) | XNNPACK (CPU), Core ML and MLX (Apple), Vulkan (Android GPU) | OS-managed |
| Token streaming + cancel | Yes (async iterator + AbortSignal) |
Yes (callback + stopCompletion()) |
Yes (callback + stop) |
Yes |
| Tool calling | Yes | Yes (Jinja templates) | Yes (chat session tools) | Yes |
| Structured JSON output | Yes (JSON Schema to GBNF) | Yes (GBNF, json_schema) |
Not documented on the LLM page | Yes (schemas) |
| Vision input | Yes (Envelope.image) |
Yes (mmproj) | Yes (VLMs, plus vision task hooks) | Device and OS dependent |
| Speech-to-text | Yes (Whisper, batch and live) | Not in this package (whisper.rn is a separate package from the same org) |
Yes (useSpeechToText, Whisper) |
No |
| Text-to-speech | Yes (for example Kokoro) | Experimental (codec.cpp) | Yes (Kokoro, Supertonic) | No |
| Multi-model pipeline (ASR → LLM → TTS) | Yes (Pipeline, YAML) |
No | Build it in TypeScript | No |
| Embeddings | Yes: Envelope.embedding(data) in, result.embedding out |
Yes (plus rerank) | Yes (useTextEmbedder) |
No |
| Cloud fallback | Optional, needs an API key | No | No | No |
| Same API on other platforms | Swift, Kotlin, Flutter, Unity, Rust, Web | React Native only | React Native only | Expo only |
| Telemetry / network notes | Trace export is off until you configure it | Downloads prebuilt native libraries from its GitHub release at install | Pre-exported model downloads send an anonymous event (opt out with setTelemetryEnabled(false)) |
Docs: prompts, images and results are not sent to an external service |
| GitHub stars (2026-11-14) | 524 (monorepo) | 1,073 | 1,791 | Part of expo/expo |
Checked on 2026-11-14 against npm, each project's repository and its official docs. Sources: Xybrid README, src and docs; llama.rn 0.13.0-rc.11 README, podspec and android/gradle.properties; React Native ExecuTorch v0.11.0 README, compatibility page and LLM guide; expo-ai docs.
How do I run an LLM on-device in React Native?
Each library needs a native install and a development build. Here is the install and first call for each.
Xybrid
Install the package, then the iOS pods. pod install downloads the Rust core (XybridFFI.xcframework) from the matching GitHub release and checks it against a pinned SHA-256.
npm install @xybrid/react-native
cd ios && pod install
In Expo, run npx expo install @xybrid/react-native, then npx expo prebuild. The package needs no config plugin. On Android, the app's minSdkVersion must be 29 or higher, and the React Native and Expo templates default to 24. In a bare app, set minSdkVersion = 29 in the ext block of android/build.gradle. In Expo, install expo-build-properties (npx expo install expo-build-properties), add this to app.json, and run npx expo prebuild again (React Native SDK docs):
{
"expo": {
"plugins": [
["expo-build-properties", { "android": { "minSdkVersion": 29 } }]
]
}
}
The shortest path, from the header of the package's src/index.ts:
// @xybrid/react-native 0.18.0 (src/index.ts)
const model = await ModelLoader.fromRegistry('qwen3.5-0.8b').load();
const result = await model.run(Envelope.text('Hello'));
await model.release();
load() resolves the id, downloads and verifies the model once, caches it, and loads it. Local inference needs no account or API key. Call release() when you are done: the weights live in the native heap.
The example app runs the full flow: load, read model info, warm up, then run with a generation preset. Trimmed from example/App.tsx:
// @xybrid/react-native 0.18.0 (example/App.tsx, smoke-test wrappers removed)
import { Envelope, GenerationConfigs, ModelLoader } from '@xybrid/react-native';
const model = await loaderFor(modelId).load();
try {
const info = await model.info();
if (!info.isLlm) return;
await model.warmup();
const result = await model.run(Envelope.text('Name one colour of the sea.'), {
generationConfig: GenerationConfigs.greedy({ maxTokens: 24 }),
});
// result.text holds the answer
} finally {
await model.release();
}
Streaming returns an async iterator, and an AbortController stops it. This is the example app's "stop button" step, which aborts after five tokens:
// @xybrid/react-native 0.18.0 (example/App.tsx)
const controller = new AbortController();
let streamed = '';
let tokens = 0;
try {
for await (const token of model.runStreaming(Envelope.text('Count from one to fifty.'), {
generationConfig: { maxTokens: 128 },
signal: controller.signal,
})) {
streamed += token.token;
tokens += 1;
if (tokens === 5) controller.abort();
}
} catch (error) {
// Cancelling mid-stream may surface as `xybrid_cancelled`.
if (!(isXybridError(error) && error.code === 'xybrid_cancelled')) throw error;
}
For multi-turn chat, pass a ConversationContext and push both the user turn and the model's reply before the next turn:
// @xybrid/react-native 0.18.0 (example/App.tsx, smoke-test wrappers removed)
const chat = await ConversationContext.create();
try {
const question = Envelope.user('My name is Ada. Reply with one word: ok.');
const first = await model.run(question, { context: chat, generationConfig: { maxTokens: 16 } });
await chat.push(question);
await chat.push(first.envelope);
const second = await model.run(Envelope.user('What is my name?'), {
context: chat,
generationConfig: { maxTokens: 16 },
});
} finally {
await chat.release();
}
The example is an Expo app (Expo ~56, React Native 0.85.3) that links the SDK from repo source and builds the native core with Bazel. Read it as a reference, not a template: a normal app uses npm install @xybrid/react-native.
llama.rn
npm install llama.rn
On iOS, re-run npx pod-install. The package downloads prebuilt native libraries from its GitHub release during postinstall and verifies each archive with SHA-256. If ProGuard is on, the README asks you to add a keep rule for com.rnllama.**.
You create a context from a GGUF path with initLlama, then call context.completion with a callback that receives each partial token. Trimmed from the llama.rn 0.13.0-rc.11 README, "Usage":
import { initLlama } from 'llama.rn'
// Initial a Llama context with the model (may take a while)
const context = await initLlama({
model: modelPath,
use_mlock: true,
n_ctx: 2048,
n_gpu_layers: 99, // number of layers to store in GPU memory (Metal/OpenCL)
})
// Do chat completion
const msgResult = await context.completion(
{
messages: [
{
role: 'user',
content: 'Hello!',
},
],
n_predict: 100,
stop: stopWords,
},
(data) => {
// This is a partial completion callback
const { token } = data
},
)
console.log('Result:', msgResult.text)
In the README, modelPath is a file:// path to a GGUF on the device and stopWords is a list of end-of-turn strings. To stop a running completion, call context.stopCompletion(). For Expo, the README uses expo-build-properties to turn on the iOS and OpenCL features with a development build.
Ecosystem note: @react-native-ai/llama (0.13.0) is a Vercel AI SDK provider built on llama.rn.
React Native ExecuTorch
npm install react-native-executorch react-native-worklets react-native-blob-util
react-native-worklets/plugin must be the last entry in your Babel plugins. The 0.11.0 package also lists @kesha-antonov/react-native-background-downloader as a peer dependency. On Expo SDK 55 and 56, the compatibility page says to request react-native-worklets@^0.10.0 (and the matching Reanimated) explicitly, because the SDK bundles an older version.
The quickstart uses a hook: useLLMChatSession downloads and loads a pre-exported model, and session.sendMessage streams tokens to a callback. Trimmed from the v0.11.0 README Quickstart (the button JSX is omitted):
import { models, useLLMChatSession } from 'react-native-executorch';
export function App() {
const session = useLLMChatSession(models.llm.LFM2_5_1_2B.DEFAULT);
const handleGenerate = async () => {
if (!session.isReady || !session.sendMessage) return;
const turn = await session.sendMessage(
'Explain on-device AI in one sentence.',
(token) => console.log(token)
);
console.log('Result messages:', turn.messages);
};
return null;
}
The chat session also exposes stop to end a generation (LLM guide).
Models: GGUF vs .pte vs a registry
Can I run a GGUF model in React Native? Yes, with llama.rn or Xybrid. React Native ExecuTorch runs .pte files (ExecuTorch exports), not GGUF. expo-ai runs only the model the OS provides.
With llama.rn you find the GGUF yourself, usually by searching Hugging Face for GGUF, download it, and pass its path to initLlama. There is no registry.
With React Native ExecuTorch you pick a model from the models registry (backed by Software Mansion's Hugging Face collection) or export your own PyTorch model to .pte with their export recipes.
With Xybrid you have several loaders on ModelLoader:
ModelLoader.fromRegistry(id): a model from the Xybrid registry, downloaded once, verified and cached. Example LLM ids includeqwen3.5-0.8b,lfm2.5-230mandlfm2.5-350m.ModelLoader.fromHuggingFace(repo, { revision }): a Hugging Face repository (org/repoororg/repo:variant), optionally pinned.ModelLoader.fromModelFile(path): a raw GGUF file on the device.ModelLoader.fromBundle(path): a local.xybbundle.ModelLoader.fromDirectory(path): a prepared local directory.
The registry is a starting point, not an allowlist. A GGUF loaded through fromHuggingFace or fromModelFile does not need a model_metadata.json from you. Only fromDirectory expects one, because it loads a prepared directory rather than a raw GGUF.
The example app picks the loader from the string it is given: a registry id, a .gguf file, or a directory.
// @xybrid/react-native 0.18.0 (example/App.tsx)
function loaderFor(model: string): ModelLoader {
if (!model.startsWith('/') && !model.startsWith('file://')) return ModelLoader.fromRegistry(model);
return model.endsWith('.gguf') ? ModelLoader.fromModelFile(model) : ModelLoader.fromDirectory(model);
}
Beyond chat: speech, vision, tool calling and JSON output
Can I do speech-to-text and text-to-speech on-device in React Native?
Yes. Xybrid loads speech models through the same ModelLoader and runs them with Envelope.text (TTS) and Envelope.audio (ASR). Trimmed from the example app's speech round trip:
// @xybrid/react-native 0.18.0 (example/App.tsx, smoke-test wrappers removed)
const tts = await loaderFor(ttsSource).load();
const voice = await tts.defaultVoice();
const speech = await tts.run(Envelope.text('Hello from React Native.', { voiceId: voice?.id }));
const asr = await loaderFor(asrSource).load();
const batch = await asr.run(Envelope.audio(wavBase64));
In the example, wavBase64 is the TTS output wrapped as a WAV (toWavBase64 in example/speech.ts), because batch ASR accepts WAV input.
For live dictation, model.stream() opens a session: feed 16 kHz mono Float32 audio in small chunks, read partial transcripts, then flush. From example/speech.ts:
// @xybrid/react-native 0.18.0 (example/speech.ts, trimmed)
const session = await asr.stream();
try {
const chunk = 1600;
for (let offset = 0; offset < samples.length; offset += chunk) {
await session.feed(samples.subarray(offset, offset + chunk));
}
const { text: transcript } = await session.flush();
} finally {
await session.release();
}
React Native ExecuTorch has separate hooks for each task (useSpeechToText with Whisper, useTextToSpeech with Kokoro or Supertonic), and you connect them in your own code. llama.rn offers experimental TTS through codec.cpp; speech-to-text lives in the separate whisper.rn package from the same maintainers.
If you want ASR, LLM and TTS chained in one call, Xybrid also has multi-stage pipelines (Pipeline, defined in YAML). The pipelines docs cover them, and Building a voice agent on-device walks through one.
Can a local model in React Native do tool calling or JSON output?
Yes, in all three libraries, with some differences.
Xybrid takes tools in generationConfig.tools and returns result.toolCalls. One run is one model turn, so the tool loop lives in your code: execute each call, then send the results back with Envelope.toolResults. From the package README, "Tool calling" (runTool is your own function):
const tools = [{ name: 'weather', description: 'Current weather', parameters: { type: 'object', properties: { city: { type: 'string' } } } }];
const prompt = 'Weather in Paris?';
const first = await model.run(Envelope.text(prompt), { generationConfig: { tools } });
if (first.toolCalls.length > 0) {
const results = await Promise.all(first.toolCalls.map(async (call) => ({
callId: call.id,
name: call.name,
content: await runTool(call.name, JSON.parse(call.argumentsJson)),
})));
const next = await Envelope.toolResults(prompt, first.text ?? '', results);
const answer = await model.run(next, { generationConfig: { tools } });
}
When streaming, the terminal token carries toolCalls and rawText; pass rawText as the prior assistant text. The tool calling guide has more detail.
For JSON output, jsonSchemaToGbnf converts a JSON Schema into a GBNF grammar that constrains the local model:
// @xybrid/react-native 0.18.0 (example/App.tsx, smoke-test wrappers removed)
const grammar = await jsonSchemaToGbnf({
type: 'object',
properties: { colour: { type: 'string' } },
required: ['colour'],
});
const structured = await model.run(Envelope.text('Give a colour as JSON.'), {
generationConfig: { grammar, maxTokens: 32 },
});
llama.rn supports tool calling through Jinja chat templates (tools and tool_choice on completion) and constrained output through GBNF or response_format with a json_schema. React Native ExecuTorch's chat session runs tools you declare with an execute handler and loops until the model gives a final answer; its LLM guide does not document a grammar or JSON-schema output option. expo-ai supports tool calls and schema-constrained values on the system model.
Vision: Xybrid accepts images through Envelope.image and Envelope.userMessage(text, images) for vision-language models. llama.rn uses an mmproj projector file. React Native ExecuTorch supports image input in its chat session and has dedicated vision hooks. Embeddings: Xybrid's Model.run accepts Envelope.embedding(data) and returns result.embedding; llama.rn has context.embedding() and rerank(); React Native ExecuTorch has useTextEmbedder.
What are the minimum iOS and Android versions for on-device LLMs in React Native?
- Xybrid: React Native 0.76+ with the New Architecture, iOS 16.0+, Android API 29 (Android 10), Expo SDK 52+ with a development build. Simulator builds need an Apple Silicon Mac.
- llama.rn: New Architecture since v0.10. The package build files set iOS 13.0 and a default Android
minSdkVersionof 23; the README does not state minimums. - React Native ExecuTorch: React Native 0.83+ or Expo SDK 55+ with a development build, iOS 17.0+, Android
minSdkVersion26. - expo-ai: Android minSdk 26 and Kotlin 2.2.21; Xcode 26.4+ to build. Generation needs iOS 26+ with Apple Intelligence, or an Android device with Gemini Nano ready through AICore.
Does on-device LLM work in Expo? Does it work in Expo Go?
It works in Expo with a development build. It does not work in Expo Go for any of these libraries, because each one ships native code that Expo Go does not include.
Should I use expo-ai?
expo-ai gives you the OS model: Apple Foundation Models on Apple Intelligence devices, Gemini Nano on supported Android devices, and the Prompt API in desktop browsers. Its docs say downloadable third-party model backends are not included, so you can't choose or bundle a model, and Android inference stops if the app moves to the background. If every target device has a ready system model and its quality is enough, it is the lightest option. If you need a specific open model, older or cheaper devices, or the same behavior on every phone, bundle a model with one of the three libraries above.
Performance and model size on phones
This page publishes no speed figures. Throughput depends on the chip, the model's quantization and the context length, and we know of no published benchmark that runs the same model on the same phones across these libraries. So this section compares backends, not numbers.
What differs is where each library can run the model:
- Xybrid: on Android, it uses llama.cpp's ARM CPU backends and picks the fastest NEON variant (dotprod / i8mm) the phone supports at runtime. On iOS it uses Metal (the simulator runs on the CPU). There is no Android GPU or NPU offload.
- llama.rn: Metal on iOS; optional OpenCL on Adreno 700+ GPUs and an experimental Hexagon NPU backend on Android.
- React Native ExecuTorch: XNNPACK on the CPU, Core ML and MLX on Apple devices, Vulkan on Android GPUs.
- expo-ai: the OS manages execution.
How big a model can I run on a phone? Small quantized models, roughly 0.2B to 2B parameters, suit most current phones. Larger models need more RAM and a bigger download, so test on the oldest device you support.
What happens on devices that can't run the model?
With Xybrid, an API key enables two optional features on top of the local runtime: cloud fallback, and speculative cloud serving (ModelLoader.fromRegistrySpeculative), which answers from the cloud while the registry weights download and then switches to on-device. result.executionTarget reports whether an answer came from 'local' or 'cloud'. You set the key once:
// @xybrid/react-native 0.18.0 (src/index.ts)
await Xybrid.initialize({ apiKey }); // optional
llama.rn and React Native ExecuTorch have no built-in fallback; you detect the device and call a server yourself. expo-ai has availability checks you run on the device before generating.
Other options
cactus-react-native (1.13.1, last published 2026-04-19) is another on-device option, not compared here.
FAQ
Can I run an LLM in Expo Go?
No. Xybrid, llama.rn and React Native ExecuTorch all bundle native code, so you need an Expo development build. The same applies to expo-ai.
Which React Native library runs GGUF models?
llama.rn and Xybrid. React Native ExecuTorch uses .pte files. A GGUF loaded with Xybrid's fromHuggingFace or fromModelFile does not need a model_metadata.json.
Do I need an account or API key for Xybrid?
No, not for local inference. An API key only enables cloud fallback, speculative cloud serving and trace export to Xybrid.
Can I do voice (speech-to-text, LLM, text-to-speech) fully on-device in React Native?
Yes. Xybrid runs Whisper ASR, LLMs and TTS through one API and can chain them in a pipeline. React Native ExecuTorch has separate hooks for each step that you connect yourself. llama.rn covers the LLM and experimental TTS; speech-to-text needs the separate whisper.rn package.
What's the minimum Android and iOS version?
Xybrid: iOS 16.0 and Android API 29. llama.rn: iOS 13.0 and a default minSdkVersion of 23, per its build files. React Native ExecuTorch: iOS 17.0 and minSdkVersion 26. expo-ai needs iOS 26 with Apple Intelligence, or an Android device with Gemini Nano.
How big a model can a phone run?
Small quantized models, roughly 0.2B to 2B parameters, suit most phones. RAM is the main limit, so test on the oldest device you support.
llama.rn vs react-native-executorch: what's the difference?
llama.rn binds llama.cpp, runs GGUF files and exposes low-level parameters. React Native ExecuTorch runs .pte exports on Meta's ExecuTorch and wraps tasks in React hooks. ExecuTorch covers far more vision tasks; llama.rn offers Android GPU (OpenCL) and experimental NPU offload.
Should I use expo-ai instead?
Only if a system model on supported devices is enough. expo-ai uses Apple Foundation Models or Gemini Nano and can't load a model you choose. It is also in alpha.
Does it work offline after the first download?
Yes for Xybrid, llama.rn and React Native ExecuTorch once the model is on the device. expo-ai depends on the OS model being present and ready.
Get started with Xybrid in React Native
- React Native SDK docs: install, loading models, streaming and speech.
- Example app: the full working flow used in this article.
- GitHub repository
- Agent setup prompt: paste it into your coding agent to add Xybrid to your app.
- On-device AI on iOS and Android: the broader mobile picture.
Originally published on the Xybrid blog. Install and API details are in the React Native SDK docs.
Comments
Join the discussionNo comments yet. Be the first to comment.

