Skip to main content

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., "user@example.com-com.example.app").

Creating an App Server

Handling Sessions

When a user starts your app, your onSession 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 AppSession
4

Real-time connection

AppSession connects via WebSocket for real-time data
5

Session ends

User stops app or connection is lost

TypeScript Support

The SDK is written in TypeScript and provides full type definitions:

Environment Variables

Recommended environment variables:

Project Structure

A typical MentraOS app project:

TypeScript Configuration

Use strict TypeScript for better type safety:

Next Steps

AppSession Reference

Learn about the AppSession class and its methods

Event Handlers

Handle transcriptions, button presses, and more

Display Layouts

Show content on the glasses display

Hardware Modules

Access camera, audio, location, and sensors