SDK docs menuEvmuxAppsApi

EvmuxAppsApi

The class every app starts from. Create an instance in your widget page and in your settings page, then call its methods.

Create an instance

import EvmuxAppsApi from 'evmux-app-framework/src/EvmuxAppsApi/EvmuxAppsApi'

const evmuxApi = new EvmuxAppsApi()

Create one instance in each component of your app: one in the widget page and one in the settings page.

Properties

Property Description
userAppInstanceId Unique identifier of the app instance.
componentId The id of the component on the evmux scene.
import EvmuxAppsApi from 'evmux-app-framework/src/EvmuxAppsApi/EvmuxAppsApi'

const evmuxApi = new EvmuxAppsApi()

const userAppInstanceId = evmuxApi._userAppInstanceId
const componentId = evmuxApi._componentId

In the published package, version 0.1.17, the instance stores these two values as _userAppInstanceId and _componentId.

If you copy and paste the same widget several times in a scene, all the copies have the same userAppInstanceId and different componentId values.

What evmux passes to your pages

evmux loads each of your pages with a few query parameters in its URL:

Parameter Description
appInstanceId The id of the app instance. The constructor reads it for you.
compId The id of the component. The constructor reads it for you.
styleVersion On the settings page: light or dark, the theme of the studio. Use it to match your settings page to the sidebar around it.
const styleVersion = new URLSearchParams(window.location.search).get('styleVersion')
document.body.classList.add(styleVersion || 'light')

Exports

The module exports the class and two lists of names:

import EvmuxAppsApi, { availableEvents, layerTypes } from 'evmux-app-framework/src/EvmuxAppsApi/EvmuxAppsApi'
Export Description
EvmuxAppsApi The class. This is the default export.
availableEvents The names of the events you can register for.
layerTypes The layer types for scene.createNewLayer.

Namespaces

Methods are grouped by what they work with:

Namespace What it covers
evmuxApi Settings, events and the lifecycle.
evmuxApi.apps Fast action buttons, messages between apps and the settings sidebar.
evmuxApi.social Comments and channel statistics.
evmuxApi.scene Scenes and layers.
evmuxApi.modules Studio pickers, editors and toasts.
evmuxApi.media The studio’s media assets.
evmuxApi.studio Studio parameters, participants and sound.
evmuxApi.misc The account’s plan.

evmuxApi.comments is deprecated. Use evmuxApi.social instead.

Return values

Methods that ask the studio for something are asynchronous. They return a promise that resolves to an object with the result in response:

const { response: settings } = await evmuxApi.getSettings()

Stuck, or found a mistake in these docs? Tell us.