Skip to main content
Solved

Is there a way to get the current file's ID?


corysimmons

I can’t find this anywhere. I also can’t imagine this is a security risk.

If someone runs XYZ plugin on a specific file, they have access to 99.999999% of the rest of the file… the one thing that seems to be missing is some sort of unique ID for the DocumentNode itself.

My use case is I’m trying to make a public-facing plugin where users can configure settings per-file. I was going to do something like:

figma.clientStorage.setAsync(documentUID, settingsForThisFile)

Best answer by Gleb

figma.com
View original
This topic has been closed for replies.

Gleb
  • Power Member
  • March 21, 2024

corysimmons

Thanks for the prompt reply!

By getting the file ID a plugin gets perpetual access to the file through REST API

If so, could the Figma team make a separate field on the document called notRestApiAccessibleUID or something to easily avoid that?

You can store plugin data right on the document node itself

I tried doing this with figma.root.foo = 'bar' and it told me that node was read only. I saw this mentioned in a couple old threads but couldn’t find any snippets or docs and ChatGPT didn’t help.

Do you happen to know the API for doing something like that? It’d solve my use-case.


Gleb
  • Power Member
  • March 22, 2024

I linked the docs above


corysimmons

D’oh! Thank you! I didn’t realize it was a permalink to a specific part of that page.


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