Publishing
Publish a preview, replace it, remove it, and clean up the bucket.
Run the CLI from your app's root, or pass --project <dir>. It needs the
publish settings, a lockfile for the copy's install,
and a git checkout, unless you pass --id.
npx preview publish # id = git branch, both platforms; asks for the title
npx preview publish --id task-1 --changelog="- Fixes the login"
npx preview unpublish task-1
npx preview pruneWith bun, use bunx preview; with pnpm, pnpm exec preview; with yarn, yarn preview.
What publish does
Publish builds in a copy of your project, the way an EAS build does, so it never writes to your app's folder. It only reads from it: the app config, the fingerprint, git and the publish settings. For each platform, Android then iOS:
- Copies the project to a temp folder. See The copy for what goes in it.
- Installs in the copy. It runs your
eas-build-pre-installscript ifpackage.jsonhas one, then the install with a frozen lockfile, theneas-build-post-install. See Install and hooks. - Builds the file sets in the copy: each file set's
buildcommand, then it reads the sets' folders there. - Builds with
expo export:embed --dev false --bytecodein the copy, the same step a release build runs. It starts your app's own Expo CLI with Node, with nonpxor other package manager in between. The result is Hermes bytecode with its images beside it, in the folders the native build uses. - Works out the key from the
compatibilityoption in your app config, the same way the config plugin did for the build. It records the app version and the native fingerprint either way. Both come from your own folder. - Uploads each file once, under its sha256, four files at a time. Files already in the bucket are skipped. It shows how many files are done and the one it started last, and a request whose connection drops is sent again, up to 4 tries. See Errors and retries.
- Writes the manifest: the files, their hashes and sizes, the changelog and the versions, and
the EAS environment when
--environmentis passed. The app shows that as anenv: <name>chip. - Adds the preview to the lists, last. An app never sees a preview whose files are not all there yet.
- Deletes the copy in the background. Publish doesn't wait for it.
It prints the URL of the list it wrote, so you can open it and check. If it stops partway, run it again: the files already uploaded are skipped.
The copy
Publish copies your app's workspace root, the folder that holds the lockfile and the workspace
config. In a monorepo that is the repository's root, so workspace packages and a file set such as
../web/out are in the copy. An app outside a workspace is copied on its own.
Everything is copied, including files git ignores, such as .env.local and a built web/out. So
the bundle gets the same env values as in your folder. These are left out wherever they are:
| Left out | Why |
|---|---|
node_modules | The copy runs its own install |
.expo | Expo makes it again |
ios/Pods, ios/build | Output of a native iOS build |
android/build, android/app/build, android/.gradle | Output of a native Android build |
Other generated folders, such as .next, dist or a docs build, are copied unless a .easignore
at the copy's root lists them, so list them there if publish is slow. It uses the same syntax as
.gitignore, ! included. .gitignore itself isn't read.
The copy has your .git folder, so scripts that run git work there. In a git worktree or a
submodule, .git is a file that points at the real repository, and git in the copy would change
that repository. So it is left out, and publish prints
<platform>: no git in the copy, since .git in <root> is a file pointing at another folder (a git worktree or submodule).
The preview's branch and commit come from your folder either way. Outside a git repository publish
still works, given --id, with no branch or commit, and no changelog unless you pass one.
The copy goes in <temp>/preview-publish-<random>/<platform>, where <temp> is the system's temp
folder ($TMPDIR). Each platform gets its own copy. Once a platform is published, its copy is
deleted by a process of its own, and publish goes on without waiting for it. When publish fails or
you stop it with Ctrl-C, the temp folder is deleted before it exits. Pass --keep-copy to keep it
and look inside.
Install and hooks
The package manager comes from the lockfile, found the way Expo finds it. The install runs in the copy's root:
| Lockfile | Install |
|---|---|
package-lock.json | npm ci --include=dev |
yarn.lock, Yarn 1 | yarn install --frozen-lockfile --production false |
yarn.lock, Yarn 2+ | yarn install --inline-builds --immutable |
pnpm-lock.yaml | pnpm install --frozen-lockfile |
bun.lock, bun.lockb | bun install --frozen-lockfile |
nub.lock | nub install --frozen-lockfile |
Expo finds nub from a nub.lock when your app's @expo/package-manager is 1.14 or later. It comes
with expo, and npm ls @expo/package-manager shows which one you have. With an older one, publish
says there is no lockfile.
With EAS_NO_FROZEN_LOCKFILE=1 set, as on EAS, the lockfile isn't frozen: npm install,
--no-immutable, --no-frozen-lockfile, or no flag for Yarn 1 and bun. Without a lockfile publish
stops. It also stops, before copying anything, when Expo finds a package manager that isn't in this
table. Publish that app with --in-place.
Before the install, publish runs eas-build-pre-install from your app's package.json, and after
it eas-build-post-install, each as <package manager> run <name> in the app's folder in the copy.
Under Yarn, eas-build-pre-install runs through npm, as on EAS. Under nub it runs as
nub run --node eas-build-pre-install, without nub's TypeScript support: nub run reads your
tsconfig.json first, and that fails while what it extends, such as expo/tsconfig.base, isn't
installed yet. A script the app doesn't have is skipped. The end-of-build scripts (eas-build-on-success, -on-error, -on-complete,
-on-cancel) never run, since a preview isn't a native build.
The scripts, the install, the file sets' build commands and the export get EAS_BUILD=1,
PREVIEW_PUBLISH=1 and a few more. See
The copy's environment. A script can skip what
only makes sense on an EAS build:
[ -n "$PREVIEW_PUBLISH" ] && exit 0Build in place
--in-place builds in your app's folder. There is no copy, no install
and no eas-build-* script, and the file sets build once for both platforms. The export then
writes to your folder, for example .expo/.
It's the faster option. For the package's example app in its monorepo, with bun and a warm package cache, an Android publish took 12 s in place and 30 s from a copy, most of it the copy's install and export. Deleting the copy took another 21 s, after publish had exited. Use it where the folder is already a clean checkout with dependencies installed, as on CI. The sample workflows pass it.
The id and the title
The id is the git branch unless you pass --id. QA sees a readable title made from it: -, _ and
/ become spaces and the first letter is a capital, so task-1-login-fix becomes
"Task 1 login fix".
In a terminal, publish asks for the title, prefilled with that; Enter keeps it. --title skips the
question, and so does a run with no terminal, such as CI.
On a detached HEAD there is no branch, so pass --id.
The changelog
Every preview has a changelog QA can read in the list. By default it is the commit subjects since the
branch left the base branch. The base is --base <branch>, or else the remote's default branch
(origin/HEAD), or else main or master.
To write it yourself:
npx preview publish --changelog="- Fixes the login
- New empty state"
npx preview publish --changelog-file CHANGES.mdUse = with --changelog when the text starts with a dash, as a list does.
Replace, unpublish, prune
Replace. Publishing the same id again overwrites its manifest and its entry in the list. A device that downloaded the old one shows Update available.
Unpublish. preview unpublish <id> removes the preview from every build's list and deletes its
manifests. A copy already downloaded stays on the device until QA deletes it, shown as
Unpublished. The files stay in the bucket.
Prune. preview prune deletes every file no manifest refers to any more. Run it now and then
after unpublishing. Nothing runs it on a schedule.
There is no time limit. A preview stays published for as long as you leave it.
One platform, another entry file
npx preview publish --platform android
npx preview publish --entry-file src/main.tsx--entry-file is passed to expo export:embed. A relative path is taken from the app's root,
and in the copy it points at the same file. Leave it out when Expo finds your entry on its own.
Compatibility override
--compatibility appVersion or --compatibility fingerprint overrides the plugin option, with a
warning. A build made with the other setting would not list the preview, so use it only when you know
the build was made that way.
In appVersion mode publish also prints a one-line warning: a native change without a version bump
is not detected. See Compatibility.
The lists in the bucket
Everything goes in a folder named after the app's slug, so several apps can share a bucket.
| File | Who reads it |
|---|---|
<slug>/index/<platform>/<key>.json | The app. Only the previews this native build can run |
<slug>/index.json | People. Every native build and its previews |
<slug>/previews/<platform>/<key>/<id>.json | The app, when it downloads that preview |
<slug>/files/<sha256> | The app, when it downloads that preview |
A preview's file sets go up the same way: each file once, under its sha256,
listed in the manifest under files/<name>/.
Two publishes at the same time both end up listed. The lists are written only if nobody wrote in between, and a clash reads again and retries.
Every flag is on CLI.
Next: CI