Part 11 · Best practices

Module call threading and payload shape

Prerequisites: 07-turbo-codegen, 08-expo-dsl

Thread hops for an async task

Illustrative queue plan. Actual Expo and TurboModule implementations control their own dispatch. Nodes: JS caller, Module adapter, Worker, Main UI, JS result.
Illustrative queue plan. Actual Expo and TurboModule implementations control their own dispatch. [S09] [S12] [S15]

Mental model verified

Expo Function executes on the JS runtime thread. AsyncFunction normally dispatches native work away from JS and can use a specified queue. Platform UI APIs still require main. A TurboModule contract can expose sync or async methods, but its implementation determines blocking behavior.

[S09] [S12]

Worked flow synthesis

For OCR, return a file URI or handle to native code, process off main, emit a small result and resolve the JS Promise. Transferring full frames through JS on every preview frame adds conversion and rendering pressure.

[S04] [S12] [S13]

Engineering decision synthesis

State max payload, cancellation and timeout semantics in the public API. Profile call overhead, conversion, native SDK time and callback fan-out separately.

[S04] [S12]

Failure mode and improvement synthesis

Moving CPU work into AsyncFunction but pinning it to main simply relocates jank. Choose the queue from the task and audit any UI hop.

[S12] [S15] [S17]
Keep this: A Promise is an API result, not proof that no work blocks a critical thread.
Check yourself: What makes a synchronous function hazardous even with JSI?

It blocks its caller while native work runs; I/O, locks or expensive conversion can stall JS.

Sources & further reading

  1. [S04] About the New Architecture

    React Native · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: JSI references, module and renderer interoperability, limits of performance claims.

    Inspect the implementation boundary described by this source.

  2. [S09] Native Modules: Introduction

    React Native · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Typed TurboModule specification and native implementations.

    Inspect the implementation boundary described by this source.

  3. [S12] Module API Reference

    Expo · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Function, AsyncFunction, queues, views, events and lifecycle.

    Inspect the implementation boundary described by this source.

  4. [S13] Using shared objects

    Expo · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Long-lived native instances, JS references and deallocation.

    Inspect the implementation boundary described by this source.

  5. [S15] Kotlin coroutines on Android

    Android Developers · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Async work and structured cancellation for Android.

    Inspect the implementation boundary described by this source.

  6. [S17] UIKit

    Apple Developer · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: UIKit objects are normally used from the main thread.

    Inspect the implementation boundary described by this source.