Skip to main content

Crate expo_modules_rs

Crate expo_modules_rs 

Source
Expand description

§expo-modules-rs

Rust SDK for writing Expo native modules that integrate directly with the JavaScript Interface (JSI) runtime.

This crate provides:

  • The ExpoModule trait and ModuleBuilder for defining modules
  • JsValue types and conversion traits (FromJsValue, IntoJsValue)
  • The cxx bridge to the JSI C++ layer
  • The #[expo_module] and #[derive(ExpoRecord)] proc macros

§Architecture

+---------------+     +----------------+     +----------------+
|  JavaScript   |---->|   JSI (C++)    |---->|  Rust Module   |
|   (Hermes)    |<----|  jsi_shim.cpp  |<----|  (your crate)  |
+---------------+     +----------------+     +----------------+
        |                    |                      |
   JS calls             cxx bridge             ExpoModule
   module.fn()          FfiValue               trait impl

§Quick Start

use expo_modules_rs::prelude::*;

struct MathModule;

#[expo_module("RustMath")]
impl MathModule {
    #[constant]
    const PI: f64 = std::f64::consts::PI;

    fn add(a: f64, b: f64) -> f64 {
        a + b
    }
}

Modules§

bridge
module
prelude
Prelude module - import everything needed for module development.
value

Functions§

install_modules
C entry point called from the native side (Android JNI or iOS ObjC++) to initialize Rust modules on the JSI runtime.