---
name: self-hosted-expo-ota
description: Set up and publish self-hosted Expo Updates on a Cloudflare Worker with expo-worker-ota (R2, laptop signing, Workers Free). Use when the user mentions OTA, expo-updates, EAS Update alternative, Cloudflare Worker updates, publish JS to a phone, runtimeVersion, rollback-to-embedded, or npx expo-worker-ota. Never invent the Expo Updates protocol.
title: self-hosted-expo-ota
canonical_url: https://skilld.dev/gh/ral7/expo-worker-ota
last_updated: 2026-08-26T18:15:59.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install ral7/expo-worker-ota/self-hosted-expo-ota`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/self-hosted-expo-ota`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/ral7/expo-worker-ota/self-hosted-expo-ota) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/self-hosted-expo-ota`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/self-hosted-expo-ota --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/self-hosted-expo-ota --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# 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:

```bash
npx github:ral7/expo-worker-ota init
```

If they already have Cursor and want this skill in the project:

```bash
npx skills add ral7/expo-worker-ota
```

Init 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)

1. In their Expo app: `npx github:ral7/expo-worker-ota init`
2. Init writes `ota-worker/`, `scripts/`, gitignores `keys/`, generates the cert, and prints what goes in `app.json`. Do not edit `wrangler.toml` by hand unless they asked for a custom name (`--name`).
3. Cloudflare once: `npx wrangler login` then `npm run ota:deploy` (creates the R2 bucket and deploys). Deploy writes `updates.url`.
4. Ship **one** Release binary with that URL baked in. TestFlight is enough. Metro / Debug will not download OTA.
5. Forever: `npx expo export --platform ios --platform android` then `npm 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.url` changed → **stop**. That needs a new store binary. If the native OTA contract changed, bump `runtimeVersion` (`"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 2` only if they asked. Never publish runtime 2 onto the store slot.

## Hard rules

1. **Do not rewrite** `ota-worker/src/ota.ts`, `scripts/publish-ota.mjs`, `scripts/verify-ota.mjs`, or `scripts/deploy-ota.mjs`. If something is wrong, copy again from `ral7/expo-worker-ota`. If the files are missing, run init, do not invent replacements.
2. **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.
3. **Never commit** `keys/`. `certs/certificate.pem` belongs in git. It is baked into the binary.
4. **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.
5. **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.
6. **Verify before telling them it worked.** `npm run ota:verify` (or `node scripts/verify-ota.mjs --url <origin>`) must be **204** (nothing published yet) or **200 multipart/mixed**. Never 404.
7. Rollback is a HEAD pointer, not a delete: `npm run ota:rollback`. Old R2 objects stay.

## Commands

```bash
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:rollback
```

`publish` 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.

```json
{
  "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.url` at `r2.dev` or a guessed subdomain.
- Bump `runtimeVersion` for a JS-only hotfix.
- Tell them Debug / Expo Go will pick up the publish.
