File size: 8,680 Bytes
be462b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
---
title: "CLI reference (mentra-miniapp)"
description: "The author CLI for developing, packing, and releasing Mentra miniapps."
icon: "terminal"
---

import BetaNote from '/snippets/beta-note.mdx'

<BetaNote />

`@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"`).

```bash
mentra-miniapp <command>
```

Run with no arguments to print the usage table.

<Info>
The CLI is **Bun-only**: it ships as TypeScript and runs under Bun. Use `bun`
(or `bunx`), not `npx`/Node.
</Info>

| Command | What it does |
|---|---|
| [`dev`](#dev) | Dev server with hot reload; prints a QR to load the miniapp on a phone. |
| [`release`](#release) | Builds, packs, and serves a QR to install a release on phones over LAN. |
| [`pack`](#pack) | Writes `build/`, a folder ready to upload to your miniapp's URL. |
| [`keys`](#keys) | Creates, shows, imports and exports publisher signing keys. |
| [`manifest`](#manifest) | Interactive wizard for editing `miniapp.json`. |
| [`permission`](#permission-and-hardware) | Add / remove / list manifest permissions. |
| [`hardware`](#permission-and-hardware) | Add / remove / list manifest hardware requirements. |
| [`schema print`](#schema) | Prints the canonical `miniapp.json` JSON Schema. |

## `dev`

```bash
mentra-miniapp dev
```

Validates `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 `bundle.zip` and its
SHA-256. It also runs a **dev sidecar** WebSocket on the next port up for live
reload and console-log forwarding 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.

<Warning>
`dev` is live and temporary. Keep the CLI and computer running: the Mentra App
loads the runtime bundle from that LAN server. Dev miniapps are keyed by their
manifest package name, so you can scan and test several side by side; rescanning
the same package updates only that entry. The Mentra App caches each entry's name
and icon. Use `bun run release` for an installed miniapp that works without the
computer.
</Warning>

## `release`

```bash
mentra-miniapp release
mentra-miniapp release --no-cache            # force rebuild even if the cached zip is fresh
mentra-miniapp release --sign                # sign with the package's stored publisher key
mentra-miniapp release --signing-key key.json  # sign with a key file (not stored)
```

The all-in-one path for putting a build on real devices: validate → build → pack
→ serve behind a QR so you can install on as many phones as you want.

It reuses a cached `build/<pkg>-<version>.zip` when every source file is older
than the zip, otherwise rebuilds (auto-detecting your package manager from the
lockfile). It serves the bundle, manifest, and icon over HTTP on `0.0.0.0` and
prints a `miniapp://release?...` QR, then stays up so multiple devices can
install. Each install logs a line. Installed miniapps run offline and persist
across restarts; no laptop needed after install.

The bundle is unsigned unless you pass `--sign` or `--signing-key`; see
[Signing](#signing). A cached ZIP is reused only when it matches the signing you
asked for.

## `pack`

```bash
mentra-miniapp pack
mentra-miniapp pack --no-build                # zip the existing dist/ as-is
mentra-miniapp pack --sign                    # sign with the package's stored publisher key
mentra-miniapp pack --signing-key key.json    # sign with a key file (not stored)
```

Writes `build/`, a folder ready to upload as is to your miniapp's URL (`release`
calls `pack` internally). It builds with `NODE_ENV=production`, verifies `dist/`,
validates the manifest, copies `miniapp.json` + `icon.png` into `dist/`, and zips
to `build/<pkg>-<version>.zip`, replacing an older ZIP of the same version only
after the new one is complete. It prints the bundle's SHA-256 and its publisher
key, or `unsigned`.

`build/` then holds what a miniapp URL serves:

| File | What it is |
|---|---|
| `miniapp.json` | Your `miniapp.json` plus `bundle: {url: "<pkg>-<version>.zip", sha256}`, naming the ZIP and its SHA-256. |
| `<pkg>-<version>.zip` | The bundle. ZIPs of earlier versions stay beside it. |
| The icon, such as `icon.png` | The file `miniapp.json`'s `icon` names, taken from the ZIP. An icon URL on another host is left to that host. |

Your `miniapp.json` must not declare `bundle` itself; `pack` fills it in. Upload
the folder to any static host, such as GitHub Pages, Cloudflare Pages or R2, or
S3. For each release, bump `version`, and upload the ZIP before `miniapp.json`, so
your URL never names a ZIP that isn't there yet.
See [Publish your miniapp](/app-devs/getting-started/publish) for hosting, the
domain rule and getting listed.

<Note>
`pack` requires the `zip` binary on `PATH` (preinstalled on macOS and most Linux;
on Windows use WSL). `build/` self-ignores from git with its own `.gitignore`;
leave that file out if you deploy the folder by committing it to git.
</Note>

### Signing

Bundles are unsigned by default. `--sign` signs with the package's stored
publisher key (see [`keys`](#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.

<Warning>
Signing is permanent for a package. The first signed bundle a phone installs
records the publisher key, and from then on that phone accepts only bundles
signed with the same key. An unsigned bundle or a different key is refused until
the user uninstalls the miniapp. There is no key rotation, so back up the key
(`keys export`) before you ship a signed bundle. Signing needs a lowercase
reverse-DNS package name (letters, digits and underscores).
</Warning>

## `keys`

```bash
mentra-miniapp keys create com.example.myapp
mentra-miniapp keys show   com.example.myapp
mentra-miniapp keys export com.example.myapp ./publisher-key.json
mentra-miniapp keys import com.example.myapp ./publisher-key.json
```

Manages one publisher signing key per package. Keys are stored in the OS
keychain, or in a mode-`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`

```bash
mentra-miniapp manifest
```

An interactive wizard for `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:

```bash
mentra-miniapp permission list
mentra-miniapp permission add [TYPE]      # interactive if TYPE omitted
mentra-miniapp permission remove [TYPE]

mentra-miniapp hardware list
mentra-miniapp hardware add [TYPE] [LEVEL]
mentra-miniapp hardware remove [TYPE]
```

Permission `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](/app-devs/core-concepts/miniapp-manifest)
for what each means.

## `schema`

```bash
mentra-miniapp schema print
```

Prints the canonical `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.