Worker and Console
One Worker, D1 database, and R2 bucket for all host apps and mini-app features.
The Console ships one TanStack console and one Elysia Cloudflare Worker. It serves many host apps and mini apps:
appId + feature + platform + runtimeVersion → selected immutable bundleFirst-time Cloudflare setup
Section titled “First-time Cloudflare setup”Run this from the Expo host app repository, not from the Expo Lynx source
repository. The published CLI carries the Console UI, Worker, and D1 migrations
with it; it does not add an apps/console directory to your app.
One operator provisions one Worker, D1 database, and R2 bucket for the host organization. That Worker can serve many host apps and mini apps. In the Console, create the identity hierarchy before either team releases:
Apps → BS One → Merchant Home → platform/runtime → BundlesApp and mini-app IDs are immutable. Upload typos are rejected instead of silently becoming apps.
1. Configure the host and create its trust key
Section titled “1. Configure the host and create its trust key”Install expo-lynx-view and expo-lynx-bundle-cli in the host app. Configure
the Expo plugin with a public-key path, then create the matching pair once:
# Use your package manager: yarn lynx …, pnpm lynx …, or npx lynx …lynx keys generateThis creates the public key at the host plugin’s publicKeyPath and the
private key at .local-lynx-keys/updates.private.pem. The private key stays on
the operator machine until setup sends it directly to the Worker secret store.
It is never written to .env.lynx, R2, Git, a mini-app repository, or the
mobile app. Setup stops if the two keys do not match.
2. Create the upload credential — or skip it
Section titled “2. Create the upload credential — or skip it”lynx release can upload archives two ways. Setup asks which one
interactively (see step 3), so pick one now only if you’d rather have the
credential ready before it asks:
-
Wrangler CLI (recommended, and preselected in the setup prompt) — the same mechanism hot-updater uses. In Cloudflare Dashboard, under My Profile → API Tokens, create a token with Workers R2 Storage: Edit permission (account-scoped).
lynx releaseshells out to the bundled Wrangler CLI (wrangler r2 object put --remote) using that token, so no R2 S3 key pair is needed — but every machine runninglynx release uploadneeds this token. -
Direct to R2. In Cloudflare Dashboard, open R2 → Manage R2 API Tokens, or use the URL printed by setup. Create an R2 S3 API token with:
Setting Value Permission Object Read & Write Bucket The value you choose for LYNX_DELIVERY_R2_BUCKETUse CLI upload from developer machines Keep its access-key ID and secret access key private. This is an S3 credential, not a general Cloudflare API token. Setup prompts for both halves of it when this mode is chosen.
Either way, the Worker itself never receives an upload credential — it only ever reads and serves already-uploaded bundles.
3. Run setup
Section titled “3. Run setup”lynx console setupThe first run creates an ignored .env.lynx beside the host package.json,
then walks you through everything it needs with colored interactive prompts —
a suggested Worker/D1/bucket name (read from the host app’s Expo slug, or
its directory name if that isn’t available; always editable), the upload mode
from step 2, an R2 credential if you picked direct-to-R2, and a Console
username/password. Whatever you answer is written
back into .env.lynx as you go, so re-running setup later only asks about
whatever is still unanswered — nothing here needs hand-editing:
CLOUDFLARE_ACCOUNT_ID="…"
LYNX_DELIVERY_WORKER_NAME="bs-one-lynx-delivery"LYNX_DELIVERY_D1_NAME="bs-one-lynx-delivery"LYNX_DELIVERY_R2_BUCKET="bs-one-lynx-artifacts"
LYNX_CONSOLE_USERNAME="operator"LYNX_CONSOLE_PASSWORD="…"
LYNX_DELIVERY_UPLOAD_MODE="wrangler"
# Present when LYNX_DELIVERY_UPLOAD_MODE is "wrangler".CLOUDFLARE_API_TOKEN="…"
# Present only when you chose direct-to-R2 above instead.R2_ACCESS_KEY_ID="…"R2_SECRET_ACCESS_KEY="…"
# Generated by setup — do not edit.LYNX_DELIVERY_D1_DATABASE_ID="…"LYNX_DELIVERY_SERVER="…"LYNX_DELIVERY_API_KEY="…"If Wrangler is not signed in, setup opens a browser for Cloudflare OAuth, then lets you pick an account from an interactive list. Setup creates or reuses D1 and R2 by name, deploys the bundled Worker and Console, sets Worker secrets, applies migrations, and writes the D1 ID, Worker URL, and CLI API key back to this same file. A retry after an interrupted D1 creation finds the existing database by name instead of creating another one.
Do not commit .env.lynx. It is the private handoff file for future releases.
4. Point the native app at the deployed Worker
Section titled “4. Point the native app at the deployed Worker”Use the public deployment URL in the Expo plugin, then make a new native app binary because the endpoint is a native configuration value:
{ "deliveryEndpoints": { "delivery": "https://your-worker.workers.dev/v1/default/delivery" }}After one-time setup, each team uses its own workflow:
# Expo host: prepare/register, then build the native apppnpm lynx host prepare --register
# independent mini app: build and uploadpnpm lynx releaseOpen the deployed Worker URL, sign in with the generated console credentials, and select then enable the uploaded bundle for its app, feature, and runtime. The CLI upload itself does not enable a release.
| D1 table | Purpose |
|---|---|
apps / mini_apps |
Allow-listed host and mini-app identities. |
bundles |
Immutable verified, platform-neutral ZIP metadata. |
deployments |
Selected bundle, enabled state, force flag, and revision for one runtime scope. |
users |
Console username/password and hashed CLI API key. |
Public mobile routes require no user credential:
GET /v1/:appId/:featureGET /v1/:appId/:feature/:releaseId/release.zipThe deployment response is signed by DELIVERY_SIGNING_PRIVATE_KEY; its public
counterpart is embedded in the app. The CLI uploads with the Wrangler CLI (or
directly to R2 with an S3 credential, if you chose that mode), then asks the
Worker to verify exact ZIP size and SHA-256 before D1 registration. The
Worker never receives an upload credential of either kind.
Clients without lynx-runtime-version are supported only while one deployment
is unambiguous. This temporary bridge fails closed once multiple runtimes exist.
Later Worker changes
Section titled “Later Worker changes”Deploy Console/Worker code changes without recreating D1, R2, users, API keys, or signing secrets:
pnpm lynx console deployUse lynx console setup --dry-run to check the host key and .env.lynx
configuration without changing Cloudflare. Deploy later Console/Worker changes
and pending migrations with lynx console deploy; it preserves D1 data and
Worker secrets.
