Skip to main content

Native Platform

Your app may need features of the operating system that React Native and the community libraries do not provide: a file dialog, the system keychain, a Rust crate, a C++ library you already have. React Native for desktop connects native code to your JavaScript with the same building blocks as React Native, and adds Rust as the default language.

This section introduces:

  • Native modules: native code with no user interface, such as storage, networking or an operating-system service. JavaScript calls them as functions and objects.
  • Native components: native views that React renders. Either a view drawn with GPUI (a host component), or a view that belongs to the operating system itself (a native view).

Choosing how to write native code​

You haveUse
New code that calls the operating systemA Rust module. It is the default for new desktop code, with the Rust ecosystem's crates for most operating-system APIs.
Existing C++ code, or C++ shared with iOS and AndroidA C++ module.
An npm package that already ships a .node binaryA Node addon, which loads unchanged.
A React Native library that already supports iOS and AndroidPort the library to desktop by supplying its native side.
A custom view drawn by GPUIA host component.
A view from AppKit, Win32 or X11A native view.

Where to start​

  1. Native modules
  2. Native components
  3. Libraries
  4. The platform
note

Native modules and components use React Native's new architecture: TurboModules and Fabric. The legacy native module and component APIs of React Native are not available on desktop.