Unique file identifier

:wave: there

I need to keep some Figma layers in sync with my tool layers.
To achieve that, I store Figma layer ids in my tool to do an update in case of re-sync.

The thing is : I can’t uniquely identify a layer from its id since two files could have the same layer id.
Is there a way to have a unique file identifier? I know the fileKey could do the job, but my plugin is certainly not a private one. Note that I don’t need the exact fileKey, knowing that one file is not that same as another is enough.

Thank you!

1 Like

For the record: I tried putting a custom id on figma.root using setPluginData. It works, but duplicating the file also duplicates this id, thus I can’t achieve unique identification this way.

Will you be publishing the plugin to the Figma Community (if not already published) or are you developing the plugin just for yourself?

If the former, then you need to come up with something, such as asking the user to paste a link to a file in order to get a fileKey. If the latter, then enable the private plugin API in the manifest.json file and use the figma.fileKey.

The plugin is indeed published to the Figma Community.

Thank you for your solution, but asking the user for the link to the file he is already on, I am afraid that the user experience will be pretty bad.

Unfortunately, I don’t see any other way.