Self-hosted Expo OTA
This skill is a babysitter. The protocol lives in this repo's scripts. Copy them. Do not generate Expo Updates v1 from docs, memory, or "a simple Worker that returns JSON."
Install
If the app has no ota-worker/ folder:
npx github:ral7/expo-worker-ota initIf they already have Cursor and want this skill in the project:
npx skills add ral7/expo-worker-otaInit copies the Worker, scripts/publish-ota.mjs, scripts/verify-ota.mjs, scripts/deploy-ota.mjs, gitignores keys/, and generates the signing cert. It does not upload the private key.
Five steps (the whole UX)
- In their Expo app:
npx github:ral7/expo-worker-ota init - Init writes
ota-worker/,scripts/, gitignoreskeys/, generates the cert, and prints what goes inapp.json. Do not editwrangler.tomlby hand unless they asked for a custom name (--name). - Cloudflare once:
npx wrangler loginthennpm run ota:deploy(creates the R2 bucket and deploys). Deploy writesupdates.url. - Ship one Release binary with that URL baked in. TestFlight is enough. Metro / Debug will not download OTA.
- Forever:
npx expo export --platform ios --platform androidthennpm run ota:publish
Default runtimeVersion is "1". That is the native shell, not the store version (1.0.4 is unrelated).
Decision tree
Before any publish:
- Native plugin, permission, Expo SDK, signing cert, or
updates.urlchanged → stop. That needs a new store binary. If the native OTA contract changed, bumpruntimeVersion("1"→"2") so old binaries keep their slot. - JS / copy / API client only, and a Release build already points at their Worker → export, publish, verify.
- They said a TestFlight fence / second slot → publish with
--runtime 2only if they asked. Never publish runtime 2 onto the store slot.
Hard rules
- Do not rewrite
ota-worker/src/ota.ts,scripts/publish-ota.mjs,scripts/verify-ota.mjs, orscripts/deploy-ota.mjs. If something is wrong, copy again fromral7/expo-worker-ota. If the files are missing, run init, do not invent replacements. - Never upload
keys/private-key.pem. Not to the Worker, R2, GitHub, CI, or wrangler secrets. Signing happens on the laptop. The Worker only serves R2 bytes. - Never commit
keys/.certs/certificate.pembelongs in git. It is baked into the binary. - Do not publish every commit. Workers Free is 100k requests/day account-wide. Each update makes every device download the bundle plus assets through the Worker. This is a hotfix hose.
- Do not expect Metro to show the update. Use a Release install. Force-quit, open, force-quit, open. First process downloads. The next process start runs the new JS.
- Verify before telling them it worked.
npm run ota:verify(ornode scripts/verify-ota.mjs --url <origin>) must be 204 (nothing published yet) or 200 multipart/mixed. Never 404. - Rollback is a HEAD pointer, not a delete:
npm run ota:rollback. Old R2 objects stay.
Commands
npx github:ral7/expo-worker-ota init # from the folder with app.json
npx github:ral7/expo-worker-ota init --name my-ota # optional worker / bucket name
npx wrangler login
npm run ota:deploy
npm run ota:verify # 204 until first publish
npx expo export --platform ios --platform android
npm run ota:publish
npm run ota:rollbackpublish and verify read ota.config.json (written by init/deploy). --origin, --runtime, --channel, --private-key override.
app.json (native contract)
After deploy, expo.updates.url must be https://<worker>.<subdomain>.workers.dev/ota/manifest. Changing it requires a new binary.
{
"expo": {
"runtimeVersion": "1",
"updates": {
"enabled": true,
"url": "https://YOUR-WORKER.workers.dev/ota/manifest",
"checkAutomatically": "ON_LOAD",
"fallbackToCacheTimeout": 0,
"requestHeaders": { "expo-channel-name": "production" },
"codeSigningCertificate": "./certs/certificate.pem",
"codeSigningMetadata": { "keyid": "main", "alg": "rsa-v1_5-sha256" }
}
}
}If app.config.js / app.config.ts is in use, do not smash it. Print the snippet and let the user (or a careful edit) add the fields.
What you must not do
- Implement "Updates v1" from scratch.
- Teach EAS Update as a fallback in the same flow. One path.
- Put the private key in a Worker secret.
- Point
updates.urlatr2.devor a guessed subdomain. - Bump
runtimeVersionfor a JS-only hotfix. - Tell them Debug / Expo Go will pick up the publish.