Pear runtime for React Native: storage path, bare workers (worklets), and OTA updates.
npm install pear-runtime-react-native react-native-bare-kitRequires 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.jsadd 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.bundlewhen 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-devFrom 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.jsonThen stage and seed with pear as in your OTA flow.
Create a pear runtime (currently doesnt do anything on its own).
Start a Bare worklet. returns IPC duplex stream.
Apache-2.0