Skip to main content

setPluginData

Lets you store custom information on any node or style, private to your plugin.

Signature

setPluginData(key: string, value: string): void

Parameters

key

The key under which to store the data. This is similar to writing to a plain object via obj[key] = value.

value

The data you want to store. If you want to store a value type other than a string, encode it as a JSON string first via JSON.stringify and JSON.parse. If you set the value to the empty string (""), the key/value pair is removed.

Remarks

The data is specific to your plugin ID. Plugins with other IDs won't be able to read this data. You can retrieve it later by calling getPluginData with the same key. To find all data stored on a node or style by your plugin use getPluginDataKeys.

caution

⚠ The data is stored privately for stability, not security. It prevents other plugins from accessing with your data. It does not, however, prevent users from seeing the data given sufficient effort. For example, they could export the document as a .fig file and try to decode it.

caution

⚠ Data will become inaccessible if your plugin ID changes.