Deploy to Railway
This guide will walk you through deploying your MentraOS app to Railway, a cloud hosting platform that makes deployment simple and reliable. Instead of running your app locally with ngrok, you’ll have a production-ready hosted solution.Why Use Railway?
Benefits of Railway hosting:- Always Online: Your app runs 24/7 without needing your computer
- Automatic Deployments: Push code changes to GitHub and Railway deploys automatically
- Better Performance: Dedicated cloud infrastructure with better uptime than local development
- Professional URLs: Clean, professional domain names instead of random ngrok URLs
- Scalability: Easily handle more users and higher traffic
- Environment Management: Separate development and production environments
- No Local Dependencies: No need to keep ngrok running or manage local tunnels
Prerequisites
Make sure you have:- GitHub Account: For code repository hosting
- Railway Account: Free account at railway.com
- MentraOS Account: For the developer console at console.mentra.glass
- Basic Git Knowledge: For pushing code changes
Part 1: Set Up Your Repository
1. Create Your App Repository
Create a new repository from the MentraOS example app template: Option A: Using GitHub Web Interface- Go to the MentraOS Cloud Example App repository
- Click the green “Use this template” dropdown in the upper right
- Select “Create a new repository”
- Choose a repository name (e.g.,
my-mentraos-app) - Set visibility to Public or Private
- Click “Create repository”
2. Clone Your Repository
Clone your new repository locally:Part 2: Deploy to Railway
3. Create Railway Project
- Go to railway.com
- Sign in with your GitHub account
- Click “Deploy a new project”
- Select “Deploy from GitHub repo”
4. Connect Your Repository
- Select your new repository from the list
- If you don’t see it, click “Configure GitHub App” to give Railway access to your repositories
- Once selected, Railway will start setting up your project
5. Get Your Public URL
- Go to the “Settings” tab in your Railway project
- Under “Networking” > “Public Networking”, click “Generate Domain”
- You’ll get a URL like:
yourapp-production-fa42.up.railway.app - Copy this URL - you’ll need it for the next step
Part 3: Register Your App with MentraOS
6. Register in Developer Console
- Navigate to console.mentra.glass
- Sign in with the same account you use for MentraOS
- Click “Create App”
- Fill in the details:
- Package Name: Use the same package name from your environment variables
- Server URL: Enter your Railway URL (e.g.,
https://yourapp-production-fa42.up.railway.app) - Webview URL: Enter
https://yourapp-production-fa42.up.railway.app/webview - Permissions: Add the microphone permission. See the Permissions guide for details.
- Click “Create App”
- Take note of the api key, as you will need it later and it won’t be shown again
7. Import App Configuration
You can now add permissions, settings, and tools to your app via the MentraOS Developer Console. Instead of doing it manually, let’s upload this example’sapp_config.json file by clicking the “Import app_config.json” button under Configuration Management:
- In the developer console, scroll to the “Configuration Management” section
- Click “Import app_config.json”
- Upload the
app_config.jsonfile from your cloned repository - This will automatically configure:
- Permissions: Microphone access for speech recognition
- Settings: Adds a toggle for show_live_transcription
- Tools: Adds an example tool called my_tool_name
- Click “Save Changes” to apply the configuration
8. Configure Environment Variables
- In your Railway project dashboard, click on the “Variables” tab
- Under “Suggested Variables”, you’ll see template variables from the
.env.examplefile - Replace the placeholder values:
- PACKAGE_NAME: Change
org.yourname.appnameto your unique package name (e.g.,com.yourname.mymentraosapp) - MENTRAOS_API_KEY: Replace
your_api_key_herewith your actual API key from the MentraOS Console - PORT: Leave as
3000
- PACKAGE_NAME: Change
- Click “Add All” to save the variables
9. Deploy Your App
- On the left side of the Railway dashboard, you’ll see “Apply 3 changes”
- Click the purple “Deploy” button
- Railway will build and deploy your app (this takes 1-2 minutes)
Part 4: Test Your Deployed App
10. Install MentraOS
If you haven’t already:- Download the MentraOS app from mentra.glass/os
- Set up your smart glasses following the setup guide
11. Test Your App
- Open the MentraOS app on your phone
- Find your app in the app list and tap to start it
- Expected behavior:
- Spoken text should appear on your smart glasses display
12. Test the Webview
- In the MentraOS phone app, tap the gear icon next to your app name
- This opens the webview interface
- Expected behavior:
- You should see your username displayed
13. Test Settings
- In the MentraOS phone app, with the webview interface open, tap the gear icon in the upper right
- This opens the settings menu
- Expected behavior:
- You should see the “Show live transcription” setting
- Tapping the setting should toggle the on-screen transcriptions on and off
Part 5: Continuous Deployment
13. Make Changes and Deploy
Railway automatically deploys when you push changes to GitHub:- Make a change to your app locally (e.g., modify the welcome message in
src/index.ts) - Commit and push your changes:
- Railway will automatically detect the changes and deploy within 1-2 minutes
- To see the changes, restart your app in MentraOS:
- Tap your app in the list to stop it
- Tap again to restart it
Next Steps
Congratulations! Your MentraOS app is now running in the cloud. Here’s what you can do next:Explore Advanced Features
- Events: Handle user interactions and sensor data
- Settings: Add configurable options for users
- AI Tools: Integrate with Mira AI for natural language interactions
- Webview Authentication: Build rich web interfaces
Get Help
- Discord Community: Get help from other developers
- Railway Documentation: Learn more about Railway features
- MentraOS Documentation: Explore the full SDK documentation
- GitHub Examples: See more example projects
Troubleshooting
App not responding after deployment?- Check the Railway logs for errors
- Verify your environment variables are set correctly
- Ensure your API key is valid in the developer console
- Confirm your GitHub push was successful
- Check Railway deployment status
- Restart your app in MentraOS after deployment completes
- Verify the webview URL is set correctly in the developer console
- Check that your Railway deployment is accessible at the public URL
- Load the webview URL directly in your browser to ensure it’s accessible

