Skip to main content

Building on MentraOS: SDK and Apps

Third-party apps are what make MentraOS magical. They extend the glasses’ capabilities from simple translation to AI assistants, note-taking, navigation, and more. Let’s see how apps connect and interact with the system.

The MentraOS SDK

The SDK (@mentraos/sdk) is a TypeScript/JavaScript library that makes it easy for developers to build apps. Think of it as the translator between apps and our cloud.

Installation

How Apps Connect

Let’s follow a translator app as it connects to help Alex:

Step 1: App Receives Start Signal

When Alex says “Start translator”, the cloud sends a webhook to the app:

Step 2: App Creates Session

Step 3: Authentication Dance

The app sends its credentials:

Step 4: Subscribe to Data Streams

Apps must tell the cloud what data they want:

The AppSession Class

The SDK’s main class that handles everything:

Working with Display Layouts

The SDK provides layout methods through session.layouts (defined in packages/sdk/src/app/session/modules/layouts.ts):

Receiving Events

Apps receive events through the session.events object (defined in packages/sdk/src/app/session/index.ts):

Managing Settings

Apps can have user-configurable settings through session.settings (defined in packages/sdk/src/app/session/modules/settings.ts):

Hardware Modules

Camera Module

Camera functionality through session.camera (defined in packages/sdk/src/app/session/modules/camera.ts):

Audio Module

Audio functionality through session.audio (defined in packages/sdk/src/app/session/modules/audio.ts):

Location Module

Location functionality through session.location (defined in packages/sdk/src/app/session/modules/location.ts):

Dashboard Module

Dashboard control through session.dashboard (defined in packages/sdk/src/app/session/modules/dashboard.ts):

App Lifecycle

Starting Up

  1. Receive webhook with sessionId
  2. Create AppSession instance
  3. Connect to cloud
  4. Subscribe to needed events
  5. Show initial UI

Running

  1. Receive events from subscriptions
  2. Process data
  3. Update display as needed
  4. Respond to user actions

Shutting Down

  1. Receive ‘appStopped’ event
  2. Clean up resources
  3. Close connections
  4. App can be restarted later

Best Practices

1. Handle Disconnections Gracefully

2. Respect Rate Limits

3. Clean Up Resources

4. Use TypeScript

The SDK has full TypeScript support:

Common App Patterns

Voice Command App

Real-time Information App

Interactive App

Multi-User Communication App

The SDK supports app-to-app communication (defined in packages/sdk/src/app/session/app-to-app.ts):

What’s Next?

Now you know how apps work! You’re ready to build your own MentraOS applications using the SDK.