Meet react-native-ai: LLMs Running on Mobile, for Real

Authors
Szymon Rybczak
Software Developer
@
Callstack
Kewin Wereszczyński
Software Engineer
@
Callstack

At the end of April, we announced the release of react-native-ai—a new React Native library that enables LLM execution on-device with React Native apps, powered by MLC LLM Engine. In this blog post, we'll explain our motivation behind this module, our plans, and the challenges we faced during development.

Introducing react-native-ai 🔥

Run LLMs on-device with React Native and Vercel @aisdk 😍

$ 𝚗𝚙𝚖 𝚒𝚗𝚜𝚝𝚊𝚕𝚕 𝚛𝚎𝚊𝚌𝚝-𝚗𝚊𝚝𝚒𝚟𝚎-𝚊𝚒 pic.twitter.com/MUGHjXx5vf

— Szymon Rybczak (@SzymonRybczak) April 30, 2025

From window.ai demo to Callstack Incubator: How react-native-ai was born

During last summer, I saw a demo of window.ai running inside the latest Canary builds of Google Chrome, and I thought “Is it possible to run AI on-device?”, and the most important question “How hard is it?”.

After some research, I found out there’s a universal engine to run models everywhere. This is somewhat similar to the React mental model, where we also have the possibility of running code everywhere.

I spent a few long evenings creating the first PoC of running AI on-device with React Native, which I presented at the first edition of thegeekconf in Berlin. The demo on stage went great. I also wanted to hack streaming support, but unfortunately, the time between the speaker’s dinner and the next breakfast wasn’t enough 😅

I open-sourced the repo and posted a demo on X, which went pretty well. Then, this topic stayed in the drawer for a few months until I spoke with Mike Grabowski, who wanted to give this project a proper API and a proper release.

So we moved the project under Callstack Incubator, a place for new, exciting (not always fully stable!) stuff.

The API: Plugging into Vercel AI SDK with just a few lines

We decided to expose API from the native side that is compatible with Vercel AI SDK, which Web-based developers might know well because of its flexibility and simplicity. With literally one-line changes, you can switch between models.

import { generateText } from 'ai';

const { text } = await generateText({
    model: openai('gpt-4o-mini'),
    prompt: "why React Native is good choice?"
});

And when I learned that AI SDK has a public API for third-party providers, which can plug into generateText(), streamText, etc. I thought of this kind of API:

import { prepareModel, getModel } from 'react-native-ai';
import { streamText } from 'ai';

const modelId = '';

prepareModel(modelId);

const { textStream } = streamText({
	model: getModel(modelId), // Passes reference into AI SDK
	prompt: "why React Native is a good choice?"
});

After a few weeks, together with Kewin, who wrote the whole implementation on Android and helped with API design a lot, we turned this API into reality.

Under the hood: MLC LLM powering react-native-ai package

Under the hood module is leveraging MLC LLM universal LLM Deployment Engine with ML Compilation that after some research was the best fit for us!

We’ll have a dedicated blog post coming soon regarding how MLC LLM engine works under the hood!

Getting Started: Installing and running models on-device

To start using react-native-ai in your projects, you'll need to set up the environment and understand which models to use. Here's what you need to know:

Installation Process

Setting up react-native-ai requires several steps to ensure the native modules are properly linked:

  1. Install the package via npm: npm install react-native-ai
  2. Clone the MLC LLM Engine repository and set the MLC_LLM_SOURCE_DIR environment variable
  3. Install the mlc_llm CLI tool following the official guide
  4. Create a mlc-config.json file in your project root to specify which models you want to use
  5. For Android, set up the required NDK environment variables
  6. For iOS, add the "Increased Memory Limit" capability in Xcode and install CocoaPods
  7. Run npx react-native-ai mlc-prepare to generate all necessary binaries and libraries
  8. Add the required polyfills to make Vercel AI SDK work with React Native
To check what are the latest steps to get module working in your project we highly recommend checking out Installation section in README.

Available Models

The library supports various quantized models that can run efficiently on mobile devices. You can specify these in your mlc-config.json file. Some popular options include:

  • Mistral-7B-Instruct (various quantization levels)
  • Llama-2-7B
  • Phi-2
  • Gemma-2B

Each model is available in different quantization levels (like q3f16_1, q4f16_1) which affect the model size and performance. To get started we recommend using some models from “Model” section in mlc-ai organization on HuggingFace.

Usage

After you’re done with package setup, and you chose your perfect model you can use API which we described before to download model from HuggingFace, then load it to the memory and generate (or stream) output from LLM 🔥 To learn more about usage check out API section in the README file.

Moving beyond AI SDK and integrating with more model architectures

Just like React allows you to write the code once and then “compiles” it to run on multiple devices, so does MLC with AI. Currently, we focus on integration with the AI SDK because we see great value in it and love using it in our own projects. But since MLC focuses on preparing the ideal runtime for the model, in the future, it should be possible to run other models as well.

Imagine a dedicated runtime for the models you have. Optimized and prepared to get the most out of the device it runs on, with a simple command, preparing the model created in any framework available to run on any device available. This is possible. And even though we know there’s a lot of work ahead, we are excited to start that journey!

Challenges and things to improve

Currently, the setup is quite complex. It requires a lot of steps to correctly set up linking native static libraries, making everything compile correctly on both platforms, etc.

We’ve created a CLI that improves the experience and validates some required env variables, reads config and calls relevant CLI to properly prepare required pieces. We believe that there’s room for improvements to lower the number of steps required to make things work.

In our backlog, there’s also a place for more guides, tutorials, and content presenting what’s possible, what the limits are, and where it can be leveraged—so stay tuned.

To wrap things up

There’s a lot of excitement around on-device LLMs, where we can have our “own” AI accessible from devices that we all carry in our pockets. To catch up with the excitement and align with the DevX on the web, we wanted to bring the best API possible.

We hope that this API will be future-proof and will fit the developers' needs. We’re more than happy to hear the feedback and hopefully implement some improvements!

Thank you

Huge thanks to Kewin for supporting me in development, for creating the whole Android module, and for helping design the user-facing API 🙏 Also thanks to Jamon for sharing react-native-ai package 🫡

Insights

Learn more about AI

Nov 12Live Stream

Mobile Development, Plugins & AI-Powered Workflows

Join Kewin Wereszczyński and Hanno Gödecke on November 12 for live demos and a discussion of the Mobile Dev plugin and AI-powered mobile workflows.

Build, Launch, and Maintain: The Business Case for a Software Factory

Nov 10Article

Build, Launch, and Maintain: The Business Case for a Software Factory

Explore an anonymized software factory business case, its delivery workflow, and the staffing assumptions behind a projected 65% reduction in total costs.

Harness Engineering: Context, Skills, and Reliable AI Workflows

Nov 10Podcast

From Prompts to Harnesses: Building Reliable AI Workflows

Amazon’s Anisha Malde joins Łukasz Chludziński to discuss harness engineering, agent skills, and how AI is changing cross-platform development.

Building a Software Factory: Write Specs an Agent Can Build From — cover

Nov 6Article

Building a Software Factory: Write Specs an Agent Can Build From

Learn how to research requirements, resolve open decisions, and write testable specs that AI coding agents can implement without the planning conversation.

 Large-Scale Migrations With Coding Agents: Planning, Verification, and Rollback — cover

Nov 4Article

Large-Scale Migrations With Coding Agents: Planning, Verification, and Rollback

Plan codebase migrations with coding agents using reviewable requirements, verification checks, staged rollouts, and defined rollback criteria.

Conversational Banking: From Customer Questions to Authorized Actions — cover

Nov 2Article

Conversational Banking: From Customer Questions to Authorized Actions

Explore conversational banking architecture through a card-dispute example, covering tool access, authorization, execution, observability, and human handoff.

Building a Software Factory: The Night My Agents Waited for Me — cover

Oct 28Article

Building a Software Factory: The Night My Agents Waited for Me

Learn how permissions, review limits, and missing product decisions stalled two overnight coding agent runs, and how their maintainer revised the workflow.

Your AI Coding Agent Still Needs an Architecture — cover

Oct 22Article

Your AI Coding Agent Still Needs an Architecture

Use explicit contracts, behavior tests, and dependency checks to guide AI coding agents and review their changes through a TypeScript favorites example.

cover

Oct 15Live Stream

Who Left the Agents Running? React Native Software Factories

Join Kewin Wereszczyński and Szymon Chmal to explore what can go wrong in a React Native software factory overnight and the controls that keep agents on track.

cover

Oct 14Podcast

When Coding Gets Faster, What Breaks Next?

Matt Hargett explains how AI moves bottlenecks across testing, deployment, infrastructure, support, and the rest of software delivery.

cover

Oct 12Podcast

AI Coding Agents and Hermes With Tzvetan Mikov

Tzvetan Mikov discusses AI coding agents, context switching, low-level engine optimization, reviewing specs and tests, and his plans for Hermes X.

cover

Oct 7Talk

Automating Mobile QA with Cloud Agents

Michał Pierzchała shows how cloud-based QA agents can test real iOS and Android user flows and bring screenshots, recordings, and logs into pull requests.

cover

Mar 19Tutorial

The Hard Way vs. The React Native AI SDK Way: Stop Writing Custom Modules for Every Model

Learn how React Native AI uses a unified provider model to switch between cloud and on-device LLMs without rewriting application logic, enabling reliable AI experiences online and offline.

cover

Mar 12Tutorial

Build Smarter Apps: Tool Calling & AI Orchestration Explained

Learn how on-device models in React Native can call tools, interact with external APIs, and return structured outputs you can use directly in application logic.

cover

Mar 5Tutorial

MLC LLM + React Native: On-Device AI Without the Pain

Learn how to run third-party on-device LLMs in React Native using MLC LLM. Choose your models, run them efficiently across platforms, and keep a unified JavaScript API with React Native AI.

cover

Feb 24Tutorial

Intelligent Fallbacks with Apple Intelligence in React Native

Learn how to use Apple’s built-in Foundation Models in React Native apps, reduce memory usage, and enable fast, fully on-device AI with React Native AI Apple.

cover

Feb 10Tutorial

What Is the React Native AI SDK? A Complete Intro & Quickstart

Learn why on-device AI matters for React Native apps, how local LLMs behave offline, and what problems React Native AI is designed to solve from day one.

cover

Jan 29Tutorial

Implementing an Android TurboModule with Kotlin

Learn how to implement a React Native TurboModule on Android, from the TypeScript spec and Codegen to the Kotlin implementation and package registration.

cover

Jan 19Tutorial

Working with Different Threads in Swift TurboModules

Learn how JavaScript, native module, background, and main threads interact in React Native TurboModules, and how to use GCD queues to run async work safely in Swift.

cover

Jan 9Tutorial

How to Add Type-Safe Constants to Swift TurboModules

Learn how to expose typed, immutable constants from a Swift TurboModule using Codegen, and get full end-to-end type safety between native and JavaScript.

cover

Dec 30Tutorial

Adding Event Emitters to Your TurboModule in Swift

Learn how to emit native events from a Swift TurboModule and subscribe to them in JavaScript, including proper memory management and Codegen integration.

Writing a Swift TurboModule in React Native

Dec 22Tutorial

Writing Your First TurboModule in Swift

Learn how to build a fully working TurboModule in Swift, integrate it with Codegen, and bridge it through Objective‑C inside an Expo app.