What is the most efficient way to save user's data in plugins?

Hi there,

I am new to development and I recently released a simple plugin for generating a defined set of pages in Figma. I am working on the next release of it by adding a feature to let the user create, read, update and delete the list of names for pages so that the plugin can generate their personalized set of pages when they select the list and run the plugin. The list they create and save will just be a string.

From reading a lot of posts, the recommended API is figma.clientStorage which I’m having a hard time figuring out how to use it. Can this only be used in the code.ts file? I tried using this code in code.js but I’m getting the below error in the console:

Promise {<rejected>: 'Failed to set client storage key "key": Error: Cannot access client storage without a plugin ID'}

I am using the figsvelte plugin development boilerplate.

I was wondering if there are there are any other simple alternatives to store plugin data so that everytime a user runs the plugin, it has the data they saved?

I’d really appreciate it if someone can explain in simple terms how to approach this.

Yes, the figma global object can only be accessed from code.ts (js).

Add plugin id to manifest.json.

If you want to store data in Local Storage so that it can be accessed regardless of which file the plugin is launched in, then you need figma.clientStorage. And if you don’t need it, then you can consider storing the data in the node(s) of the file. There are the following methods for this:

You can search and see examples of using this property on this forum, GitHub, etc.:

Thank you so much for your responses! I will look at both of those plugin APIs.