Skip to main content
Question

Communicating between Prototype and Figma Plugin


I’ve created a Figma plugin to get the state of local variables then trigger external API’s based on that state change.

I’m trying to have a prototype instance of the file communicate with the Figma Plugin I created so when I click a UI element in the prototype, a variable changes which triggers an external API. Right now, there’s no way I can find to ‘listen’ for the variable state change in a prototype because it does not ‘write’ to the original variable value.

11 replies

tank666
  • 4854 replies
  • December 27, 2023

Plugins cannot run in Presentation mode, and therefore receive changes from the prototype.


xiduzo
  • New Participant
  • 8 replies
  • September 8, 2024

is this still the current behaviour? or can the plugin API already access the prototype variable values?


dvaliao
Figmate
  • Community Support
  • 4591 replies
  • September 9, 2024

Hey @xiduzo, thanks for following up!

This is still the expected behavior. Plugins do not run in Presentation mode.


xiduzo
  • New Participant
  • 8 replies
  • January 15, 2025

Hey ​@dvaliao, I think my last reply was taken away due to the migration to the new forum (love it by the way) and me not reading the huge banner on top. User never read right :p

Anyway, I was wondering if this is something which is being noticed as a actual bug?

I can see that plugins, like https://www.figma.com/community/plugin/1355055910166329140/variables-inspector, are using the https://www.figma.com/plugin-docs/api/properties/nodes-setboundvariable/ API to actually get updates from within the presentation mode.

This to me indicates that Figma has access to these variable changes from within the presentation mode, however slightly limited, and it would be wonderful for plugin developers to gain access to this as well!

I can imagine extending the current variable API with `.getPreviewVariablesAsync` similar to https://www.figma.com/plugin-docs/api/properties/figma-variables-getlocalvariablesasync/ or `.getPreviewVariableByIdAsync` like https://www.figma.com/plugin-docs/api/properties/figma-variables-getvariablebyidasync/.

Curious to hear your thoughts on this or any update regarding this issue!


dvaliao
Figmate
  • Community Support
  • 4591 replies
  • January 15, 2025

Hi @xiduzo, thanks for replying again!

Yes - it does seem that your last reply was lost in the migration, but glad to hear you’re loving the changes. 😁


I took a look at your linked plugin, and yes - you can use a plugin in editor mode, so that your changes can/will appear in real-time to viewers of a presentation. That’s how the plugin you’ve linked is able to been seen in prototype mode. But keep in mind, there is still no way to run a plugin in presentation mode, so this is still expected behavior rather than a bug.

As shown in their YouTube demo, they run the plugin first in editor mode then switch to view the frame running the plugin in presentation mode. Again, you can’t “run” a plugin in a prototype itself, but you can always run them in a separate Figma edit window and still see it if set up to be visible within presentation mode. Hope this helps clarify! 



 


xiduzo
  • New Participant
  • 8 replies
  • January 16, 2025

Thank you for your quick answer,

I think there might be some misunderstanding of what I am asking here.

I would like to know if it is possible to gain access to the variable values from the running preview mode. And if not, is there any feature plans to allow this in the (hopefully near) future?

I understand that, as of right now, you are not able to run the plugin directly inside of the preview mode, this is not what I am asking for.

However, I can see that the preview mode does react to changes of variables from the editor mode (your local variables) and the preview mode does have some way of updating values bound to variables (like the linked plugin is doing).

It does not make sense to me that my plugin, which runs from the editor mode, can affect variables in the preview mode by editing the local variables via the API but that same plugin does not have any access to see what are the values of that running preview.

For example;

I made a simple shopping cart page with some prototyping logic that calculates the amount of items the user has added to the cart (using variables) and based on the items price (using variables) I can calculate the total shopping cart amount (again, using variables). With all of this neat prototyping I can update the UI perfectly by linking text frames to the above mentioned variables.

Now, I would also be interested, from my plugin running in editor mode, to see the current state of the variables of the preview mode, not just of the local variables I have declared (which do not update from prototyping interactions).

I hope this clarifies the issue and I am looking forward to your response!


Cheers


dvaliao
Figmate
  • Community Support
  • 4591 replies
  • January 16, 2025

Thanks for clarifying, ​@xiduzo

I’ll pass this onto our variables team for more input. I’ll follow up with an update, if this can be added to the future roadmap. 


xiduzo
  • New Participant
  • 8 replies
  • February 7, 2025

hey ​@dvaliao, any update on this issue?

If you need any more input or clarification, do not hesitate to reach out to me!


Cheers


xiduzo
  • New Participant
  • 8 replies
  • March 5, 2025

@dvaliao has this landed in the variables team? Is there perhaps any expected timeline for this or is this a feature that will “never” be added to Figma?

Seeing the following post on the forum I can see there is a broader need for this, any update would be very helpful!

 


dvaliao
Figmate
  • Community Support
  • 4591 replies
  • March 7, 2025

Hey ​@xiduzo, thanks for following up! 

Right now, this is a systemic limitation to how variables/plugins/prototyping currently only work in one direction: syncing of editor > preview. Because of this, no plugin running in the editor can truly listen to changes in the prototype. 

The variables team understands that you want to read (temporary) values of variables in the preview mode, but as it stands, there is no syncing of preview > editor; it is a one-way push. This capability would have to be built to function as you’d expect, so while it is now on their radar for the future, we cannot guarantee when/if it will be implemented, which is sadly why I wasn’t able to follow up that it was officially on the roadmap. 


xiduzo
  • New Participant
  • 8 replies
  • March 7, 2025

Thank you for the update ​@dvaliao, it is unfortunate to hear that there is no possibility to have this for of synchronisation or any other way to read the (temporary) values from the preview.

As I am truly interested in this feature, I would be interested in any future updates. As I mentioned before, please don’t hesitate to reach out to me! Perhaps my plugin could serve as an example case for such a feature :)


Reply


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