How MentraOS Apps Work
Understanding the architecture helps explain why we need tunneling for local development:- User interacts with glasses (voice, buttons, camera)
- MentraOS Relay Server processes the interaction
- Relay Server sends events to your app server via webhook
- Your app responds (display text, play audio, etc.)
- Response flows back through the Relay Server to the user’s phone, and then to the user’s glasses
The Local Development Problem
When you run your app locally, it’s only accessible on your machine:localhostis not a public address- MentraOS Relay Server runs on the internet
- Relay Server can’t reach your local machine directly
- Firewalls and routers block incoming connections
The Solution: Tunneling with ngrok
ngrok creates a secure tunnel from a public URL to your local server:https://abc123.ngrok.io, and they’ll be forwarded to your local app.
Quick Start
1. Install ngrok
macOS:2. Start Your App
3. Start ngrok Tunnel
In a new terminal:https://abc123.ngrok.io
4. Update Developer Console
- Go to console.mentra.glass/apps
- Select your app
- Set App Server URL to:
https://abc123.ngrok.io - Save changes
5. Test on Glasses
- Open your app on MentraOS glasses
- Interact with it (speak, press buttons, etc.)
- Watch your terminal - you should see events coming in
- Check ngrok’s web interface at
http://localhost:4040to see requests
Development Workflow
Typical workflow:- Free ngrok URLs change each time
- You must update the Developer Console with the new URL
- Paid ngrok plans provide persistent URLs
ngrok Web Interface
ngrok provides a web interface at http://localhost:4040 showing:- Request Inspector - See all incoming requests
- Request/Response Details - Headers, body, timing
- Replay Requests - Resend requests for debugging
Common Issues
Issue: “Connection Refused”
Problem: ngrok can’t connect to your local server Solution:Issue: “No Events Coming Through”
Problem: You don’t see any requests in your terminal Solution:- Check packageName - Must match exactly in both your code and Developer Console
- Check API key - Must be correct and match your app in Developer Console
- Check ngrok URL - Must be correct in Developer Console (no trailing slash)
- Check ngrok is still running (free URLs expire after 2 hours)
- Check your app is still running
- Look at ngrok web interface (localhost:4040) to see if requests are arriving
- Check your app logs for errors
Issue: “ngrok URL Changed”
Problem: You restarted ngrok and URL changed Solution:- Free plan: Update Developer Console with new URL each time
- Paid plan: Use reserved domains for persistent URLs
- Alternative: Deploy to Railway/Ubuntu for persistent URLs
ngrok Free vs Paid
Free Plan
- ✅ Unlimited tunnels
- ✅ Web interface
- ❌ URL changes each restart
- ❌ 40 connections/minute limit
- ❌ Random subdomain
Paid Plans (starting $8/month)
- ✅ Everything in Free
- ✅ Reserved domains - URL never changes
- ✅ Custom domains
- ✅ Higher limits
- ✅ More regions
Alternatives to ngrok
CloudFlare Tunnel
- Free persistent URLs
- More complex setup
- Good for long-term development
localtunnel
- Simpler than ngrok
- Less reliable
- Good for quick tests
VS Code Port Forwarding
If using GitHub Codespaces or VS Code Remote:- Built-in port forwarding
- No extra tools needed
- Limited to VS Code environment

