The `window.miro` Object

Interface: Root

This is the same window.miro Object and will be your main entry point to the SDK methods.

Hierarchy

  • Root

Index

Properties

Methods

Properties

account

account: IAccountCommands

Contains commands (functions) to access to the Account (Team)
where the Web-plugin was installed

Note: this is not the current user


board

board: IBoardCommands

The current board the user is watching.
Contains commands (functions) to access to the board information.

Available only when the Web-plugin runs in a board


currentUser

currentUser: ICurrentUserCommands

The current user.
Contains commands (functions) to access to the current user information.


enums

enums: IEnums

Contains constants like events and style that can be used with other SDK methods

Methods

__getRuntimeState

__getRuntimeState<T>(): Promise<T>

Gets a previously set state from any container extension point (iframe) from your plugin.

You can set this state with __setRuntimeState

Note: This state is not persisted between boards or page reloads.

experimental

Type parameters:

NameDefault
Tany

Returns: Promise<T>

A promise resolving into the stored state.


__setRuntimeState

__setRuntimeState<T>(data: T): Promise<T>

Saves a state (any) that can will be accessible across all
the container extension points (iframes) from your plugin.

You can retrieve this state with __getRuntimeState

Note: This state is not persisted between boards or page reloads.

experimental

Type parameters:

NameDefault
Tany

Parameters:

NameType
dataT

Returns: Promise<T>

A promise resolving into the previously saved state. Defaults to an empty object.


addListener

addListener(event: EventType, listener: (e: Event) => void): void

Subscribe to an event in the board.
Go to EventType to see a list of possible events.

Note: Available only when the Web plugin runs on a board page.

Parameters:

NameTypeDescription
eventEventTypeA string with an event as defined in EventType
listener(e: Event) => voidA function to handle the Event

Returns: void

void

Example

function handleSelectionUpdated(event) {
  // Your event handler
}
miro.addListener('SELECTION_UPDATED', handleSelectionUpdated)

Related: See removeListener to remove a listener


broadcastData

broadcastData(data: any): void

Broadcast some data to iframes from your plugin in Container Entry Points

You can subscribe to the DATA_BROADCASTED event to receive this data.
See addListener and EventType

Parameters:

NameTypeDescription
dataanyThe payload you wish to broadcast

Returns: void

void

Example

miro.broadcastData({
 value: 1
})

getClientId

getClientId(): string

Returns the clientId from the web plugin.
This is the same clientId from the App settings dashboard.

Returns: string

The web plugin clientId.


getIdToken

getIdToken(): Promise<string>

The getIdToken() method returns a JSON Web Token (JWT), an encoded form of JSON data, signed by the application secret. You can use JWTs to authenticate requests from your Miro web-plugin to your backend services. You can use an existing JWT library to decode the token and establish the communication between your Miro web-plugin and your backend services.
If you are migrating from getToken() to getIdToken(), see the migration guide.

Returns: Promise<string>

a JWT token

Example

miro.getIdToken().then((jwt) =>{
  console.log('jwt token', jwt);
})

initialize

initialize(config?: IPluginConfig): Promise<void>

Accepts a configuration to initialize the plugin.

Available only on a board. Not available in iframes from Container Entry points

Example

miro.onReady(() => {
  miro.initialize({
    //plugin configuration
  });
}

Parameters:

NameType
config?IPluginConfig

Returns: Promise<void>


initializeSettings

initializeSettings(config?: IPluginSettingsConfig): Promise<void>

Accepts a configuration to initialize the plugin in the settings page.
Available only in the setting page.

Example

miro.onReady(() => {
  miro.initializeSettings({
    //plugin configuration
  });
}

Parameters:

NameType
config?IPluginSettingsConfig

Returns: Promise<void>


isAuthorized

isAuthorized(): Promise<boolean>

Check if the current user has authorized the Web-plugin to make API requests
on their behalf

Returns: Promise<boolean>

True if the web plugin is authorized, false when not.

Example

miro.isAuthorized().then( (isAuthorized) => {
  if (isAuthorized) {
    console.log('Web plugin authorized');
  } else {
    console.log('Unauthorized');
  }
})

onReady

onReady(callback: () => void): void

Callback executed when everything is loaded and ready to use SDK methods.

Parameters:

NameTypeDescription
callback() => voidFunction to be executed

Returns: void

Example

miro.onReady(() => {
 console.log("Ready to call SDK methods")
}

removeListener

removeListener(event: EventType, listener: (e: Event) => void): void

Unsubscribe from an event in the board.
Go to EventType to see a list of possible events.

Note: Available only when the Web plugin runs on a board page.

Parameters:

NameTypeDescription
eventEventTypeA string with an event as defined in EventType
listener(e: Event) => voidThe function originally passed in addListener to handle the event

Returns: void

void

Example

miro.removeListener('SELECTION_UPDATED', handleSelectionUpdated)

Related: See addListener to add a listener


requestAuthorization

requestAuthorization(options?: AuthorizationOptions): Promise<void>

Opens a modal to follow the authorization process for your App.

Parameters:

NameTypeDescription
options?AuthorizationOptionsOptions for the authorization process. See AuthorizationOptions

Returns: Promise<void>

A promise fulfilled if the app has been authorized.


showErrorNotification

showErrorNotification(text: string): Promise<void>

Similar to showNotification with additional style to indicate error

Parameters:

NameTypeDescription
textstringThe text to show in the notification

Returns: Promise<void>

A Promise, fulfilled when the notification is displayed to the user
Example

miro.showErrorNotification('This is an error notification')

showNotification

showNotification(text: string): Promise<void>

Shows a notification to the user

Parameters:

NameTypeDescription
textstringThe text to show in the notification

Returns: Promise<void>

A Promise, fulfilled when the notification is displayed to the user

Example

miro.showNotification('Hello world')

Did this page help you?