When your miniapp connects, the SDK hands your registerMiniapp handler a session. It lives in the background layer, and every capability (display, microphone, sensors, storage) is a module on it.
src/background/index.ts
You don’t create or connect the session yourself. The host does it and runs your handler. Everything you do with the glasses goes through session. (For advanced or testing use you can new MiniappSession() and call connect() directly, but a normal miniapp never needs to.)

Modules

Type session. in your editor and autocomplete shows everything. Each module is covered in its own page.

Output

Input & audio

Sensors & device

Phone & system

Storage & data

Glasses with cameras

Interop & UI

Lifecycle

Subscribe to lifecycle events with session.on(event, handler). Each returns an unsubscribe function.
session.capabilities, session.userId, and the user’s permissions are populated from the connect handshake, which lands after your handler first runs. Subscribe to events immediately, but read capabilities inside session.on("ready", …) (or session.onCapabilitiesChange). It’s null before then.
If the background context crashes, the host respawns it and re-runs your handler with backoff. See crash recovery.

Subscriptions

Registering a handler subscribes; calling the returned function unsubscribes. You never manage subscriptions by hand.
Every .on(), .onUpdate(), .onChunk(), .onButtonPress(), and the rest return this cleanup function. Subscriptions are ref-counted internally: the SDK only talks to the phone on the first subscribe and last unsubscribe of a given stream.
A successful request means accepted, not done. For streaming capabilities, watch the stream for the real result rather than assuming the call already succeeded.

Properties

Next steps

Display

Show text and graphics on the glasses.

Transcription

Turn speech into text in real time.

Storage

Persist data across sessions.

Actions

Let Mentra AI call your miniapp.