Axonpack

Reference

Every export, config field, hook result, label and theme token.

Use this page to look up a name. If you are new, start with the Quick start. Every command of the CLI is on CLI.

Components and hooks

ExportWhat it is
PreviewProvider{ config: PreviewConfig, children }. Mount it near the root, on every start
PreviewListThe ready-made list. Props: theme, labels, style
usePreview()The list and its actions. Needs the provider above it
useRunning()What this start runs, as a Running. Needs the provider
usePreviewsState()The raw store state, without the provider
useDevPreviewServersState(){ servers, activeUrl, error } for dev preview servers

PreviewConfig

What the app passes to the provider. Nothing here is read from the environment.

FieldNeededWhat it is
enabledYestrue turns previews on. You decide per build; nothing is detected
urlYesWith a read key: <endpoint>/<bucket>[/<folder>], the same as PREVIEW_S3_URL. Without one: any address the files are public under, such as that URL, https://pub-<id>.r2.dev or a CDN
readAccessKeyIdNoA read-only key, for a private bucket. Never the write key
readSecretAccessKeyNoIts secret
regionNoSigning region for a private bucket. Default us-east-1; auto on R2
headersNoExtra headers on every read, for a proxy, CDN or tunnel in front of the bucket
devPreviewServersNoLists this app's Metro servers in a debug build. Default off. See Dev preview servers
buildKeyNoThis build's key, only when the config plugin is not used to bake it in

usePreview

FieldWhat it is
enabledconfig.enabled
devPreviewServersWhether dev preview servers are on
itemsPreviewItem[]: this build's previews, and downloads it no longer lists
incompatibleDownloads made for another native build
loadingA refresh is running
errorThe last error, as text, or null
buildKeyThis build's key, or null without the plugin
remoteWhat the bucket lists for this build. Null until it has answered once
localEvery download on the device
downloadingDownload progress by id, from 0 to 1
activeIdThe preview the next start loads, or null for the base bundle
brokenIds of previews that stopped before they finished starting
ActionWhat it does
refresh()Reads the downloads, then asks the bucket for this build's list
download(id)Downloads a preview, or its update
switchTo(id)Restarts into a preview, downloading it first if needed
switchTo(null)Back to base. Also stops a dev preview server
remove(id)Deletes a download. If it runs, goes back to base first
removeIncompatible()Deletes every download made for another native build

PreviewItem

FieldWhat it is
idThe preview's id
entryThe bucket's entry: title, branch, commit, author, publishedAt, appVersion, buildNumber, compatibility, fingerprint, size, changelog, revision, manifest
statusavailable, downloading, downloaded, update-available, unpublished or broken
progress0 to 1 while downloading, else null
activeIt is the one the next start loads
localThe download on the device, or null

Running

kindFields
basenone
previewid, title
localurl, hostPort, server (null until the list has found it)

Functions

FunctionWhat it does
selectPreview(id, key?)Chooses what the next start or reload() loads: a preview id, or null for the base bundle. False where the native module is missing
reload()Restarts JS, so a new choice takes effect. False where the native module is missing
previewBundlePath(id)Where a preview's bundle sits, relative to the preview folder
markLaunched()Tells the native side this start worked. The provider calls it
buildKey()The key the plugin baked into this build, or null
buildCompatibility()appVersion or fingerprint, as baked in, or null
buildSlug()The app's slug, as baked in, or null
previewTitle(id)The readable title for an id: task-1-login-fix becomes "Task 1 login fix"
previewItems(state){ items, incompatible } from the store state
runningNow(input)The pure form of useRunning()
resolveTheme(theme, scheme)A full list theme from a partial one and the device's colour scheme

previewsStore and devPreviewServersStore are the stores behind the hooks, with getState() and subscribe(), for use outside React.

Theme

PreviewList's theme takes any of these. LIGHT_THEME and DARK_THEME are the defaults.

TokenWhat it colours
modeauto (follows the device), light or dark. Default auto
backgroundBehind the list
cardEach card
surfaceBehind the changelog and the progress track
borderCard and button borders
titleHeadings
textBody text
mutedQuiet text: branch, author, date, size
primaryMain buttons
primaryTextText on main buttons
dangerDelete, and errors
warningUpdate available, unpublished, and the Metro note
successDownloaded
radiusCard corner radius. Buttons scale from it. Default 14
fonts{ regular, medium, bold } font family names. Each falls back to the system font

Labels

PreviewList's labels takes any of these. DEFAULT_LABELS has the defaults.

LabelDefault
titlePreviews
runningRunning
baseEmbedded bundle
backToBaseBack to base
metroBypassedDebug build: Metro is not used while a preview runs. Go back to base to load from Metro again.
refreshRefresh
emptyNo previews published for this build yet.
noBuildKeyThis build has no compatibility key, so it cannot list previews. Add the config plugin and rebuild.
downloadDownload
switchToSwitch
updateUpdate
deleteDelete
statusOne per status: Not downloaded, Downloading, Downloaded, Update available, Unpublished, Broken: it stopped while starting
incompatibleTitleIncompatible
incompatibleHintMade for another native build. They can't run on this one.
deleteAllDelete all
devPreviewServersTitleDev preview servers
devPreviewServersHintMetro servers for this app on your computer. Debug builds only.
noDevPreviewServersNo Metro server found. Start one with npx preview start.
noBuildSlugThis build has no app slug, so it cannot tell its servers from other apps'. Add the config plugin and rebuild.
stopDevPreviewServerStop using dev preview server
localSuffixlocal
localIncompatibleMade for another native build
localUnknownBuildNative build unknown

status is merged per key, so labels={{ status: { broken: 'Crashed' } }} changes only that one.

Config plugin

["@axonpack/preview", { "compatibility": "appVersion" }]
OptionDefaultValues
compatibilityappVersionappVersion or fingerprint

See Compatibility for what it writes into the build.

On this page