Why Use Railway?
Benefits of Railway hosting:- Always Online: Your app runs 24/7 without needing your computer
- Easy to Deploy: Push code changes to GitHub and Railway deploys automatically
- Better Performance: Dedicated cloud infrastructure with better uptime than local development
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:- 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). - 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” and 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
- 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
- Download the MentraOS app from MentraGlass.com/os
- Set up your smart glasses following the setup guide
11. Test Your App
- Open Mentra on your phone
- Find your app in the app list and tap to start it
- Spoken text will appear on your smart glasses display
12. Test the Webview
- In the MentraOS phone app, open the currently running app.
- This opens the webview interface.
- You will see your username displayed.
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
14. Success!
Congratulations! Your MentraOS app is now running in the cloud.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

