Skip to content

Working with Options

The SDK provides two classes for managing options:

Singleton instances of these classes work identically and support:

  • get() — read a single option / all options
  • set() — save a single option / multiple options

Application Options

Global options shared across all users.

ts
import { App } from '@aspro-cloud/miniapp-jssdk'

const frame = await App.initializeFrame()

// get all option values
const values = await frame.options.get()

// get a single option value
const enabled = await frame.options.get('enabled')
const token = await frame.options.get('token')

// save an option value
await frame.options.set('enabled', true)
await frame.options.set('token', 'service-token-value')

// save multiple option values
await frame.options.set({
  enabled: true,
  token: 'service-token-value'
})

Current User Options

Do not override application option values.

Work the same way.

ts
import { App } from '@aspro-cloud/miniapp-jssdk'

const frame = await App.initializeFrame()

const theme = await frame.userOptions.get('theme')
await frame.userOptions.set('theme', 'dark')

Published under the MIT license.