Installation
Install the MentraOS SDK using Bun:Basic Concepts
The MentraOS SDK provides two main classes:AppServer
Base class you extend to create your app server. Handles webhook registration and session lifecycle.
AppSession
Manages the connection to a specific user session. Created automatically when users start your app.
Important: Apps should extend
AppServer and override the onSession method. The sessionId parameter follows the format "userId-packageName" (e.g., "[email protected]").Creating an App Server
Handling Sessions
When a user starts your app, youronSession method is called:
Session Lifecycle
1
User starts app
User says “Start [app name]” or taps in the mobile app
2
Cloud sends webhook
MentraOS Cloud sends a webhook to your server
3
Session created
Your
onSession handler is called with an AppSession4
Real-time connection
AppSession connects via WebSocket for real-time data
5
Session ends
User stops app or connection is lost