Skip to main content
Question

Figma use mqtt


I am new to writing Figma plugins,I need to transmit values from Figma using MQTT, but it seems that Figma does not support MQTT. Later, I intend to use postMessage to transmit values, but the HTML receiving part refuses to execute.
Figma.ui.postMessage({type: ‘text’,logsContent});
window.onload = () => {
window.onmessage = (event) => {
if(event.data.type === ‘text’){
document.getElementById(‘logsTextarea’).value = event.data.logsContent;
}
}
};
The instruction ‘window.onmessage = (event)’ keeps failing to execute.

This topic has been closed for comments

3 replies

  • Figmate
  • 1901 replies
  • April 30, 2024

Hey @Bolt, Thanks for reaching out about this!

I’ve moved your topic to the “Plugin and Widget API” category where it’s more likely to catch the eye of other developers who might have some insights.

I’ll also be touching base with our internal team to see if they can lend a hand. We’ll be sure to keep you in the loop as soon as we have any updates.

And of course, we always welcome any insights or suggestions from other folks in our community!

Thanks,


Gleb
  • Power Member
  • 4707 replies
  • April 30, 2024

The UI code looks fine. What does the backend code of the plugin look like? What do you mean by onmessage fails to execute? Does it not run at all? Make sure you are correctly sending the message from the backend.


  • Figmate
  • 1901 replies
  • April 30, 2024

Hi there, here’s some advice from our engineer on this.

Instead of event.data, they need to read from event.data.pluginMessage in their onmessage handler.
You can find more details on this here: Creating a User Interface - Sending a message from the plugin code to the UI

Hope this helps!

Thanks,


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings