← ClaudeAtlas

shipping-a-model-in-a-react-native-applisted

Put a local language model inside a React Native or Expo app and get it generating on device. Covers react-native-executorch for .pte models and llama.rn for GGUF models, choosing between them, native build configuration and model loading, streaming answers into the UI as tokens arrive, and whether to bundle the model in the binary or download it on first run. Use when the project is React Native or Expo and someone wants on-device or offline AI, local inference, or a model running without an API. Not for iOS native Swift projects, not for Android native Kotlin projects, not for Flutter, and not for models running on a server.
ErtasAI/open-model-skills · ★ 2 · AI & Automation · score 76
Install: claude install-skill ErtasAI/open-model-skills
# Shipping a model in a React Native app Two runtimes cover React Native and Expo, and they do not take the same artifact. Picking between them is the first decision here, before any package gets installed, because reading the wrong runtime's docs for an hour is a common way to lose an afternoon. ## Which artifact shape this needs | You are holding | Package | What it eats | |---|---|---| | A `.pte` file, plus `tokenizer.json`, `tokenizer_config.json`, `config.json` | `react-native-executorch` | An ExecuTorch program | | A single `.gguf` file | `llama.rn` | GGUF, self-contained | These are two separate native modules with two separate build steps. There is no package that takes both. If a `.pte` file gets handed to `llama.rn`, or a `.gguf` file to `react-native-executorch`, it fails to load, full stop. **If what you are holding is neither of these,** a merged Hugging Face checkpoint (`config.json` + `model*.safetensors`) or a PEFT adapter directory (`adapter_config.json` + `adapter_model.safetensors`), it is not shippable into React Native as is. Run **inspecting-a-model-bundle** first to confirm which shape you actually have, then convert: - To `.pte`: `optimum-cli export executorch`, covered below and in `references/executorch-path.md`. - To GGUF: `convert_hf_to_gguf.py` then `llama-quantize`, covered below and in `references/llama-rn-path.md`. A PEFT adapter directory converts to neither format directly. Either merge it into its base model first and export from