# react-native-fast-tflite: TensorFlow Lite in React Native with zero-copy buffers and GPU delegates

> react-native-fast-tflite brings TensorFlow Lite inference to React Native using Nitro Modules, passing model inputs and outputs as zero-copy ArrayBuffers through the C/C++ TFLite core API. GPU delegates for CoreML, Metal, and OpenGL are supported, but tensor shape handling is entirely the caller's responsibility.

**margelo/react-native-fast-tflite** — 🧬 High-performance TensorFlow Lite library for React Native with GPU acceleration

- Repository: https://github.com/margelo/react-native-fast-tflite
- Website: https://mrousavy.com
- Stars: 1,239 · Forks: 92
- Language: TypeScript
- License: MIT
- Published: 2026-10-11 · Updated: 2026-10-11 · Language: en
- Canonical page: https://hysenlabs.com/projects/margelo-react-native-fast-tflite

## Zero-copy ArrayBuffers and direct C/C++ TFLite access instead of a JavaScript bridge

Standard React Native native modules pass data through a bridge that serializes values and copies memory between the JavaScript engine and native code. react-native-fast-tflite takes a different path: it uses Nitro Modules to call the C/C++ TensorFlow Lite core API directly, and it represents both model inputs and outputs as ArrayBuffers with zero copies. The model never sees a serialized form of your data.

That matters most in real-time camera use. Processing video frames from a camera on every capture means the cost of a full serialization cycle per frame would be prohibitive. The zero-copy path means the ArrayBuffer you prepare in JavaScript maps directly to what the TFLite runtime reads, and the output ArrayBuffer comes back on the same memory path. The architecture also supports swapping TensorFlow models at runtime without rebuilding the app.

## Installing with yarn and wiring metro.config.js to accept .tflite asset files

Two packages are needed: the library itself and Nitro Modules, its core dependency.

```sh
yarn add react-native-fast-tflite react-native-nitro-modules
```

After adding the packages, metro.config.js needs one change: tflite must appear in the resolver's assetExts array. Without it, Metro will not bundle .tflite files and loading models from the app's asset folder will fail:

```js
module.exports = {
  // ...
  resolver: {
    assetExts: ['tflite', // ...
```

Adding tflite to assetExts also enables runtime model swapping: you can drop a different .tflite file in and load it without a rebuild. GPU delegates are optional and require separate setup. For iOS, run npx pod-install before building; for Android, run yarn android.

## Three model loading paths: bundle require, local file, and remote URL

Models can be loaded from three sources. The README shows all three in a single block:

```ts
// Asset from React Native Bundle
loadTensorflowModel(require('assets/my-model.tflite'), [])
// File on the local filesystem
loadTensorflowModel({ url: 'file:///var/mobile/.../my-model.tflite' }, [])
// Remote URL
loadTensorflowModel(
  { url: 'https://tfhub.dev/google/lite-model/object_detection_v1.tflite' },
  []
)
```

The second argument is the delegates array. An empty array means CPU inference with no GPU acceleration.

All three forms are asynchronous: buffers are allocated before the model is ready, so the promise must resolve before you call run. The README says to handle errors during loading explicitly. A hook alternative exists for function components: useTensorflowModel takes the same arguments and manages the loading lifecycle, returning the model's current state.

## Tensor shapes are your responsibility: use Netron to inspect the model before writing input code

TensorFlow Lite treats input and output as fixed-size byte buffers. react-native-fast-tflite exposes these as ArrayBuffer, with no higher-level API to parse them. Preparing the correct input shape and interpreting the output bytes correctly is your work.

Netron (netron.app) is the inspection tool the README points to. Opening a .tflite file there shows the model's input and output tensors with their data types and shapes. The README uses an object detection model from tfhub.dev as a concrete example: that model takes 1 input tensor at 192 by 192 pixels with 3 bytes per pixel in RGB order, and produces 4 output tensors for boxes, classes, scores, and detection count. Getting the shape wrong at call time produces a runtime error, not a compile-time one.

Providing data in the correct layout requires converting your source (a camera frame, an image file, or a prepared array) to a raw ArrayBuffer with the right dimensions before calling run.

## CoreML on iOS: two setup paths for Expo config plugins and bare React Native Podfiles

CoreML is the iOS GPU delegate. Expo projects add the config plugin to their app.json or app.config.js:

```json
{
  "name": "my app",
  "plugins": [
    [
      "react-native-fast-tflite",
      {
        "enableCoreMLDelegate": true
      }
    ]
  ]
}
```

Bare React Native projects set $EnableCoreMLDelegate to true in the Podfile:

```ruby
$EnableCoreMLDelegate=true
```

After that, the CoreML framework must be added manually in Xcode under General > Frameworks, Libraries and Embedded Content, and pod install must run again before building. To activate the delegate at runtime, pass 'core-ml' in the delegates array:

```ts
const model = await loadTensorflowModel(
  require('assets/my-model.tflite'),
  ['core-ml']
)
```

The README includes an explicit warning: not all model operations are supported on the CoreML delegate. Testing your specific model against that delegate before shipping is a required step.

## VisionCamera frame processors and the runSync path for worklet inference

The README provides a full VisionCamera integration example. A useTensorflowModel hook loads the model, a useResizer hook from react-native-vision-camera-resizer converts each camera frame to the model's expected dimensions, and a useFrameOutput callback calls model.runSync inside the worklet.

runSync, unlike run, is synchronous and designed for use inside VisionCamera worklets, which run on a separate thread. The async run path does not fit that execution context. The integration example resizes each frame to 192 by 192 pixels in RGB uint8 format, slices the ArrayBuffer to the exact byte range the model expects, and calls runSync with that buffer.

The README includes a compatibility note: when VisionCamera is built on Nitro Modules internally and uses react-native-worklets, worklets can hold a reference to the TFLite model as a HybridObject directly. An earlier VisionCamera architecture required wrapping the model with NitroModules.box() before passing it into a worklet.

## Android GPU documentation is cut short, and the migration guide covers breaking changes from the prior major version

The Android GPU and NNAPI section of the README opens with a note that native libraries may be needed on Android 12 and up, then ends. The content cuts off at a bare heading with no body text beneath it. Developers targeting Android with GPU or NNAPI acceleration will find no setup steps in the README and will need to consult sources outside it.

For teams upgrading from the prior major version, MIGRATION_V2_TO_V3.md in the repository root documents the breaking changes and upgrade steps. The README points to that file without reproducing its contents.

The last push to the repository was on 2026-09-11. The library is MIT-licensed.

## Conclusion

Use react-native-fast-tflite when you need on-device ML inference in a React Native app and can accept preparing raw ArrayBuffer inputs and interpreting raw outputs yourself. The zero-copy path and CoreML delegate are real hardware paths, but tensor shape handling is entirely your responsibility. Skip it for Android GPU workflows: the README's Android GPU and NNAPI section is incomplete. Before shipping, test your specific .tflite model under the CoreML delegate, since the README states that not all operations are supported on that delegate.

## FAQ

### How do I install react-native-fast-tflite?

Run yarn add react-native-fast-tflite react-native-nitro-modules, then add tflite to the assetExts array in metro.config.js. For iOS, run npx pod-install before building. GPU delegates require additional setup described in the README.

### Does react-native-fast-tflite support GPU acceleration on Android?

The README opens an Android GPU and NNAPI section and notes that native libraries may be needed on Android 12 and up, but the section ends there without completing the setup steps. Android GPU documentation is not finished in the README.

### What TensorFlow Lite models work with react-native-fast-tflite?

Any .tflite format model can be loaded. The README points to tfhub.dev as a source with thousands of public models. Inspect your model's tensor shapes in Netron before writing the ArrayBuffer conversion code.

### How do I use react-native-fast-tflite with VisionCamera?

Load the model with useTensorflowModel, use react-native-vision-camera-resizer to convert each frame to the model's input dimensions, and call model.runSync inside a useFrameOutput worklet. When VisionCamera is built on Nitro Modules, worklets can reference the model directly without boxing it.

### Is react-native-fast-tflite compatible with Expo?

Yes. Expo projects can enable the CoreML delegate through the config plugin in app.json or app.config.js by setting enableCoreMLDelegate to true inside the react-native-fast-tflite plugin entry.

## Sources

- [License: MIT](https://github.com/margelo/react-native-fast-tflite/blob/main/LICENSE)
- [margelo/react-native-fast-tflite on GitHub](https://github.com/margelo/react-native-fast-tflite)
- [Project website](https://mrousavy.com)
- [README](https://github.com/margelo/react-native-fast-tflite/blob/main/README.md)
- [Releases](https://github.com/margelo/react-native-fast-tflite/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/margelo-react-native-fast-tflite
