Old architecture vs. new architecturePart 8 of 14

JSI (JavaScript Interface)

A C++ interface to the JavaScript engine, built on HostObjects and HostFunctions, with one thread per runtime

AdvancedVerified on React Native 0.88Updated 6 December 2026

Read first: Codegen

The big idea#

JSI is a C++ API for working with a JavaScript engine. React Native's C++ code talks to the JSI interface, never to Hermes directly, and the engine provides the implementation. That buys two things. The first is engine independence. The second is direct access: C++ can create JS values, read JS objects and call JS functions, and JS can call C++ functions, all in the same memory and without serialization.

Concepts#

The building blocks#

TypeWhat it is
jsi::RuntimeThe engine instance. Every JSI call needs it.
jsi::ValueAny JS value: undefined, null, boolean, number, string, object…
jsi::String, jsi::Object, jsi::Array, jsi::FunctionSpecific kinds of values
jsi::ArrayBufferBinary data both sides can read without copying
jsi::HostFunctionA C++ function JS can call like a normal function
jsi::HostObjectA C++ object that looks like a JS object; reading a property calls its C++ get()
jsi::NativeStateA lighter way to attach C++ data to a plain JS object

HostFunction and HostObject are the foundation of everything else in the new architecture.

The simplest JSI code#

C++
void install(jsi::Runtime &rt) {
  auto add = jsi::Function::createFromHostFunction(
      rt, jsi::PropNameID::forAscii(rt, "nativeAdd"), 2,
      [](jsi::Runtime &rt, const jsi::Value &thisVal,
         const jsi::Value *args, size_t count) -> jsi::Value {
        return jsi::Value(args[0].asNumber() + args[1].asNumber());
      });
  rt.global().setProperty(rt, "nativeAdd", std::move(add));
}
TypeScript
global.nativeAdd(2, 3); // 5: a direct C++ call

This is "bare JSI", how early JSI libraries worked. It's fast but untyped (asNumber() throws on a string), not lazy, and must be installed at the right moment. A Turbo Module is a standardized, typed, lazily loaded version of this idea.

What Calculator.add(2, 3) really does#

A Turbo Module call through JSI

JS callCalculator.add
HostObjectget("add")
HostFunctionConvert args
Native methodKotlin or ObjC
Return valuejsi::Value(5)

Boxes: JS call (Calculator.add); HostObject (get("add")); HostFunction (Convert args); Native method (Kotlin or ObjC); Return value (jsi::Value(5)). Arrows: JS call to HostObject; HostObject to HostFunction; HostFunction to Native method; Native method to Return value; Return value to JS call.

4 steps

All on the JS thread, with no JSON.
  • JavaScript
  • C++
  • Native

For an async method, the native code works on another thread and resolves the Promise later through CallInvoker, which schedules a task on the event loop.

Threading rules#

  • A jsi::Runtime is not thread-safe. Only the JS thread may use it, and every jsi::Value is only valid there.
  • Native work can happen on other threads, but must return through CallInvoker before touching JS.
  • Multiple runtimes can exist. Reanimated runs a second runtime on the UI thread for worklets: separate runtimes, each with its own thread.
  • Never keep a jsi::Value or jsi::Function past the runtime's lifetime. A development reload destroys the runtime; a stored JS callback then becomes a dangling reference and crashes the app.

Myths vs reality#

Myth

JSI lets JavaScript invoke functions executed on different threads (concurrency)

Reality: one runtime is used by one thread. JSI enables native work on background threads (returning through CallInvoker) and multiple separate runtimes.

Myth

No serialization means data is free to pass

Reality: numbers and booleans are nearly free, but strings are copied, and large objects are read property by property (each a JSI call). Only ArrayBuffer is truly zero-copy.

Myth

JSI adds type safety

Reality: type safety comes from Codegen. Raw JSI is untyped.

Myth

JSI enables Chakra, V8 and Hermes

Reality: the design is engine-independent, but in practice Hermes is the default, JavaScriptCore lives in a community package, V8 is a community project, and Chakra is discontinued.

In practice#

Three levels of native code you'll find in libraries, all built on JSI:

LevelFingerprintsExamples
Bare JSI#include <jsi/jsi.h>, install(jsi::Runtime&), rt.global().setProperty, HostObject subclassesOlder MMKV, Reanimated internals
Turbo ModuleNative*.ts spec, generated …SpecJSI, methodMap_Most current libraries
Higher-level frameworksSwift/Kotlin DSLs or generated hybrid objectsExpo Modules, Nitro Modules

They differ in how much is generated for you and how much can go wrong, not in the underlying mechanism.

In one sentence

JSI is a C++ interface to the JS engine where native code exposes HostFunctions and HostObjects, so a Turbo Module in JS is a reference to a C++ object and calling a method is a direct C++ call on the JS thread, with one strict rule: only that thread may touch the runtime.