WhoBuilt

Open Native and Universal Native Modules With Jamie Birch

Oct 26, 2023· 51 min· 1.1K views·Watch on YouTube

Speaker

Jamie Birch, React Native and NativeScript creator and member of the NativeScript Technical Steering Committee, discusses cross-framework native modules with the Callstack host on the React Native Show podcast.

NativeScript’s JavaScript access to native APIs

Birch describes NativeScript as an end-to-end framework that lets JavaScript call iOS and Android APIs directly. For example, JavaScript can create an iOS `NSString` with `NSString.alloc().init()`, without writing a native module. His longer-term aim is to make NativeScript usable within other frameworks, including React Native.

Why native modules are hard to share

React Native, Flutter, and Capacitor each use different ways to connect JavaScript to native APIs, so their modules are not directly interchangeable. React Native’s classic modules use a JSON bridge, while Capacitor sends messages across a WebView boundary. Birch says this fragmentation makes smaller ecosystems repeat work and makes cross-framework reuse difficult.

From UniModules to Open Native

Birch says Expo’s UniModules proposed a shared format, but Expo ended up doing most of the implementation work, and the effort was deprecated in 2021 in favor of Expo Modules. Open Native takes another approach: it aims to let NativeScript use existing React Native modules as they are, with package installation and autolinking handled by NativeScript. The episode describes this React Native-to-NativeScript path as the capability available at the time.

How Open Native adapts classic modules

Open Native examines React Native’s module macros, registry, and bridge behavior, then uses build-time parsing to extract module names, methods, and signatures into JSON. Birch says the implementation used regular expressions because Objective-C AST approaches were slow. At runtime, NativeScript can load modules on demand and call methods directly, avoiding the classic JSON message round trip; the host cites performance figures in the repository that Birch recalls as possibly about 50 times faster.

Views and broader interoperability remain unfinished

Birch says adapting views is a later phase and was still under construction, with Open Native contributor Omar doing much of that work. View support would require an API-compatible equivalent to React Native’s `RCTView`, and React component libraries may not fit frameworks such as NativeScript Angular. Birch clarifies that Open Native did not yet let React Native consume Flutter modules; the demonstrated use was React Native modules from NativeScript.

Takeaways

  • Different native module formats keep cross-platform ecosystems from reusing each other’s plugins directly.
  • A build step can inspect existing module code and generate metadata, reducing the need for module authors to adopt a new shared format.
  • NativeScript’s direct runtime calls can avoid the classic React Native bridge round trip, according to Birch.
  • Treat function and method access separately from view support; the episode describes view adaptation as unfinished.
  • Open Native’s demonstrated interoperability was React Native modules in NativeScript, not general two-way framework compatibility.

Mentioned in this talk

Search inside this talk

What was claimed 14

Show all 14 facts

Related talks