darkmatter-react-native
v0.1.3
Published
OTA updates for React Native, built from first principles
Maintainers
Readme
darkmatter-react-native
OTA updates for React Native, built from first principles in Rust.
Features
- Rust Core: Shared logic between CLI and mobile for consistency
- React Native 0.76+: Built for New Architecture (TurboModules)
- Type-Safe: Full TypeScript support with React hooks
- Cross-Platform: iOS and Android support
- Hermes Ready: Works with Hermes bytecode bundles
Quick Start
Full guide: dark-matter.io/docs/quickstart — Zero to OTA update in 10 minutes.
npm install darkmatter-react-nativeimport { initialize, useUpdate } from 'darkmatter-react-native';
// Initialize once
initialize({
baseUrl: 'https://api.yourdomain.com',
appId: 'your-app-id',
channel: 'production',
});
// Use the hook
function App() {
const { updateInfo, status, check, download, apply } = useUpdate();
if (status.type === 'ready') {
return <Button title="Restart" onPress={() => apply({ restartImmediately: true })} />;
}
return <Button title="Check for Updates" onPress={check} />;
}Documentation
- Integration Guide - Full setup instructions for iOS and Android
How It Works
Dark Matter intercepts React Native's bundle loading at startup:
- Check: Call
checkForUpdate()to see if a new bundle is available - Download: Call
downloadUpdate()to fetch the bundle with progress tracking - Apply: Call
applyUpdate()to mark the bundle for loading on next restart
The native BundleLoader provides the custom bundle URL to React Native, replacing the embedded bundle with your OTA update.
Architecture
┌─────────────────────────────────────────────────────┐
│ Your React Native App │
├─────────────────────────────────────────────────────┤
│ darkmatter-react-native (TypeScript) │
│ ├── initialize(), checkForUpdate(), useUpdate() │
│ └── Native bridge (TurboModule) │
├─────────────────────────────────────────────────────┤
│ iOS: Swift + Rust Android: Kotlin + Rust │
│ ├── DarkMatterImpl ├── DarkMatterModule │
│ ├── BundleLoader ├── BundleLoader │
│ └── libdarkmatter.a └── libdarkmatter.so │
├─────────────────────────────────────────────────────┤
│ darkmatter-core (Rust) │
│ API client, update logic │
└─────────────────────────────────────────────────────┘Requirements
- React Native 0.76+
- iOS 13.4+ / Android API 24+
- New Architecture enabled
- Hermes (recommended)
Building from Source
The Rust core must be compiled for each platform:
# iOS (requires Xcode)
cd core && ./scripts/build-ios.sh --release
# Android (requires Android NDK)
cd core && ./scripts/build-android.sh --releaseLicense
MIT
