Skip to main content

SettingsManager API Reference

The SettingsManager class provides a type-safe interface for accessing and monitoring App settings. It automatically synchronizes with MentraOS Cloud and provides real-time change notifications.

Import

Class: SettingsManager

Constructor

The SettingsManager is automatically instantiated by the AppSession. You should not create instances directly.

Methods

get

Get a setting value.
Parameters:
  • key: Setting key to retrieve
  • defaultValue: Default value if setting doesn’t exist or is undefined
Returns: Setting value or default value Example:

has

Check if a setting exists.
Parameters:
  • key: Setting key to check
Returns: True if the setting exists Example:

getAll

Get all settings.
Returns: Copy of all settings Example:

getSetting

Find a setting by key and get the full setting object.
Parameters:
  • key: Setting key to find
Returns: Setting object or undefined Example:

onChange

Listen for changes to any setting.
Parameters:
  • handler: Function called when any setting changes
Returns: Cleanup function to remove the listener Example:

onValueChange

Listen for changes to a specific setting.
Parameters:
  • key: Setting key to monitor
  • handler: Function called when the setting changes
Returns: Cleanup function to remove the listener Example:

fetch

Manually fetch settings from the cloud. This is generally not needed since settings are automatically kept in sync.
Returns: Promise that resolves to the updated settings Throws: Error if the API client is not configured or the request fails Example:

MentraOS Settings

The SettingsManager also provides access to system-wide MentraOS settings.

onMentraosSettingChange

Listen for changes to specific MentraOS settings.
Parameters:
  • key: MentraOS setting key (e.g., ‘metricSystemEnabled’)
  • handler: Function called when the value changes
Returns: Cleanup function to remove the listener Example:

getMentraosSetting

Get the current value of an MentraOS setting.
Parameters:
  • key: MentraOS setting key
  • defaultValue: Default value if setting doesn’t exist
Returns: Setting value or default value Example:

Best Practices

1. Provide Defaults

2. Type Your Settings

3. Clean Up Listeners