$ npm install pear-runtime-react-nativePear runtime for React Native: storage path, bare workers (worklets), and OTA updates.
npm install pear-runtime-react-native react-native-bare-kit
Requires react-native-bare-kit in your project.
This boilerplate is MVP and Experimental.
import PearRuntime from 'pear-runtime-react-native'
import bundle from './worker.bundle.js'
const runtime = new PearRuntime()
const IPC = runtime.run('/worker.bundle', bundle)
OTA works for Expo and plain React Native. Native setup differs; Metro and JS setup are the same.
Native — In app.json / app.config.js add the plugin, then run prebuild:
{ "expo": { "plugins": ["pear-runtime-react-native/plugin"] } }
npx expo prebuild
Release builds load the OTA bundle from pear-runtime/ota/app.bundle when present.
Metro and App entry below.
Apply the same native changes (iOS bundleURL, Android getJSBundleFile) to your ios/ and android/ projects manually so release builds load from pear-runtime/ota/app.bundle when present. Then do Metro and App entry below.
Create metro.config.js in the project root:
const { getMetroConfig } = require('pear-runtime-react-native/metro-config')
module.exports = getMetroConfig(__dirname, { useExpo: true, useSentry: false })
Options (second argument): useExpo — merge in expo/metro-config when available (default true). useSentry — merge in @sentry/react-native/metro when available (default false).
Add @react-native/metro-config to your devDependencies. With Expo, expo/metro-config is merged in automatically. Then npx react-native bundle works for OTA payloads.
npm install @react-native/metro-config --save-dev
From the project root (entry file must match your app, e.g. index.js):
npx react-native bundle --platform ios --dev false --entry-file index.js --bundle-output dist/by-arch/<host-arch>/app/app.bundle --assets-dest dist/by-arch/<host-arch>/app
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output dist/by-arch/<host-arch>/app/app.bundle --assets-dest dist/by-arch/<host-arch>/app
cp -f package.json dist/package.json
Then stage and seed with pear as in your OTA flow.
const pear = PearRuntime()Create a pear runtime (currently doesnt do anything on its own).
IPC <stream.Duplex> = pear.run(filename, bundle, argv)Start a Bare worklet. returns IPC duplex stream.
Apache-2.0