Skip to main content

What is the native bridge?

Some capabilities don’t live in JavaScript at all: reading files, fetching device and build info, reloading the bundle. They live in native modules, compiled into the app and exposed to JS through React Native’s bridge. native is how you reach them. It resolves native modules by name and ships a handful of pre-resolved handles for the ones Unbound needs most.

Resolving native modules

A native module’s name varies across platforms and Discord versions. The iOS file manager might be DCDFileManager on one build and RTNFileManager on another. So getNativeModule takes a list of candidate names and returns the first one that resolves, checking both NativeModules and the TurboModule registry.
import { native } from '@unbound-app/api';

const FileManager = native.getNativeModule(
	'NativeFileModule',
	'DCDFileManager',
	'RTNFileManager',
);
Always pass every name you know a module by. A single name that’s right on your device may be wrong on someone else’s. The candidate list is what makes a module resolve everywhere.

Built-in handles

The native modules Unbound depends on are already resolved for you:
Build and release metadata: version, release channel, build number, identifier.
The bundle updater. Drives OTA update checks and reloads (see below).
Hardware and OS details: device model, manufacturer, system version, RAM.
The native file module the fs module is built on. Prefer fs for file work, since it resolves paths and defaults encodings for you.

Reloading & UnboundNative

reload() is the safe way to restart the bundle: it persists pending settings first, then reloads, so nothing in flight is lost.
import { native } from '@unbound-app/api';

await native.reload(); // persists settings, then reloads
UnboundNative is the raw JSI bridge the platform loader installs on the global. The higher-level handles above are built on top of it, and you generally won’t touch it directly.
If UnboundNative is missing, the environment isn’t a real Unbound install and most native features won’t work. That’s a bug worth reporting, not a state to handle in your addon.