Hosting the game, and reading logs off the device
The build needs HTTPS hosting to run on the glasses. Offer it, but don't auto-run it.
Deploying this game to Vercel
This is a Vite build-tool app with its own project shape. Deploy it as follows:
- Do NOT add a
server.jsor apackage.jsonstartscript. Vercel is serverless — astartscript makes it run the app as a Node function whose working directory has noindex.html, so every route 404s (body<h1>404 Not Found</h1>, nox-vercel-errorheader). Let Vercel build and serve static output instead. - Deploy from the project root, not from
dist/. Runvercelin the game directory. Accept the auto-detected Vite framework preset (build commandnpm run build, output directorydist); Vercel runs the build itself. - The scaffold ships a root-level
vercel.json(SPA fallback + cache policy). Leave it at the project root — never move it intodist/, which Vite empties on every build. - Caching is already correct; don't "fix" it with
no-store./_vite/*isimmutablebecause Vite content-hashes it,/api/*isno-store, and everything else (index.htmlplus the verbatimpublic/assets) isno-cache— stored but revalidated every load, so a republish lands immediately. A blanketno-storere-downloads the whole payload on every launch over the glasses' constrained link, and buys nothing the hashes don't already give. The broad/(.*)rule is listed first and the two narrow ones after it, because Vercel applies every matchingheadersentry and the later one wins for a repeated key. - Never use a negative lookahead in a route
source. Vercel rejects the whole config —Error: Rewrite at index 0 has invalid 'source' pattern, and the deploy fails before it builds. Route patterns are path-to-regexp, not arbitrary regex::param,:param*and(.*)are available;(?!...)is not. Any exclusion has to come from rule ordering or from Vercel's routing order, never from a lookahead. - Don't re-point the immutable tier at
/assets/, and don't dropbuild.assetsDirfromvite.config.ts. They are one mechanism:public/is copied into the build root, so with Vite's defaultassetsDirthe hashed output and the verbatimpublic/assets/...files share a prefix and no rule can tell them apart._vite/is written by the bundler alone, which is what lets the immutable rule stand with no per-subdirectory carve-out. - Do not run
meta-wearables-webapp'sai-glasses-webapp-publishscript on a game. It first runs the web app test gate, which checks for a UI Toolkit React shell a game does not have. Follow the same production practice by hand: check authentication withvercel whoami(runvercel loginif needed), deploy withvercel --prodfrom the project root, and confirm the returned HTTPS URL loads without signing in. If production is behind Deployment Protection, report the exact Vercel setting to the user rather than disabling it automatically. - Register the game on the glasses with a QR code. Build the deep link
fb-viewapp://web_app_deep_link?appName=<url-encoded name>&appUrl=<url-encoded production URL>and render it with theqr_generator.pybundled inai-glasses-webapp-publish:python3 <ai-glasses-webapp-publish-skill>/scripts/qr_generator.py --png qr.png '<deep link>'. Scan it with the phone to add the game in the Meta AI app. - Serverless functions under
api/are the one sanctioned server-side addition, and the SPA catch-all does not shadow them. Vercel resolves the filesystem — static files, then Serverless Functions — before it consultsrewrites, so/api/<name>reaches the function and only unmatched paths fall through to/index.html. The catch-all is therefore a plain/(.*); it needs no carve-out. That is how the opt-in remote-logging backend works — see /add-webapp-game-logging. It is still never aserver.jsor astartscript.
Reading logs from the glasses
Once the game is on device there is no console, so mention this when the user hits a
device-only bug: ?log=debug&logview draws the log on the 600x600 display with no backend at
all, and the /add-webapp-game-logging skill adds a log portal they can read on their laptop.
See ${CLAUDE_PLUGIN_ROOT}/docs/logging.md.
For faster iteration without a device, /iterate-webapp-game drives the game in a desktop Chrome over CDP — screenshot it, send D-pad/pinch/drag input, read state, capture console errors. It's the same driver the Step 7 verification pass uses.