@mentra/miniapp-cli provides the mentra-miniapp command. It’s installed as a
dev dependency in every scaffolded project, so your package.json scripts call
it directly ("dev": "mentra-miniapp dev").
The CLI is Bun-only: it ships as TypeScript and runs under Bun. Use
bun
(or bunx), not npx/Node.dev
miniapp.json, builds both layers, serves them over your LAN, and
prints a QR of its local-network miniapp URL, http://<lan-ip>:<port>/. That
URL serves miniapp.json like any miniapp URL, naming the build’s ZIP,
<pkg>-<version>-<hash>.zip, and its SHA-256. <hash> is the first 8 hex digits
of that SHA-256, so every build has its own file name. It also runs a dev sidecar WebSocket on the next port up, which tells the
phone when a saved change is built and forwards the miniapp’s console back to
your terminal (non-fatal if it can’t start). It watches for Wi-Fi/LAN-IP changes
every 10 seconds and reprints the QR.
The starting port comes from "port" in miniapp.json (default 3000); if it or
its sidecar neighbor is busy, the CLI scans upward for a free adjacent pair.
On the phone: In the Mentra App, open Settings → Miniapp Developer Settings
→ Scan Miniapp QR Code. Phone and laptop must share Wi-Fi. Ctrl+C stops
everything.
dev runs your miniapp the way an installed one runs: the Mentra App installs
it from the URL and runs it from the phone, screen included, so everything your
miniapp does in development (its storage, photo.url) works as it will once
installed. Your screen can’t load files from the LAN server by relative URL,
just as an installed one can’t. On each saved change the CLI tells the phone,
which installs the new build and restarts the miniapp, screen and background.
The phone also checks the URL each time the miniapp opens. It never asks your
computer in the background.
Production build
pack builds, with
NODE_ENV=production, and serves that ZIP at the same kind of URL as dev, with
the same plain-URL QR. miniapp.json names the ZIP pack would write and its
SHA-256.
Nothing is watched: a saved change neither rebuilds nor reloads. After a change,
stop it and run it again. The Mentra App takes the new build from the same URL
the next time it opens the miniapp, so you scan again only when the address
changed. The phone keeps the build it downloaded, so the miniapp opens with your
computer away.
The bundle is unsigned unless you pass --sign or --signing-key; see
Signing. --usb and --device work as they do for dev. It writes
nothing to build/.
mentra-miniapp release is the former name of dev --production. It still runs
for one more release of the CLI and says so. Its QR code is now a plain URL, not
a miniapp://release one. Change scripts that call it to dev --production.pack
build/, a folder ready to upload as is to your miniapp’s URL
(dev --production serves the same ZIP from your computer). It builds with NODE_ENV=production, verifies dist/,
validates the manifest, copies miniapp.json + icon.png into dist/, and zips
to build/<pkg>-<version>-<hash>.zip, where <hash> is the first 8 hex digits
of the ZIP’s SHA-256. The same files always pack to the same ZIP, whenever and
wherever you pack them, and with the same key to the same signed ZIP. It prints
the bundle’s SHA-256 and its publisher key, or unsigned.
build/ then holds what a miniapp URL serves:
Your
miniapp.json must not declare bundle or versions itself; pack fills
them in. Upload
the folder to any static host, such as GitHub Pages, Cloudflare Pages or R2, or
S3. For each release, upload the ZIP before miniapp.json, so your URL never
names a ZIP that isn’t there yet. Phones update when the ZIP’s SHA-256 changes,
with or without a new version.
See Publish your miniapp for hosting, the
domain rule and getting listed.
versions has one {version, url, sha256} entry per version, highest version
first, at most 50. Each pack adds the version it packed, or replaces that
version’s entry, and keeps the others:
- With
--url <your miniapp URL>, the ones theminiapp.jsonpublished there lists. Use it in CI: a clean checkout has nobuild/, and without--urlit would write a list with one version. A URL that can’t be reached, or whose list can’t be read, stops the pack. Only a404, nothing published yet, starts a new list. - Without
--url, the ones inbuild/miniapp.jsonfrom the last pack whose ZIPs are still inbuild/.
build/ self-ignores from git with its own .gitignore; leave that file out
if you deploy the folder by committing it to git.Signing
Bundles are unsigned by default.--sign signs with the package’s stored
publisher key (see keys); --signing-key <path> signs with a key
file without storing it, for CI. CI can also set MENTRA_MINIAPP_SIGNING_KEY_FILE
or MENTRA_MINIAPP_SIGNING_KEY_JSON together with --sign. A signed ZIP carries
META-INF/MENTRA.SIG: the package’s Ed25519 public key and a signature over its
package name, version, manifest and every file.
keys
0600 file under ~/.mentra/cli-v2/signing-keys/ when the
keychain refuses the write. If the keychain can’t be read, key commands stop
without creating or changing a key; on machines without a keychain, such as CI,
sign with --signing-key. show prints the key’s sha256: fingerprint. export
writes the private key to a new file; keep it secret and in a secure backup.
manifest
miniapp.json: edit permissions and hardware
requirements, show the current manifest, or finish. It saves after each confirmed
change, so Ctrl+C never loses a saved edit.
permission and hardware
Object-verb edits that share the wizard’s validation:
TYPE: MICROPHONE, CAMERA, CALENDAR, LOCATION,
BACKGROUND_LOCATION, READ_NOTIFICATIONS, POST_NOTIFICATIONS. Hardware
TYPE: CAMERA, DISPLAY, MICROPHONE, SPEAKER, IMU, BUTTON, LIGHT,
WIFI; LEVEL: REQUIRED, OPTIONAL. See the manifest
for what each means.
schema
miniapp.json JSON Schema to stdout: useful for CI
validation or IDE config. The same schema ships at
node_modules/@mentra/miniapp-cli/schema/miniapp.schema.json, which the $schema
line in a scaffolded miniapp.json references for editor autocomplete.
