How is plugin data shared between users

Hello.
It’s not clear to me how data set with setPluginData or getSharedPluginData are shared between users.
For example, User “A” puts some data into the Node with the plugin. Is those data available for all users of the plugin or only to User “A”?

This data is stored in the node itself so it is available to all users who have access to the document with this node. If the node with the data is still there of course.

Shared plugin data allows other plugins to access it. If you use non shared plugin data, only the plugin that wrote this data will have access to it.

1 Like

It also depends on the logic of the plugin. For example, it can store the user.id, and only show data to that user.

1 Like

@Gleb @tank666
Thank you a lot for the clarification.
One more question. Am I right that plugin data will be available through public API whenever have user installs this plugin or not?

Yes, it is just like any other property stored on the node.

Saved plugins don’t affect this data (they don’t affect anything except what user sees in their saved plugins menu). You cannot “install” plugins in Figma — every plugin is available without installation.

2 Likes

How does this technically work @Gleb ? Im looking at a selected node in the console that I know has third-party party plugin data saved against it (I see it in the Plugin panel in the UI) but I cant work out which property in the node its using to save the data. Is it actually saved on the node (and in which case which property is it?) or is there another data table of node Id to plugin data mappings somewhere thats hidden to the console/plugin api?

Which panel is that? If you are talking about the right panel, you are not seeing it because of the saved data, you are seeing it because it has set a relaunch button.

Also what are you trying to do? I don’t get what you are trying to achieve. I think you are confusing three different things: plugin data, saved plugins and plugin relaunch button. They are all independent concepts and don’t affect each other at all.

Thanks Gleb. I should give fuller context.

I have a simple rectangle in Figma that uses Token Studio to apply a ‘fill’ using design tokens. So that plugin has obviously saved its custom token mapping using setPluginData(). What I was trying to do in my plugin was create a new rectangle and add that custom data to it so I was trying to look in the console to see what custom data Token Studio was writing. I could then create rectangles in my own plugin that have Token Studio design tokens applied.

Ive realised this probably isnt the best approach. Im now making the ‘design-tokened’ rectangle into a component and now just trying to create an instance of that in my plugin, hoping that it retains its Token Studio plugin data context. We shall see…

Thanks for the reply.

You can do that if Token Studio uses setSharedPluginData, not setPluginData (and I believe it does, I think I’ve seen some plugins use this data, you need to check the docs). You can read shared plugin data using getSharedPluginData:

To find which keys TS used to store this data use getSharedPluginDataKeys RectangleNode | Plugin API

Ah awesome. Thanks so much

For future reference, if anyone else needs this

Their namespace is just “tokens”. It means you can do:
Figma.currentPage.selection[0].getSharedPluginData(“tokens”, “fill”)

I love the Token Studio guys, they’re so open and aware of what they’re doing for the community. Figma take note!