Bluetooth Low Energy

How do you send data between two phones without internet in React Native?

You use a direct radio link reached through a native module. If the phones may be an iPhone and an Android phone, the dependable choice is Bluetooth LE with each phone able to advertise and scan. Platform peer-to-peer APIs such as Google's Nearby Connections and Apple's Multipeer Connectivity are options when you know which platforms the pair runs. All of these need native code, so the app runs as a native build or an Expo development build, not in Expo Go.

TL;DR

Pick the link by the platform pair: Bluetooth LE with both roles on each phone covers iPhone and Android, while Nearby Connections and Multipeer Connectivity suit same-platform pairs. Every option is a native library, so the app needs a native or Expo development build, not Expo Go. Make transfers dependable with chunking, application-level acknowledgments and item IDs.

Learning objectives

After reading this article you will be able to:

  • Choose a direct link for a React Native app by which platforms the phones run
  • Explain why phone-to-phone libraries need a native build rather than Expo Go
  • Describe how chunking, acknowledgments and item IDs make transfers dependable

Direct links by phone platform pair

Bluetooth LE works for every pair, and the platform peer-to-peer APIs add options when both phones run the same platform. The right answer depends on which phones need to talk, so decide that first.

PhonesOptions
iPhone and AndroidBluetooth LE, with both roles on each phone
Android and AndroidBluetooth LE, or Google’s Nearby Connections
iPhone and iPhoneBluetooth LE, or Apple’s Multipeer Connectivity

Most consumer and field apps cannot choose their users’ phones, which is why Bluetooth LE is the usual starting point. The platform peer-to-peer APIs are useful when you know the pair. Can an iPhone and an Android phone connect directly without internet? goes through each radio in more detail.

Native code for React Native data transfer

Every option for sending data between phones in React Native is a native library on iOS and Android, reached from JavaScript through a native module. That rules out Expo Go. The react-native-ble-plx README says that it cannot be used in the Expo Go app because it requires custom native code, and the same applies to every library in this article. Expo’s answer is a development build, which Expo describes as your own version of Expo Go where you can use any native library and change native configuration. Bare React Native projects work the same way: install the module, rebuild the native app, and run it on real phones.

Bluetooth LE data transfer in React Native

Sending data between two phones over Bluetooth LE needs both BLE roles: Bluetooth LE is available to apps on both platforms, but a connection is asymmetric. One phone, the peripheral, advertises and hosts a GATT server; the other, the central, scans, connects, and reads and writes. Android’s BLE overview notes that two devices that only support the central role cannot talk to each other.

That matters because common React Native BLE libraries are built for phones talking to sensors, which only needs the central role. The react-native-ble-plx README lists “communicating between phones using BLE (Peripheral support)” among the things it does not support. To send data phone to phone over BLE you need the peripheral side too:

  • write a native module for the peripheral role on each platform, and keep ble-plx or a similar library for the central side;
  • adopt a community package that exposes the peripheral role, after checking its platforms, maintenance and license; or
  • use an SDK that runs both roles for you.

Can react-native-ble-plx connect two phones directly? covers these routes and the platform APIs behind them.

Multipeer and Nearby Connections in React Native

Nearby Connections and Multipeer Connectivity are both native peer-to-peer APIs, and community wrappers bring them to React Native.

Nearby Connections. Google’s API lets one device advertise, another discover it and request a connection, and both accept before data flows. After that the link is symmetric. Data moves as one of three payload types: bytes, which Google limits to 32k and suggests for metadata or control messages; files of any size; and streams generated on the fly. Google publishes libraries for Android and for Swift.

Multipeer Connectivity. Apple’s framework does discovery and sessions between Apple devices, carrying messages, streams and files. On iOS it uses infrastructure Wi-Fi, peer-to-peer Wi-Fi and Bluetooth personal area networks. It is available only on Apple platforms, so it cannot reach an Android phone.

expo-nearby-connections, for example, offers one JavaScript API that uses Nearby Connections on Android and Multipeer Connectivity on iOS. Its README is clear about the limit that follows: cross-platform peer-to-peer between Android and iOS is not supported. A single JavaScript API is not the same thing as a single radio protocol, so check what each wrapper runs underneath before relying on it for mixed pairs. Multipeer Connectivity alternatives that work with Android compares the options.

Reliable phone-to-phone data transfer

Reliable transfers between two phones come from chunking large data, acknowledging at the application level, giving each item an ID so retries are safe, and testing under real conditions. Whichever link you choose, these habits make the transfer dependable:

  • Chunk large data. BLE characteristics carry short pieces of data, so a photo or a long record has to be split, numbered and reassembled. How do you send a file between two phones without internet? covers files in particular, from AirDrop and Quick Share to in-app transfers.
  • Acknowledge at the application level. A link reporting that bytes were sent is not proof that the other app stored them. Have the receiver confirm once it has saved the item. What is an acknowledgment (ACK)? explains the pattern.
  • Make retries safe. Connections drop, so the sender will sometimes resend something that already arrived. Give each item an ID so the receiver can ignore duplicates.
  • Test the real conditions. Turn off cellular data and Wi-Fi, try both phones in the foreground and background, and try more than one Android manufacturer.

If you would rather not build the Bluetooth layer, Offline Protocol’s @offline-protocol/mesh-sdk 0.33.0 is one example of a React Native native module that advertises and scans over BLE on each phone, encrypts messages with MLS and reports delivery back to the sender. Its installation guide notes that it does not run in Expo Go; a custom development client or a bare React Native project is required.

Frequently asked questions

Can I test phone-to-phone transfer in the iOS Simulator or Android emulator?

You can test that the app builds and the JavaScript side is wired correctly, but not that two radios deliver data. Use two physical phones for anything involving Bluetooth or peer-to-peer Wi-Fi.

Can an iPhone and an Android phone send data to each other without internet?

Yes, over Bluetooth LE, with each phone able to advertise and scan. Apple's Multipeer Connectivity is available only on Apple platforms, so it cannot reach an Android phone.

How much data can Nearby Connections send in one payload?

Google limits byte payloads to 32k and suggests them for metadata or control messages. File payloads can be any size, and stream payloads are generated on the fly.

Does expo-nearby-connections connect an iPhone to an Android phone?

No. It offers one JavaScript API that uses Nearby Connections on Android and Multipeer Connectivity on iOS, and its README says cross-platform peer-to-peer between Android and iOS is not supported.

Why does a phone-to-phone transfer need its own acknowledgments?

A link reporting that bytes were sent is not proof that the other app stored them. Having the receiver confirm once it has saved the item, and giving each item an ID, lets the sender retry without the receiver keeping duplicates.

Sources

Build it with Offline Protocol

The quickstart installs the mesh SDK in a React Native app and sends a message between two physical phones over Bluetooth LE, then repeats it with cellular data and Wi-Fi turned off.

Read the quickstart